This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoObjectId = function () { | |
var timestamp = (new Date().getTime() / 1000 | 0).toString(16); | |
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() { | |
return (Math.random() * 16 | 0).toString(16); | |
}).toLowerCase(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### BEGIN INIT INFO | |
# Provides: vmwareautostart | |
# Required-Start: $vmware $network $syslog | |
# Required-Stop: $vmware $network $syslog | |
# X-Start-Before: | |
# X-Stop-After: | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module rounded_square( width, radius_corner ) { | |
translate( [ radius_corner, radius_corner, 0 ] ) | |
minkowski() { | |
square( width - 2 * radius_corner ); | |
circle( radius_corner ); | |
} | |
} | |
module alternative_square( width, r_c ) { | |
hull() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tcpdump -A -nn -s 0 'tcp dst port 9200 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -i lo | |
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode | |
listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes | |
14:32:33.525122 IP 127.0.0.1.49777 > 127.0.0.1.9200: Flags [P.], seq 313752908:313753888, ack 2465010394, win 257, options [nop,nop,TS val 2684167067 ecr 2684167066], length 980 | |
E...^.@[email protected]#...}L............... | |
..#...#.GET /index/_search HTTP/1.1 | |
Host: 127.0.0.1:9200 | |
Accept: */* | |
Content-Length: 845 | |
Content-Type: application/x-www-form-urlencoded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# based on script from http://www.axllent.org/docs/view/ssh-geoip | |
# License: WTFPL | |
# UPPERCASE space-separated country codes to ACCEPT | |
ALLOW_COUNTRIES="DE EU GB" | |
LOGDENY_FACILITY="authpriv.notice" | |
if [ $# -ne 1 ]; then | |
echo "Usage: `basename $0` <ip>" 1>&2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Originally by stanislavs from post http://stanislavs.org/reporting-correct-space-usage-for-samba-shared-zfs-volumes/#comment-2443 | |
#Used some updated code from github user umito / Peter on that site to clean up the non zfs code. | |
if [[ `findmnt -n -o FSTYPE -T "$PWD" | grep -c zfs` > 0 ]] | |
then | |
# echo "DEBUG: this is zfs" | |
USED=$((`zfs get -o value -Hp used $PWD` / 1024)) > /dev/null | |
AVAIL=$((`zfs get -o value -Hp available $PWD` / 1024)) > /dev/null | |
TOTAL=$(($USED+$AVAIL)) > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// More information: https://danielupshaw.com/openscad-rounded-corners/ | |
// Set to 0.01 for higher definition curves (renders slower) | |
$fs = 0.15; | |
module roundedcube(size = [1, 1, 1], center = false, radius = 0.5, apply_to = "all") { | |
// If single value, convert to [x, y, z] vector | |
size = (size[0] == undef) ? [size, size, size] : size; | |
translate_min = radius; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib | |
import socket | |
import StringIO | |
# generic | |
SSDP_ALL = 'ssdp:all' | |
UPNP_ROOT = 'upnp:rootdevice' | |
# devices | |
DIAL = 'urn:dial-multiscreen-org:service:dial:1' |
OlderNewer