This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mruby.h> | |
#include <mruby/compile.h> | |
#include <mruby/string.h> | |
#include <stdio.h> | |
mrb_state* mrb; | |
void p(mrb_value value) { | |
printf("--> %s\n", mrb_str_to_cstr(mrb, mrb_inspect(mrb, value))); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
import Data.Monoid | |
data MState s a = MState s a | |
instance Monoid s => Functor (MState s) where | |
fmap f (MState st x) = MState st (f x) | |
instance Monoid s => Applicative (MState s) where | |
pure = return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "nokogiri" | |
require "pry" | |
doc = Nokogiri::XML(File.read("collection.nml")) | |
def update_playlist(doc, playlist_name, xpath) | |
playlist = doc.xpath("/NML/PLAYLISTS//NODE[@TYPE='PLAYLIST'][@NAME='#{playlist_name}']/PLAYLIST").first | |
playlist.children.remove |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function query<T>(selector: string, klass: Class<T>): T { | |
let element = document.querySelector(selector); | |
if (!(element instanceof klass)) { | |
throw new TypeError("expected " + selector + " to select element of type " + (klass : Function).name); | |
} | |
return element; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "nokogiri" | |
require "pry" | |
doc = Nokogiri::XML(File.read("collection.nml")) | |
def update_playlist(doc, playlist_name, xpath) | |
playlist = doc.xpath("/NML/PLAYLISTS//NODE[@TYPE='PLAYLIST'][@NAME='#{playlist_name}']/PLAYLIST").first | |
playlist.children.remove |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
#include <errno.h> | |
struct worker_ctx { | |
pthread_t thr; | |
size_t n; | |
size_t stride; | |
size_t offset; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "activerecord", "4.2.4" | |
require "active_record" | |
ActiveRecord::Base.logger = Logger.new($stdout) | |
ActiveRecord::Base.establish_connection :adapter => "mysql2", :database => "test" | |
# --------------------------------------------------------------------- | |
ActiveRecord::Base.connection.transaction do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "rails", "3.2.21" | |
require "rails/all" | |
class MyApp < Rails::Application | |
end | |
def path_for(opts) | |
MyApp.routes.url_helpers.url_for(only_path: true, **opts) | |
rescue => e | |
e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Reverse<T>(slice []T) { | |
for i := 0; i < len(slice) / 2; i++ { | |
j := len(slice) - i - 1 | |
x := slice[j] | |
slice[j] = slice[i] | |
slice[i] = x | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module GitHub | |
# GitHub::RenameColumn helps us rename columns on ActiveRecord models in the | |
# cases where we're unable or unwilling to migrate the table in question to | |
# rename the column. | |
# | |
# For example, to rename the column 'watcher_count' on the Repository model | |
# to 'stargazer_count' to better represent what data the column actually | |
# stores, you'd put some code like this in app/models/repository.rb: | |
# | |
# extend GitHub::RenameColumn |
NewerOlder