Skip to content

Instantly share code, notes, and snippets.

View kenn's full-sized avatar

Kenn Ejima kenn

View GitHub Profile
@kakutani
kakutani / Annotation.md
Last active September 26, 2019 13:35 — forked from ursm/Gemfile
Raw Gemfile on Idobata (master - 5adeddb)

Idobata Gemfile プレゼント

tl;dr IdotabaのGemfileは"全プレ"になりました。ご笑納ください。→ Gemfile

プレゼントについてのお詫び

rebuild.fmのep36でお知らせさせていただきました、Idobataの最新版Gemfileプレゼントをお届けいたします。 過日はIdobata会議01への多数のご参加ありがとうございました。おかげさまで盛況なミートアップとなりました。 (当日会場を提供いただいたEngine Yardさまのブログにて、Idobata会議01当日の様子がまとめられています。ありがとうございます!)

@nh7a
nh7a / NSObject+AssociatedDictionary.h
Created May 28, 2014 02:29
NSObject+AssociatedDictionary
#import <Foundation/Foundation.h>
@interface NSObject (AssociatedDictionary)
+ (NSMutableDictionary*)associatedDictionary;
- (NSMutableDictionary*)associatedDictionary;
@end
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@peterc
peterc / methods_returning.rb
Last active October 29, 2023 03:10
Object#methods_returning - to work out which method on an object returns what we want
require 'stringio'
require 'timeout'
class Object
def methods_returning(expected, *args, &blk)
old_stdout = $>
$> = StringIO.new
methods.select do |meth|
Timeout::timeout(1) { dup.public_send(meth, *args, &blk) == expected rescue false } rescue false
@javan
javan / application_controller.rb
Created November 30, 2013 22:06
Prevent cross-origin js requests
class ApplicationController < ActionController::Base
before_filter :ensure_xhr
private
def ensure_xhr
if request.get? && request.format && (request.format.js? || request.format.json?)
head :forbidden unless request.xhr?
end
end
end
@danfinlay
danfinlay / How to download streaming video.md
Last active March 23, 2024 03:32
How to download a streaming video with Google Chrome

How to download streaming video

Streaming just means a download that they don't want you to keep. But Chrome's developer tools make it easy to access what's really going on under the hood.

Open Developer Tools

From the page where you want to download some things, go into your chrome menu to open the developer tools. You can either:

1.  (On a mac): Command-option-J
2. (On a PC): Control-alt-J
@sh2
sh2 / order_by.sql
Created October 20, 2013 16:16
ORDER BY狙いのインデックス
CREATE TABLE `customer` (
`c_id` int(11) NOT NULL,
`c_d_id` tinyint(4) NOT NULL,
`c_w_id` smallint(6) NOT NULL,
`c_first` varchar(16) DEFAULT NULL,
`c_middle` char(2) DEFAULT NULL,
`c_last` varchar(16) DEFAULT NULL,
`c_street_1` varchar(20) DEFAULT NULL,
`c_street_2` varchar(20) DEFAULT NULL,
`c_city` varchar(20) DEFAULT NULL,
@jbenet
jbenet / simple-git-branching-model.md
Last active April 9, 2024 03:31
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@willurd
willurd / web-servers.md
Last active May 4, 2024 07:22
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@tenderlove
tenderlove / terrible.rb
Last active May 16, 2020 13:13
I am a terrible person
require 'fiddle'
module IAmAHorriblePerson
def unset flag
value = _wrap self
flags = 8.times.map { |i| value[i] }.pack('C8').unpack('Q').first
[flags & ~flag].pack('Q').unpack('C8').each_with_index { |n,i|value[i] = n }
end
def class= k