Skip to content

Instantly share code, notes, and snippets.

@foxumon
foxumon / csv_export.rb
Created April 29, 2016 20:19
Export table to CSV with all attributes in rails console
require 'csv'
file = "#{Rails.root}/public/data.csv"
table = User.all;0 # ";0" stops output. Change "User" to any model.
CSV.open( file, 'w' ) do |writer|
writer << table.first.attributes.map { |a,v| a }
table.each do |s|
writer << s.attributes.map { |a,v| v }
@jamescmartinez
jamescmartinez / slack_delete.rb
Last active May 28, 2024 15:00
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,

Updating rbenv Ruby to use newer OpenSSL versions

rbenv/ruby-build don’t use Homebrew-installed versions of OpenSSL — instead, they on OS X's built-in ancient version.

This can throw OpenSSL::SSL::SSLErrors when talking to websites that enforce newer SSL/TLS protocols and ciphersuites.


1: Dependencies

@chrislkeller
chrislkeller / import_json_appsscript.js
Last active September 5, 2024 15:22
Adds what amounts to an =ImportJSON() function to a Google spreadsheet... To use go to Tools --> Script Editor and add the script and save.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@yurivictor
yurivictor / css-best-practices.md
Created August 20, 2012 22:09
CSS best practices for The Washington Post

CSS best practices

Do

  • Use Eric Meyer's CSS override
  • Use clearfloat instead of clear:both, when applicable
  • Use core html over divs whenever possible (h2, p, li, ol, time)
  • Add a top level ID to every kind of page (#race-page, #candidate-page)
  • Use IDs for elements that are unique to every page in the site
  • Use hyphens for IDs and classes, no camelCase or underscores. (Improves readability)
@giratikanon
giratikanon / gist:2308213
Created April 5, 2012 05:25
Save a Chrome page as a keyworded custom search in Alfred
on alfred_script(q)
set theURL to ""
set pageName to ""
tell application "Google Chrome"
set theURL to URL of active tab of window 1
set pageName to title of active tab of window 1
end tell
tell application "Safari"
if not (exists (document 1)) then
tell application "Safari" to activate
@jeremyjbowers
jeremyjbowers / awesome.js
Created October 31, 2011 14:29 — forked from drinks/awesome.js
Better AutoAwesome
var loveit = function(){var e,el,interval=Math.random()*60000;e = new jQuery.Event("click");e.pageX=1;e.pageY=1;el = jQuery('.record_pile:last').nextAll('a').eq(2);turntable.lastMotionTime=new Date().getTime();el.hover().trigger(e);setTimeout(loveit, interval);};loveit();