Skip to content

Instantly share code, notes, and snippets.

@gigablah
gigablah / debounce_test_multi.go
Created January 21, 2016 03:57
Multiple channel debouncing
package main
import (
"fmt"
"time"
"sync"
)
type APIEvents struct {
Status string
@gigablah
gigablah / debounce_test.go
Last active January 20, 2016 04:38
Debouncing Go channels
// Reference: https://gist.github.com/leolara/d62b87797b0ef5e418cd
package main
import (
"fmt"
"time"
)
type APIEvents struct {
@gigablah
gigablah / pie.svg
Created December 2, 2015 15:16
Pie cluster
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gigablah
gigablah / ansible-container.yml
Created November 11, 2015 08:17
Update Docker containers with Ansible
---
- name: Spin up a container
hosts: localhost
connection: local
gather_facts: False
sudo: False
vars:
base_image: gigablah/alpine-python
container_name: ansible_test
tasks:
@gigablah
gigablah / le_spe.c
Created October 21, 2015 16:25
Parallel implementation of the Gaussian elimination algorithm for the STI Cell
#include <spu_intrinsics.h>
#include <spu_mfcio.h>
#include <stdio.h>
#include <string.h>
#include "le_spe.h"
// Local store structures and buffers.
volatile parm_context ctx __attribute__ ((aligned(16)));
volatile float a[BLOCKSIZE] __attribute__ ((aligned(16))); // active row
volatile float x[BLOCKSIZE] __attribute__ ((aligned(16))); // target row
@gigablah
gigablah / bluebird.coffee
Created July 24, 2015 10:24
Bluebird async test
global.P = require 'bluebird'
backoff = 100
max_attempts = 10
_random_time = -> Math.random() * 3000 + 1000;
_backoff = (attempt) -> if attempt > 0 then backoff * Math.pow(2, attempt-1) else 0
_with_retry = (err, attempt, res, rej, callback) ->
return rej(err) if attempt >= max_attempts
P.try ->
return unless err?
@gigablah
gigablah / scripts.js
Last active August 29, 2015 14:25
Kittens game
var hunter = function () {
if ($("#fastHuntContainer a").css('visibility') == 'visible' && gamePage.resPool.resources[6].value < 500) {
console.log("Sending hunters...");
$("#fastHuntContainer a").click();
}
};
var observer = function () {
if ($('#observeBtn').length > 0) {
console.log("Observing...");
$('#observeBtn').click();
@gigablah
gigablah / local.kuanyen.net.conf
Created May 11, 2015 10:19
nginx config for php-fpm socket
server {
listen 80;
server_name local.kuanyen.net;
gzip on;
gzip_min_length 1000;
location / {
root /opt/www;
index index.php;
#!/bin/bash
#+----------------------------------------------------------------------------------------+
#| This file is used to clean up traces from DigitalOcean *images* before being published.|
#+----------------------------------------------------------------------------------------+
unset HISTFILE
files=(/root/.mysql_history /var/log/lastlog /root/.bash_history /var/log/wtmp /var/log/auth.log /var/log/messages /root/.viminfo)
for file in ${files[*]}
do
@gigablah
gigablah / flatten_image.sh
Created November 13, 2014 06:22
Flatten docker image
#!/bin/bash
# See: https://github.com/deis/deis/pull/1825
IMAGE=$1
NEW_IMAGE=$HOST:$PORT/$2:$3
NOW=$(date +"%m%d%Y%H%M%S")
if [ "$#" -ne 3 ]; then