Skip to content

Instantly share code, notes, and snippets.

@r38y
r38y / run_dms.rb
Created October 22, 2015 20:20
RunDMS
require 'net/https'
require 'uri'
class RunDMS
def self.snitch(id, options={}, &block)
dead_man = new(id, options)
block.call
dead_man.snitch
end
@einfallstoll
einfallstoll / README.md
Created June 30, 2015 13:30
Reset Spotlight Location (Fix for OS X 10.11 El Capitan)

Installation for GUI Users

  1. Right click the file and choose information and choose to always open this file with Terminal.app

  2. Go to the Terminal.app and do something like this chmod 744 Reset Spotlight.sh

  3. There you go, you can now double click it so reset the Spotlight location

  4. Optional: Uncomment line for the useCount to prevent Spotlight to forget that you already used it

@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@brianhempel
brianhempel / bench_rails_memory_usage.rb
Last active October 6, 2022 12:47
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@bobbygrace
bobbygrace / trello-css-guide.md
Last active April 22, 2024 10:15
Trello CSS Guide

Hello, visitors! If you want an updated version of this styleguide in repo form with tons of real-life examples… check out Trellisheets! https://github.com/trello/trellisheets


Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

@jjb
jjb / gist:7389552
Last active March 16, 2024 18:48
Ruby 2.1 memory configuration

This all applies to Ruby 2.1. In some cases a setting is not available in 2.0, this is noted. There is also a different with 1.9, 1.8, and REE --- these are not noted.

All the relevant code is in https://github.com/ruby/ruby/blob/master/gc.c

RUBY_HEAP_MIN_SLOTS

default: 10000

The number of heap slots to start out with. This should be set high enough so that your app has enough or almost enough memory after loading so that it doesn't have to allocate more memory on the first request (althogh this probably isn't such a big deal for most apps).

(todo: figure out how big a slot is. i think the answer can be infered from this code.)

@tokenvolt
tokenvolt / simple_form_bootstrap3.rb
Last active November 2, 2023 11:55
Bootstrap 3 simple form initializer
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
@adamico
adamico / collection_check_boxes_input.rb
Last active April 28, 2020 15:12 — forked from mattclar/simple_form.rb
This fork adds a custom horizontal form wrapper and merges append/prepend in a 'group' wrapper
#app/inputs/collection_check_boxes_input.rb
class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput
def item_wrapper_class
"checkbox-inline"
end
end
@nowlinuxing
nowlinuxing / gist:6435240
Created September 4, 2013 10:23
execute Controller#action via rails runner with user authentication (devise)
rails runner "ApplicationController.allow_forgery_protection = false; s = ActionDispatch::Integration::Session.new(Rails.application); s.post('/login', user: {login: 'admin', password: 'password'}); s.get('/my'); puts s.response.body"
@r38y
r38y / console_fallback.js
Last active August 15, 2016 08:36
Make console.log bulletproof.
// see if the browser supports console.log - fail gracefully if it doesn't
try {
console.log();
console.debug();
console.assert();
} catch(e) {
console = {
log: function() {},
debug: function() {},
assert: function() {}