Skip to content

Instantly share code, notes, and snippets.

@cgvarela
cgvarela / JS-Detect-Browser.js
Created September 28, 2015 06:11
Detect what browser we are in and do a focus/blur based on the browser window. (uses jquery.browser.js and modernizr.js)
if($.browser.msie && parseInt($.browser.version) <= 8){ // just for IE8 and lower
$(document).on('focusout', windowBlurred);
$(document).on('focusin', windowFocused);
}else if($.browser.safari && Modernizr.touch && !navigator.userAgent.match(/Android/i) && !navigator.userAgent.match(/CriOS/i)){ // just for ipad / iphone / ipod (Safari mobile, not Android default browsers nor Chrome Mobile that is)
$(window).on('pagehide', windowBlurred);
$(window).on('pageshow', windowFocused);
}else{ // the rest
console.log('chrome');
$(window).on('blur', windowBlurred);
$(window).on('focus', windowFocused);
@cgvarela
cgvarela / amzn.csv
Created October 1, 2015 14:10 — forked from lebek/amzn.csv
Responsive Visualizations: Basic Graph
date close
2014-02-07 361.08
2014-02-06 354.59
2014-02-05 346.45
2014-02-04 347.95
2014-02-03 346.15
2014-01-31 358.69
2014-01-30 403.01
2014-01-29 384.2
2014-01-28 394.43
@cgvarela
cgvarela / mesos_arm.md
Created November 10, 2015 09:43 — forked from moderation/mesos_arm.md
Compile Apache Mesos 0.22 for Raspberry Pi 2

How to compile Mesos on your new Raspberry Pi 2 (which is amazing with 4 cores and 6x performance). Follows on from experiments in compiling for OS X

sudo apt-get install maven libsasl2-dev libapr1-dev libsvn-dev libcurl4-openssl-dev python-dev python-boto

export JAVA_HOME="/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt"
export PATH=$JAVA_HOME/bin:$PATH

http://likemagicappears.com/projects/raspberry-pi-cluster/mesos-on-raspbian/

@cgvarela
cgvarela / gist:dea08dc47f638c9195d2
Created December 15, 2015 10:12 — forked from jodok/gist:38aaaf5826211d5eef8b
amsterdam benchmark
import sys
import time
import random
from crate.client import connect
from threading import Thread
from Queue import Queue
from uuid import uuid1
host = sys.argv[1]
@cgvarela
cgvarela / queries.sql
Created December 15, 2015 10:14 — forked from jodok/queries.sql
-- Techcrunch Demo Queries
-- count all steps records
SELECT count(*) FROM steps;
-- count all steps
SELECT sum(num_steps) FROM steps;
-- count all steps for a specific user
SELECT sum(num_steps) AS steps_for_user FROM steps WHERE username = 'gosinski';
#!/bin/bash
mkfs.ext4 /dev/sdb
mkfs.ext4 /dev/sdc
mkdir /data
mkdir /data/data{1,2}
mount /dev/sdb /data/data1
mount /dev/sdc /data/data2
@cgvarela
cgvarela / batman.m
Created January 26, 2017 09:57 — forked from traeblain/batman.m
Batman Equation
clf; clear; syms x y
eq1 = ((x/7)^2*sqrt(abs(abs(x)-3)/(abs(x)-3))+(y/3)^2*sqrt(abs(y+3/7*sqrt(33))/(y+3/7*sqrt(33)))-1);
eq2 = (abs(x/2)-((3*sqrt(33)-7)/112)*x^2-3+sqrt(1-(abs(abs(x)-2)-1)^2)-y);
eq3 = (9*sqrt(abs((abs(x)-1)*(abs(x)-.75))/((1-abs(x))*(abs(x)-.75)))-8*abs(x)-y);
eq4 = (3*abs(x)+.75*sqrt(abs((abs(x)-.75)*(abs(x)-.5))/((.75-abs(x))*(abs(x)-.5)))-y);
eq5 = (2.25*sqrt(abs((x-.5)*(x+.5))/((.5-x)*(.5+x)))-y);
eq6 = (6*sqrt(10)/7+(1.5-.5*abs(x))*sqrt(abs(abs(x)-1)/(abs(x)-1))-(6*sqrt(10)/14)*sqrt(4-(abs(x)-1)^2)-y);
eqf = '((x/7)^2*sqrt(abs(abs(x)-3)/(abs(x)-3))+(y/3)^2*sqrt(abs(y+(3*sqrt(33))/7)/(y+(3*sqrt(33))/7))-1)*(abs(x/2)-((3*sqrt(33)-7)/112)*x^2-3+sqrt(1-(abs(abs(x)-2)-1)^2)-y)*(9*sqrt(abs((abs(x)-1)*(abs(x)-3/4))/((1-abs(x))*(abs(x)-3/4)))-8*abs(x)-y)*(3*abs(x)+3/4*sqrt(abs((abs(x)-3/4)*(abs(x)-1/2))/((3/4-abs(x))*(abs(x)-1/2)))-y)*(9/4*sqrt(abs((x-1/2)*(x + 1/2))/((1/2-x)*(1/2+x)))-y)*((6*sqrt(10))/7+(3/2-abs(x)/2)*sqrt(abs(abs(x)-1)/(abs(x)-1))-(6*sqrt(10))/14*sqrt(4-(abs(x)-1)^2)-y)=0'
@cgvarela
cgvarela / nginx.conf
Created March 2, 2017 05:57 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@cgvarela
cgvarela / main.go
Created May 28, 2018 09:32 — forked from julz/main.go
containersched minicontainer
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {