Skip to content

Instantly share code, notes, and snippets.

View insanity54's full-sized avatar

Chris Grimmett insanity54

View GitHub Profile
@insanity54
insanity54 / docpad + jQuery-One-Page-Nav navigation
Created February 19, 2015 16:46
eco template for generating a jquery-one-page-nav compatible navigation
<ul id="nav">
<% for document, index in @getCollection('pages').toJSON(): %>
<li
id="n<%= index + 1 %>"
<% if index == 0: %>
class="current"
<% end %>
>
</li>
<% end %>
@insanity54
insanity54 / gist:809a5c7b0ffbb250d63c
Created February 27, 2015 20:54
mine bitcoin script
#!/bin/bash
bindir="$(dirname "$(readlink -fm "$0")")"
username=[USERNAME]
password=[PASSWORD]
cd $bindir
./cgminer -o stratum+tcp://mint.bitminter.com:3333 -u $username -p $password
@insanity54
insanity54 / bash dirname path
Last active October 22, 2015 23:41
Get the absolute path of the directory of the bash script
#!/bin/bash
# Gets the absolute path of the directory of this bash script. works in Linux & OSX
# greets to https://stackoverflow.com/questions/394230/detect-the-os-from-a-bash-script
# greets to https://stackoverflow.com/questions/3572030/bash-script-absolute-path-with-osx
function detectplatform {
platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
@insanity54
insanity54 / compilation
Created April 19, 2015 17:19
tracebox on OSX 10.9.5
apple-dapple:fart chrisgrimmett$ cd ~/scripts/
apple-dapple:scripts chrisgrimmett$ git clone https://github.com/tracebox/tracebox
Cloning into 'tracebox'...
remote: Counting objects: 1403, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 1403 (delta 0), reused 0 (delta 0), pack-reused 1400
Receiving objects: 100% (1403/1403), 279.13 KiB | 0 bytes/s, done.
Resolving deltas: 100% (860/860), done.
Checking connectivity... done.
apple-dapple:scripts chrisgrimmett$ cd tracebox/
// var syntax with initializers.
var u uint = 7 // Unsigned, but implementation dependent size as with int.
@insanity54
insanity54 / python2.7 main.py
Created April 29, 2015 16:02
Blame test 001
["127.0.0.1", 8000]
self id = 208
$ python2.7 main.py -D 8000 -remote None
None
self id = 86
joining
joined
--- A python written IRC Server project ---
-L- Starting server...
-E- Server aborted due to an error
-E- [CannotListenError]: Couldn't listen on 127.0.0.1:6667: [Errno 98] Address already in use.
Exception in thread Thread-2:
root@vultr:~/scripts/ChordRelayChat# python2.7 main.py -D 8000 -remote None
None
self id = 27
joining
joined
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/root/scripts/ChordRelayChat/chord/chord.py", line 61, in run
root@vultr:~/scripts/ChordRelayChat# python2.7 main.py -remote 73.207.38.249:8000
self id = 27
joining
poking ["73.207.38.249", 8000]
fingering
joined
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
@insanity54
insanity54 / gist:c99921bebde702557b8f
Created April 30, 2015 10:57
why do they do `p=new(int)`?
// Go is fully garbage collected. It has pointers but no pointer arithmetic.
// You can make a mistake with a nil pointer, but not by incrementing a pointer.
func learnMemory() (p, q *int) {
// Named return values p and q have type pointer to int.
p = new(int) // Built-in function new allocates memory.
// The allocated int is initialized to 0, p is no longer nil.
s := make([]int, 20) // Allocate 20 ints as a single block of memory.
s[3] = 7 // Assign one of them.
r := -2 // Declare another local variable.
return &s[3], &r // & takes the address of an object.