Skip to content

Instantly share code, notes, and snippets.

Avatar

jdrydn jdrydn

View GitHub Profile
@jdrydn
jdrydn / Vue-HTTP-APIG.md
Last active Mar 27, 2021
Serve a Vue SPA through API-Gateway
View Vue-HTTP-APIG.md

Vue HTTP API-Gateway

Serve a Vue SPA through API-Gateway.

Deploy

$ aws cloudformation deploy \
  --stack-name vue-frontend-prod \
 --template-file ./vue-http-apig.yml
View cluster.js
if (require('cluster').isMaster) {
const cluster = require('cluster');
const CPU = require('os').cpus();
const LIMIT = process.env.LIMIT || CPU.length;
const start = Date.now();
// Generate a list of MAX numbers to loop through
const LIST = (new Array(parseInt(process.env.MAX || 10, 10))).fill(null).map((v, k) => k + 1);
@jdrydn
jdrydn / HINCRALLBY.lua
Last active Apr 19, 2017
Grab your shovels, that Redis instance won't be around much longer
View HINCRALLBY.lua
-- Usage: HINCRALLBY AKeyOfYourChoice 1
-- HKEYS AKeyOfYourChoice
-- HINCRBY AKeyOfYourChoice KEY 1
-- Not sure on performance or what would happen with a hash of 100,000 keys
-- And I don't really want to find out!
local keys = redis.call("HKEYS", ARGV[1])
local results = {}
for i,k in ipairs(keys) do results[i] = redis.call("HINCRBY", ARGV[1], keys[i], ARGV[2]) end
return results
View keybase.md

Keybase proof

I hereby claim:

  • I am jdrydn on github.
  • I am jdrydn (https://keybase.io/jdrydn) on keybase.
  • I have a public key ASAA7zfX7R6N4pdJFnxZX4ff-GhgoRhawwfaikF4hLwlFQo

To claim this, I am signing this object:

View Sockets.md

A Friday Project of Sockets

View scan.js
module.exports = function scanEach(redis, opts, eachFn, callback) {
var scan_args = [ opts.cursor || 0 ];
if (opts.prefix) scan_args.push('MATCH', opts.prefix);
if (opts.count) scan_args.push('COUNT', opts.count);
scan_args.push(function (err, results) {
if (err) return callback(err);
if (!Array.isArray(results)) return callback(new Error('Invalid results from redis SCAN command'));
@jdrydn
jdrydn / Sherlock.md
Last active Mar 13, 2016
Archived the old Sherlock project
View Sherlock.md

Sherlock

A simple proxy service that takes requests and send them to specific ports based on their hostname.

Nothing special at all & extremely helpful once upon a time ago.

Uses http-proxy and forever.

View loader.js
/**
* A really nice way to dynamically load JavaScript files.
* Place this at the bottom of HTML files to load JavaScripts after pageload! :)
*
* The cake is still a lie.
*/
(function(d, scripts){
for(var id in scripts) if (d.getElementById(id) == null) {
var js = d.createElement('script'); js.id = id; js.src = scripts[id];
d.body.appendChild(js);
@jdrydn
jdrydn / csv-email.php
Created Jun 18, 2014
A simple script to email the results of a query as a CSV.
View csv-email.php
<?php
$query = 'SELECT id, column1, column2, column3 FROM ImportantTable WHERE something LIKE "SomethingElse%";';
exec("mysql -h 123.456.789.012 -u SomeImportantUser -p'P4ssw0rd!' BigImportantDatabase -e '$query' | sed 's/\t/,/g' > ".__DIR__."/output.csv");
$mail = new stdClass;
$mail->to = "james@jdrydn.com";
$mail->subject = "CSV Output for that query you asked for";
$mail->hash = md5(uniqid());
$mail->headers = array(
@jdrydn
jdrydn / .svnextended
Last active Aug 29, 2015
Extending SVN's features to include common tasks such as tagging.
View .svnextended
#!/bin/bash
# Just overriding the main SVN command
# So we can catch any requests to tag
# @javajawa++
function svn
{
case "$1" in
tag)
if [ ! -d ".svn" ]; then