Skip to content

Instantly share code, notes, and snippets.

View melvynhills's full-sized avatar

Melvyn Hills melvynhills

View GitHub Profile
// PEOPLE
\ud83d\ude00
\ud83d\ude2c
\ud83d\ude01
\ud83d\ude02
\ud83d\ude03
\ud83d\ude04
\ud83d\ude05
\ud83d\ude06
// PEOPLE
\U0001F600
\U0001F62C
\U0001F601
\U0001F602
\U0001F603
\U0001F604
\U0001F605
\U0001F606
// PEOPLE
😀
😬
😁
😂
😃
😄
😅
😆
@melvynhills
melvynhills / gist:b692531c926d735e8672
Created October 30, 2014 17:07
Find duplicate records in Rails
User.select(:name,:email).group(:name,:email).having("count(*) > 1").count
git push origin (see push.default setting)
git push origin master (git push origin master:master)
git push staging new-feature:master (push new-feature branch to master on remote)
git push origin :old-branch (push nothing to old-branch, delete)
@melvynhills
melvynhills / animation.rb
Created February 25, 2014 16:25
RubyMotion UIView animation wrapper
class Animation
def initialize(duration, animations, completion=nil, delay=0, additionalOptions=nil)
if duration + delay == 0
animations.call
completion.call if completion
return
end
options = UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseOut
# Fixes key command originally mapped to "html_to_jade_from_selection"
# ~/Library/Application Support/Sublime Text 2/Packages/Sublime-JS-to-CoffeeScript/Default (OSX).sublime-keymap
[
{ "keys": ["shift+alt+s"], "command": "js_to_cs_from_selection"}
]
@melvynhills
melvynhills / gist:5575178
Last active June 26, 2019 12:37
Throttle / debounce functions (underscore.js)
// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time.
var throttle = function(func, wait) {
var context, args, timeout, throttling, more, result;
var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
return function() {
context = this; args = arguments;
var later = function() {
timeout = null;
if (more) func.apply(context, args);
{Module} = require 'coffeescript-module'
class Foo extends Module
log: -> console.log 'hi!'
class Bar extends Module
@delegate 'log', Foo
@aliasFunction 'b', 'a'
@aliasProperty 'd', 'c'
@melvynhills
melvynhills / open-ios-app.js
Created February 28, 2013 15:45
Launch an iOS app if it's installed, or redirect to the App Store.
function openIOSApp() {
window.location = "my-app-scheme://";
setTimeout(function() {
window.location = "itms://itunes.apple.com/us/app/my-app-name/my-app-id";
}, 0);
}