Skip to content

Instantly share code, notes, and snippets.

View semikolon's full-sized avatar

Fredrik Bränström semikolon

View GitHub Profile
# this is a dirty implementation of logger that
# compiles AR queries with trace into /last_request_log.html
# the snippet is useful when optimizing performance of the endpoint
class QueryLogSubscriber < ActiveSupport::LogSubscriber
TRACE_LEVEL = :app
LINES = 5
IGNORE_CACHED_QUERIES = false
def initialize
#
#= dump database to yaml for fixtures
#
# originated by elm200 <http://d.hatena.ne.jp/elm200/20070928/1190947947>
#
#== install
#
# move this file to RAILS_ROOT/lib/tasks/extract_fixtures.rake
#
namespace :db do
@ChuckJHardy
ChuckJHardy / digital_ocean_setup.md
Last active October 27, 2023 17:51
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions

DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3

SSH into Root

$ ssh root@123.123.123.123

Change Root Password

@tdg5
tdg5 / mocha_calls_through.rb
Last active January 11, 2016 15:43
Mocha Expectation#calls_through
module Concerns
module Mocha
module CallsThrough
def calls_through
method_name = @method_matcher.expected_method_name
@mock.instance_variable_get(:@receiver)
@original_method = @mock.instance_variable_get(:@mockery).stubba.stubba_methods.find do |mockery|
mockery.method == method_name
end.instance_variable_get(:@original_method)
self
@rosskevin
rosskevin / Rakefile
Last active October 28, 2015 10:41
Rakefile - less to sass a.k.a. less2sass or less2scss
# less to scss based on http://stackoverflow.com/a/19167099/2363935
namespace :convert do
task :less_to_scss do
source_glob = "assets/less/*.less"
dest_dir = "converted"
rm_r dest_dir rescue nil
mkdir_p(dest_dir)
# A little Meteor CheatSheet about Iron-Router. (updated on a weekly basis)
# Check our Studio: https://gentlenode.com/
meteor add iron:router
meteor update iron:router
# Iron Router > Configuration
@mikaelbr
mikaelbr / destructuring.js
Last active February 21, 2024 20:41
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@rooreynolds
rooreynolds / voltmeter_things.ino
Last active December 29, 2015 18:49
Things-completed-today-meter
const int voltPin = 4;
const int maxVoltAdjust = 230; // analog out is max 255, but for my voltmeter 230 == 100%
void setup() {
pinMode(voltPin, OUTPUT);
Serial.begin(19200);
}
String inData;
@RaVbaker
RaVbaker / readme.md
Last active November 29, 2023 06:08
Reverse engineering Things SQLite tasks database

To open SQLite Things.app database run this command in Terminal.app:

$ sqlite3 ~/Library/Containers/com.culturedcode.things/Data/Library/Application\ Support/Cultured\ Code/Things/ThingsLibrary.db

In SQLite command-line type this query to get your tasks stats:

sqlite> .mode column
sqlite> .header on
sqlite> select zscheduler, zstatus, ztrashed, count(*) from ZTHING where z_ent = 13 group by  zstatus,ztrashed order by Z_pk desc;

ZSCHEDULER ZSTATUS ZTRASHED count(*)

@kenyee
kenyee / gist:6307258
Last active December 17, 2022 10:38
How to add Node.js npms to your Meteor.js project.
Make a subdirectory named packages/mynpms in your project.
Add a package.js that looks something like this:
Package.describe({
summary: "Custom app NPM dependencies"
});
Npm.depends({
nconf: '0.6.7',
feedparser: '0.16.1'