ruby
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
// Just an excerpt of the relevant part here | |
<Button | |
title="Click to invoke your native module!" | |
color="#841584" | |
onPress={() => {CameraViewWrapper.testEvent()}} | |
/> |
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
a = new Promise (resolve) -> | |
setTimeout resolve, 1000 | |
b = -> | |
c = await a | |
throw "error" | |
d = -> | |
e = await b() |
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 CoreExt; end | |
module CoreExt::RefinementBuilder | |
def build_refinement(class_name, namespace: Object, refines: Object, &blk) | |
const = namespace.const_set class_name, Module.new(&blk) | |
const.instance_methods(false).each do |method_name| | |
orig_method = const.instance_method method_name | |
const.send :define_method, method_name do |*args, **keywords, &blk| |
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 written for use with https://github.com/maxpleaner/step_sequencer | |
# It should be loaded from the step_sequencer repl using pry's `play` command, | |
# e.g. `play song.rb` | |
Player = StepSequencer::SoundPlayer | |
Builder = StepSequencer::SoundBuilder | |
DrumsPlayer = Player.new %{ | |
"Symbol.mp3", | |
"Hat.mp3", |
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
var fns = []; | |
var arr = [1,2,3]; | |
for (var idx in arr) { | |
fns[idx] = function() { return idx }; | |
}; | |
console.log(fns[0]()); // 2 | |
console.log(fns[1]()); // 2 | |
console.log(fns[2]()); // 2 |
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
Object.prototype.tap = function(f){f.apply(this); return this;} | |
var x = {a:2}; | |
x.tap(function(){console.log(this.a)}).a = 4; //Prints 2 | |
console.assert(x.a == 4); |
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 AutoInitializer | |
def initialize(*args, **opts, &blk) | |
opts.each do |k,v| | |
instance_variable_set(“@#{k}”, v) | |
end | |
super if defined? super | |
end | |
end | |
# Usage |
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
$Tempo = 120.to_f | |
$Sounds = %w{ 2.mp3 1.mp3 1.mp3 1.mp3 } | |
$SoundsIdx = 0 | |
def rest_time_from_tempo | |
60.0 / $Tempo | |
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
require 'json' | |
require 'active_support/all' | |
class GoogleSearch | |
attr_reader :results | |
def initialize(search_term) | |
@results = JSON.parse `googler #{search_term} --json` | |
end | |
end |
NewerOlder