Skip to content

Instantly share code, notes, and snippets.

@beherca
beherca / ssdp.node.js
Created April 18, 2016 02:11 — forked from chrishulbert/ssdp.node.js
Service discovery using node.js and ssdp / universal plug n play
var dgram = require('dgram'); // dgram is UDP
// Listen for responses
function listen(port) {
var server = dgram.createSocket("udp4");
server.on("message", function (msg, rinfo) {
console.log("server got: " + msg + " from " + rinfo.address + ":" + rinfo.port);
});
anon true, if the space may be omitted in anonymous function declarations
bitwise true, if bitwise operators should be allowed
browser true, if the standard browser globals should be predefined
cap true, if upper case HTML should be allowed
continue true, if the continuation statement should be tolerated
css true, if CSS workarounds should be tolerated
debug true, if debugger statements should be allowed
devel true, if logging should be allowed (console, alert, etc.)
eqeq true, if == should be allowed
es5 true, if ES5 syntax should be allowed
@beherca
beherca / node nginx configuration
Created February 28, 2016 15:03 — forked from uhho/node nginx configuration
Sample nginx configuration for NodeJS + SocketIO app
# Load balancer configuration
upstream exampleApp {
# Directs to the process with least number of connections.
least_conn;
# One failed response will take a server out of circulation for 20 seconds.
server 127.0.0.1:10080 fail_timeout=20s;
#server 127.0.0.1:10081 fail_timeout=20s;
#server 127.0.0.1:10082 fail_timeout=20s;
#server 127.0.0.1:10083 fail_timeout=20s;
@beherca
beherca / config.json
Created February 22, 2016 20:05 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@beherca
beherca / latency.txt
Created February 14, 2016 16:41 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@beherca
beherca / gist:b268bed4cc3cd9cf45ba
Created January 23, 2016 15:12 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@beherca
beherca / nodejs.sh
Created January 8, 2016 04:11 — forked from Gioyik/nodejs.sh
Script to cross compile NodeJS for ARMv7
#!/bin/sh -e
#Define our target device
export TARGET_ARCH="-march=armv7-a"
export TARGET_TUNE="-mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -mthumb-interwork -mno-thumb"
#Define the cross compilators on your system
export AR="arm-linux-gnueabi-ar"
export CC="arm-linux-gnueabi-gcc"
export CXX="arm-linux-gnueabi-g++"
@beherca
beherca / Doctrine.php
Created November 30, 2015 19:08 — forked from jakzal/Doctrine.php
Use Doctrine and Symfony Kernel in phpunit tests
<?php
namespace Zalas\Test;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\Tools\SchemaTool;
trait Doctrine
{
{
"title": "collectd-post",
"services": {
"query": {
"list": {
"0": {
"query": "plugin: \"cpu\" AND plugin_instance: \"0\"",
"alias": "cpu1",
"color": "#7EB26D",
"id": 0,
@beherca
beherca / find_large_file_ubuntu.sh
Created November 11, 2015 11:28
Find Large File on Ubuntu
# Find Largest File, http://www.cyberciti.biz/faq/find-large-files-linux/
sudo du -a | sort -nr | head
sudo du -sx /* 2>/dev/null | sort -n
#Delete file older than 10 days
# find /usr/backup/jira -type f -mtime +10 -exec rm {} \;