Skip to content

Instantly share code, notes, and snippets.

@korya
korya / Merge a git repo as a subdir.md
Last active August 29, 2015 14:15
Merge a git repo as a subdir

In one of my previous gists, there are instructions for converting a repo subdir to a separate repo. In this git we'll go in opposite direction. Suppose we have 2 git repositories A and B.

Problem

Merge B repo into A as dir b/.

Solution

# Clone A
git clone https://github.com/korya/A

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
@korya
korya / _cassandra-best-practices.md
Last active October 16, 2015 21:40
Cassnadra Best Practices

Cassandra Best Practices

@korya
korya / gist:b56653d786f1e3abdec2
Created October 24, 2015 01:23 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@korya
korya / gist:7368277
Last active December 27, 2015 18:18
Notes for HTML5 Game Development by Udacity

XMLHttpRequest

  1. Create a new request
  2. Prepare the request
  3. Set the onload callback. The callback can access the response by referencing this.responseText.
  4. Send the request
  var xhr = new XMLHttpRequest();
@korya
korya / bithacks.html
Created February 16, 2016 18:30
Bit Hacks
<html>
<head>
<title>
Bit Twiddling Hacks
</title>
</head>
<body>
@korya
korya / transform.js
Created March 11, 2016 14:45
CSS3 transform matrix in JS
// Based on https://github.com/enepomnyaschih/jwcanvas/blob/master/jwidget/public/jwcanvas/transform.js
class Transform {
constructor() {
// / a c e \
// | b d f | => [a, b, c, d, e, f]
// \ 0 0 1 /
this.matrix = [1, 0, 0, 1, 0, 0];
}
@korya
korya / handler.js
Created April 11, 2016 12:45 — forked from ThisIsMissEm/handler.js
The better way to execute Go on Amazon Lambda (see: http://blog.0x82.com/2014/11/24/aws-lambda-functions-in-go/)
var child_process = require('child_process');
exports.handler = function(event, context) {
var proc = spawn('./test', [ JSON.stringify(event) ], { stdio: 'inherit' });
proc.on('close', function(code){
if(code !== 0) {
return context.done(new Error("Process exited with non-zero status code"));
}