>! spoiler
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 MergeGifPlugin(options) { | |
} | |
MergeGifPlugin.prototype.apply = function(compiler) { | |
compiler.plugin("emit", function(compilation, callback){ | |
// console.log(compilation) | |
// console.log(compilation.missingDependencies) | |
console.dir(Object.keys(compilation.errors[0])) | |
console.log(compilation.errors[0].name) | |
console.log(compilation.errors[0].message) | |
}) |
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
# this is a fish function | |
# if using fish, add this to a new file at ~/.config/fish/functions/read-md.fish | |
# otherwise, use line 2 only and replace $argv with a markdown file path. | |
function read-md | |
pandoc $argv | lynx -stdin | |
end | |
# source: | |
# http://unix.stackexchange.com/a/120519/65890 |
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
# note this is a fish function | |
# if you're using fish shell, create a new file called ~/.config/fish/functions/record-out.fish | |
# and copy this in there | |
# | |
# otherwise, just use line 2 and replace $argv with a filename such as out.mp3 | |
function record-out | |
parec -d alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | lame -r -V0 - $argv | |
end |
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
def proc_with_closure(val) | |
Proc.new { other_function(val) } | |
end | |
class Tester | |
def self.other_function(val) | |
val * 2 | |
end | |
end |
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
N = 10000000 | |
SET INSERTION: | |
user system total real | |
13.080000 0.370000 13.450000 ( 13.453529) | |
HASH INSERTION: | |
user system total real | |
12.870000 0.330000 13.200000 ( 13.193739) | |
SET DELETION: | |
user system total real |
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
def search(term) | |
@client.search({ | |
index: "trends", | |
type: "trend", | |
body: { | |
suggest: { | |
name_suggest: { | |
prefix: term, | |
completion: { | |
field: "name_suggest" |
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
# ~/.config/fish/functions/cfn.fish | |
# stands for "cat function" (shows a function definition) | |
function cfn | |
cat ~/.config/fish/functions/$argv.fish | |
end | |
# ~/.config/fish/functions/cfn.fish | |
# stands for "functions" (lists functions) | |
function fns | |
ls ~/.config/fish/functions |
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
class ActiveRecord::Query | |
def preload_map(association_name_sym) | |
preload(association_name_sym).map &association_name_sym | |
end | |
alias map_with_preload preload_map | |
end | |
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
THREAD_LIMIT = ENV["THREAD_LIMIT"].to_i || 10 | |
THREAD = {count: 0} | |
class TooManyThreadsError < StandardError; end | |
class Thread | |
def new(*args, &blk) | |
too_many_threads_error if THREAD[:count] > THREAD_LIMIT | |
THREAD["count"] += 1 | |
super(*args, &->{blk.call; THREAD["count"] -= 1}) |