Skip to content

Instantly share code, notes, and snippets.

@parmentf
parmentf / GitCommitEmoji.md
Last active May 2, 2024 20:29
Git Commit message Emoji
@tkrajcar
tkrajcar / newrelic-metaprogramming-challenge.md
Created November 21, 2014 18:56
New Relic Ruby Metaprogramming Challenge

Your challenge, should you accept it, is to write a Ruby library that will modify an existing program to output the number of times a specific method is called.

You solution library should be required at the top of the host program, or via ruby's -r flag (i.e. ruby -r ./solution.rb host_program.rb).

Your solution library should read the environment variable COUNT_CALLS_TO to determine the method it should count. Valid method signatures are Array#map!, ActiveRecord::Base#find, Base64.encode64, etc.

Your solution library should count calls to that method, and print the method signature and the number of times it was called when the program exits.

Also, your solution should have a minimal impact on the program's running time. set_trace_func is a no-go...

@eoinkelly
eoinkelly / getting_started.md
Last active February 1, 2016 21:50
Getting started with requirejs-rails

Usage

  1. Add this to your Rails app's Gemfile:

    gem 'requirejs-rails'
    

    and then run bundle install on the command line.

@evanphx
evanphx / bundle-update-lockfile.rb
Last active August 8, 2016 11:44
Need to update a Gemfile.lock but don't want to install the gems? No problem! Run this in the same directory as your Gemfile!
#!/usr/bin/env ruby
require 'bundler'
gems = ARGV
if gems.empty?
puts "Updating all gems"
Bundler.definition(true)
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@evtuhovich
evtuhovich / rmongo.rb
Created December 18, 2012 11:58
Код к докладу "Нетрадиционное использование Ruby и PostgreSQL" http://www.slideshare.net/evtuhovich/ruby-postgresql
require 'rubygems'
require 'pg'
require 'yaml'
class DB
def initialize(debug = true)
@conn = PG::Connection.open()
@debug = debug
end
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 3, 2024 19:09
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@jboner
jboner / latency.txt
Last active May 3, 2024 15:17
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@fred
fred / application_controller.rb
Created April 29, 2012 07:20 — forked from skamithi/application_controller.rb
Adding Opensearch to my Rails 3.2 app
#app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
def opensearch
response.headers['Content-Type'] = 'application/opensearchdescription+xml; charset=utf-8'
end

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: