Skip to content

Instantly share code, notes, and snippets.

Brian Mock wavebeem

Block or report user

Report or block wavebeem

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View js.sh
#!/usr/bin/env bash
set -eu
main() {
Object.new |
Object.set name "$(echo Brian Mock | String.new)" |
Object.get name
Array.new |
Array.push 1 |
@wavebeem
wavebeem / 1.js
Created Jun 23, 2017
Which syntax reigns supreme?
View 1.js
r => {
var ElseIf = (
P.seqObj(
keyword("elseif"),
r.Expr.trim(_).as("condition"),
keyword("then"),
r.Block.trim(_).as("block"),
).node("ElseIf")
);
return (
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
checkboxes: Ember.computed(function() {
return Array.from({length: 4}, (x, i) => {
return {
index: i,
checked: i >= 2
};
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
checkboxes: Ember.computed(function() {
return Array.from({length: 4}, (x, i) => Ember.Object.create({checked: i >= 2}));
}),
checkboxesAsJson: Ember.computed('checkboxes.@each.checked', function() {
return JSON.stringify(this.get('checkboxes'), null, 2);
})
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
checkboxes: Ember.computed(function() {
return Array.from({length: 4}, (x, i) => Ember.Object.create({checked: i >= 2}));
}),
checkboxesAsJson: Ember.computed('checkboxes.@each.checked', function() {
return JSON.stringify(this.get('checkboxes'), null, 2);
})
View install.ps1
# cd to directory of dotfiles based on this script.
$scriptDir = Split-Path $SCRIPT:MyInvocation.MyCommand.Path -Parent
$dir = Resolve-Path (Join-Path $scriptDir "..")
cd $dir
function install($path) {
$dir = Split-Path $Path
$filename = (ls $path).Name
if ($dir) {
$prefix = Resolve-Path (Join-Path $HOME ".$dir")
View spin.py
#!/usr/bin/env python
import sys
import time
def uchar(code):
return ('\\U%08x' % code).decode('unicode-escape')
start = 0x1F550
end = 0x1F55B
emoji = map(uchar, range(start, end + 1))
View spin.rb
#!/usr/bin/env ruby
def spin
("\u{1F550}" .. "\u{1F55B}").cycle.each do |moji|
print moji, " "
sleep 0.1
print "\r"
end
end
View decorators.rb
module MyDecorators
def limit(max, name)
tries = 0
m = instance_method(name)
define_method(name) do |*args|
tries += 1
if tries <= max
m.bind(self).call(*args)
else
raise "LIMITER ENGAGED"
You can’t perform that action at this time.