Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am chuyskywalker on github.
  • I am chuyskywalker (https://keybase.io/chuyskywalker) on keybase.
  • I have a public key whose fingerprint is 45FC 2659 BCE7 ECCB 629D 3BE7 5A27 4011 BC1A 6F11

To claim this, I am signing this object:

@chuyskywalker
chuyskywalker / simpler.js
Last active November 17, 2016 04:47
Simpler JS for you
// when the document is fully loaded, run this function
$(document).ready(function(){
// find every checkbox
$('input[type="checkbox"]')
// and bind to the click method to run this function
.click(function(){
// create a variable called "box_value" which has the string from the current element's "value" attribute.
// $(this), in the current context, refers to the input-checkbox that is experiencing a click event
var box_value = $(this).attr("value");
// since the "value" matches the class name, we can start a selector $() which combines a dot and the box_value variable to form a proper class name.
@chuyskywalker
chuyskywalker / app-spread.go
Created September 18, 2016 02:51
Count to MAXINT
package main
// second variant, splits process among cores and creates a unique file for each. MUCH faster, but incurs randomness penelty
import (
"fmt"
"os"
"math"
"math/rand"
"strconv"
import time
import logging
import pprint
import random
from threading import Thread, Event
class lastPerThread(logging.Handler):
"""
A log handler which keeps the last log message availble per thread
"""
@chuyskywalker
chuyskywalker / memsql-sad.php
Last active February 5, 2016 07:07
memsql doesn't like medium ints on prepared statements
<?php
echo '<pre>';
/*
Have a table like
CREATE TABLE `inty` (
`biu` bigint unsigned NOT NULL AUTO_INCREMENT,
`bis` bigint NOT NULL ,
@chuyskywalker
chuyskywalker / dance-party.php
Created August 14, 2014 04:48
Phillips Hue: Dance Party
<?php
/*
* Make your Hue lights dance -- a very rudimentary Hue control script
*/
$ip = 'your-ip-here';
$user = 'your-username-here';
$lights = array_flip(array(1,2)); // 3,4,5, etc
@chuyskywalker
chuyskywalker / client.php
Created August 13, 2014 05:46
Parallel Tasks Spawn Other Tasks As Available
<?php
require './defs.php';
$gearmanClient = new GearmanClient();
$gearmanClient->addServer();
$modelsToRun = [
ModelA::CLASS,
ModelB::CLASS,
@chuyskywalker
chuyskywalker / basic
Created April 21, 2014 03:49
quick docker contained app
# echo '{"test":123, "peso": [1,2,3]}' | docker run -i --rm --networking=false app /bin/bash -c 'cat - | php app.php'
object(stdClass)#1 (2) {
["test"]=>
int(123)
["peso"]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
goofy:
- cmd.run:
- name: echo hello
@chuyskywalker
chuyskywalker / configuration.txt
Last active January 2, 2016 06:48
Salt init, empty top.sls @ 1 minutes
Virtualbox
613mb ram
CentOS6.4
- based on this box: https://github.com/2creatives/vagrant-centos/releases/download/v6.5.2/centos65-x86_64-20131219.box
- from this fellow: https://github.com/2creatives/vagrant-centos/
Just a basic, masterless provision that takes 1 minutes to run.
Minion file looks like: