Skip to content

Instantly share code, notes, and snippets.

View jalada's full-sized avatar

David Somers jalada

View GitHub Profile
@jalada
jalada / reverse-chunk.js
Created April 8, 2019 11:40
Reverse chunk
const chunk = function(array, size) {
var length = array.length;
var index = length,
result = Array(Math.ceil(length / size)),
resIndex = result.length-1;
var start;
while (index > 0) {
start = Math.max(0, index - size);
result[resIndex--] = array.slice(start, index);
#!/usr/bin/env python
'''
Send Redis connection metrics to Amazon CloudWatch
'''
import sys
import re
from subprocess import check_output
from boto.ec2 import cloudwatch
from boto.utils import get_instance_metadata

Keybase proof

I hereby claim:

  • I am jalada on github.
  • I am jalada (https://keybase.io/jalada) on keybase.
  • I have a public key ASAQDYbixXz7raIFzButKSquHPoB5iexxEVwIEu_kWHm7go

To claim this, I am signing this object:

» curl -vv "https://www.theguardian.com"
* Rebuilt URL to: https://www.theguardian.com/
* Trying 23.235.43.67...
* Connected to www.theguardian.com (23.235.43.67) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: i.ssl.fastly.net
* Server certificate: GlobalSign Organization Validation CA - SHA256 - G2
* Server certificate: GlobalSign Root CA
> GET / HTTP/1.1
> Host: www.theguardian.com
@jalada
jalada / gulpfile.snippet.js
Created July 28, 2015 08:08
Gulp task for deploying dist/ to S3
// Public: Deploy to AWS.
gulp.task('deploy', function() {
var publisher = $.awspublish.create({
params: {
Bucket: 'my-bucket'
},
// Put credentials in .env, use dotenv
region: 'eu-west-1'
});
@jalada
jalada / Example
Last active August 29, 2015 14:22
Create all permutations of an array of an array.
comb([[3], ['a', 'c', 'f'], [4,6], [5,9]])
=> ["3a45", "3a49", "3a65", "3a69", "3c45", "3c49", "3c65", "3c69", "3f45", "3f49", "3f65", "3f69"]
(*
Copyright © 2011, Scott Dollins. All rights reserved.
http://scottdollins.com/
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
@jalada
jalada / index.js
Created October 15, 2014 14:30
Status Codes As A Service
var express = require('express');
var app = express();
app.get('/:status_code', function (req, res) {
if (req.params.status_code.match(/^\d{3}$/)) {
res.status(req.params.status_code).send('');
} else {
res.status(500).send('Not a code');
}
});
@jalada
jalada / gist:16e22f77d99c8567e080
Last active August 29, 2015 14:05
When you find a set of tests on a project you've inherited, and you try and run it.
$ ./some-custom-test-script-our-guy-wrote.sh
Starting test harness...this may take a while...
A bad group name
F: A key piece of functionality
F: Another key piece of functionality
P: A test that doesn't actually do anything
F: What, you thought there were going to be more green ones?
F: Nope, not this one either
-----BEGIN PGP MESSAGE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - http://gpgtools.org
hQEMAx0kRtUDcrDQAQf/VT/qiSK5LZ+JegsGrmd9yjHvoTpIE/06oXTaCacCHGFt
33EnNNjekkxQy/uSWSgxtaQ2fvdlecCiSsc3lzShW+i04o0nOs++HTvbUMZO+Z3A
I5a7WaQjQG3PSEdqCsTGX/eclNBVApvIHwYcqM3+CvFEDFrsZ5yUR4pQQ1Ubvf/o
5aFw68u2Tjfqkty4IE31voO/TyNB7kbi+vFEIgcqTWb9VPN4f8kAEgEpOnxIu2pY
z2xsQX64QUQQwQBU8BSbr1lZcf7+Vd/LuArfL1xm7oFok/9PHDWw9NFEZ8I1vbIB
pqLw8C7gL3turGg2rGYS2nxUka8iLzx4ebPfLrjGBtJCAbN/14uziW7AxHkuLCcr