Skip to content

Instantly share code, notes, and snippets.

View sbward's full-sized avatar
🌱
plant-powered programming

Sam Ward sbward

🌱
plant-powered programming
  • Wellington, New Zealand
  • 05:48 (UTC +12:00)
View GitHub Profile
$('#tools li').each(function() {
analytics.trackLink($(this), 'Social Link', {
platform: $(this).attr('title')
});
});
<div id="footer">
<span id="footer-img"><img src="/images/logo-sm.png" width="58" height="22" alt="ZingCharts" /></span>
<div class="nav">
<?php
$menu = array("Home"=>"$prefix/", "Download"=>"http://www.zingchart.com/download/", "Purchase"=>"$securePrefix/store/buy.php", "Learn"=>"/reference/", "Support"=>"$prefix/support/", "About"=>"$prefix/about/", "Privacy"=>"$prefix/privacy/", "Terms"=>"$prefix/legal/tc.php", "Site Map"=>"$prefix/sitemap/", "White Papers"=>"$prefix/assets/pdf/zc-brochure.pdf");
foreach ($menu as $key => $value){
if ($current_location == $key){
echo $key . " ";
} else if ($key == "White Papers") {
echo "<a href='$value' target='_blank' id='white_papers_link'>$key</a> ";
// Segment.io tracking: which modules were selected?
var props = {};
var $chkboxes = $('.module-option input[type=checkbox]');
$chkboxes.each(function() {
props[$(this).attr('name')] = $(this).attr('checked');
});
analytics.trackForm(form, 'Build Created', props);
@sbward
sbward / mixpanel_people.php
Created July 22, 2014 19:39
Get mixpanel people without emails
<?php
include "mixpanel_data.php"
$mp = new Mixpanel($api_key, $api_secret);
$data = $mp->request(array('engage'), array(
'where' => 'properties["email"] == ""',
'page' => $page
));
@sbward
sbward / andrew.go
Created July 31, 2014 06:13
Code sample from your house
package main
import (
"flag"
"fmt"
"math/rand"
"strconv"
"sync"
)
@sbward
sbward / docker.log
Created August 14, 2014 19:48
strace output
execve("/usr/bin/docker", ["docker", "-d", "-D"], [/* 14 vars */]) = 0
uname({sys="Linux", node="ip-10-5-152-136", ...}) = 0
brk(0) = 0x229d000
brk(0x229e1c0) = 0x229e1c0
arch_prctl(ARCH_SET_FS, 0x229d880) = 0
set_tid_address(0x229db50) = 7479
set_robust_list(0x229db60, 24) = 0
futex(0x7fff70c269c0, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, 229d880) = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGRTMIN, {0x7da500, [], SA_RESTORER|SA_SIGINFO, 0x7dabc0}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x7da590, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7dabc0}, NULL, 8) = 0
[39355.705832] Memory cgroup out of memory: Kill process 8378 (php) score 999 or sacrifice child
[39355.712940] Killed process 8378 (php) total-vm:657284kB, anon-rss:408400kB, file-rss:0kB
[65425.582891] Memory cgroup out of memory: Kill process 8616 (ruby) score 809 or sacrifice child
[65425.589482] Killed process 8612 (wkhtmltoimage) total-vm:346084kB, anon-rss:56492kB, file-rss:0kB
[65427.755910] Memory cgroup out of memory: Kill process 8712 (ruby) score 810 or sacrifice child
[65427.760548] Killed process 8708 (wkhtmltoimage) total-vm:346212kB, anon-rss:56584kB, file-rss:0kB
[65431.124425] Memory cgroup out of memory: Kill process 8764 (ruby) score 810 or sacrifice child
[65431.129199] Killed process 8759 (wkhtmltoimage) total-vm:345964kB, anon-rss:56564kB, file-rss:0kB
[65435.164030] Memory cgroup out of memory: Kill process 8780 (ruby) score 810 or sacrifice child
[65435.168430] Killed process 8776 (wkhtmltoimage) total-vm:345944kB, anon-rss:56428kB, file-rss:0kB
#!/bin/bash
touch kill.me
for i in {0..10000}
do
container_name=$RANDOM-$i
echo $container_name
if [ ! -f kill.me ]; then
echo "Exiting..."
exit 0
fi
  1. install rsync on boot2docker VM
  2. install rsync locally
  3. install fswatch locally
  4. configure docker image to use a data volume, "/mnt/node_src" or whatever. this is a directory inside the VM. do not make this into a shared folder
  5. configure rsync to send your local node source directory to the VM into the "/mnt/node_src" directory (it does this via the network, not vbox shared folders)
  6. configure fswatch locally to trigger rsync when your source code changes
  7. configure forever to watch "/mnt/node_src" for changes in the VM
  8. ?????
  9. profit!
@sbward
sbward / go_macro.rs
Created December 9, 2014 07:23
Goroutines macro (joke)
macro_rules! go(
($inp:expr $sp:path) => (
unsafe{ spawn( $inp ) }
);
)