Skip to content

Instantly share code, notes, and snippets.

@ryands
ryands / callback.js
Created March 28, 2014 22:07
throwaway gist
var addition = function(a, b, callback) {
var result = a + b;
if (callback != null) {
callback(result);
}
};
addition(2, 3, function(result) {
alert("The sum is " + result + "!");
});
@Override
protected void onResume() {
super.onResume();
loadImageWhenReady(imageView, mPayload);
}
private static void loadImageWhenReady(final ImageView v, final String url) {
v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {

Keybase proof

I hereby claim:

  • I am ryands on github.
  • I am ryands (https://keybase.io/ryands) on keybase.
  • I have a public key whose fingerprint is D0CA AAC9 FC0A 7B41 829B 31B0 3369 F0BD BB2C E1EB

To claim this, I am signing this object:

@ryands
ryands / gist:193251a517599d82ed75
Created June 16, 2014 21:47
Lodash vs. Underscore (benchmarks)
Chrome 36.0.1985.67 on OS X 10.9.3
Sit back and relax, this may take a while.
`_(...)` with a number:
lodash.min x 148,659,845 ops/sec ±1.16% (83 runs sampled)
underscore-min x 21,250,737 ops/sec ±0.71% (89 runs sampled)
lodash.min is 596% faster.
`_(...)` with an array:
@ryands
ryands / module.js
Created June 19, 2014 17:49
JS Module pattern - quick example
/* Module pattern in javascript
* Not using RequireJS/ES6/Node/...
*/
var MyModule = (function () {
function SubClass() {
// constructor
}
SubClass.prototype.someMethod = function() {
@ryands
ryands / proxy.js
Created August 4, 2014 21:57
quick node proxy for local XHR proxying
/* Local proxy for XHR testing
*
* Prereq: npm install express request lodash
* Running: node proxy.js
*
*/
// Configuration:
var port = 3001;
var mapping = {
@ryands
ryands / debian.sh
Last active December 6, 2017 13:49
Debian KVM virt-install script
#!/usr/bin/env bash
INSTALL_MEDIA="http://cdimage.debian.org/cdimage/jessie_di_beta_2/amd64/iso-cd/debian-jessie-DI-b2-amd64-netinst.iso"
VMNAME="debian-jessie-vm"
[[ "x$1" != "x" ]] && VMNAME=$1
echo
echo "Building VM: $VMNAME"
echo " Creating disk image"
@ryands
ryands / .tmux.conf
Created December 5, 2014 20:52
~/.tmux.conf
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
set-option -g status-style bg=blue
@ryands
ryands / cast.c
Created February 25, 2015 17:15
demonstrating casting and overflow (trivial)
/* gcc -o cast cast.c */
#include <stdio.h>
int main(int argc, char **argv) {
unsigned long sides;
int input = -5;
sides = input;
printf("Catas input %lu\n", sides);
@ryands
ryands / pullrequest.5m.js
Last active February 4, 2016 17:39
Bitbar pull request monitoring
#!/usr/local/bin/node
// node.js BitBar plugin for pull-request tracking.
var https = require('https');
function pull_requests(options, cb) {
var repo = options.repo,
token = options.token;
https.get({
protocol: 'https:',