Skip to content

Instantly share code, notes, and snippets.

View Starefossen's full-sized avatar
🚀
Building platforms for the Norwegain Government

Hans Kristian Flaatten Starefossen

🚀
Building platforms for the Norwegain Government
View GitHub Profile
@Starefossen
Starefossen / object.extend.coffee
Created December 16, 2012 16:06
Makes it possible to extend object in the following way: myObject.extend otherObject
# Extend Object Prototype
Object::extend = (obj) ->
org = this
Object.keys(obj).forEach (key) ->
prop = Object.getOwnPropertyDescriptor obj, key
Object.defineProperty org, key, prop
this
@Starefossen
Starefossen / roulette
Created March 4, 2013 05:57
Command line Russian roulette
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo *Click*
@Starefossen
Starefossen / disassembler.py
Created March 4, 2013 07:21
LENA Assembly code disassembler written in Python.
hex = [
'800000',
'8884b0',
'808806',
'808806',
'808806',
'808806',
'808806',
'808806',
'808806',
@Starefossen
Starefossen / progress.sh
Created March 4, 2013 07:23
Some example progress bar in shell
echo -ne '##### (33%)\r'
sleep 1
echo -ne '############# (66%)\r'
sleep 1
echo -ne '####################### (100%)\r'
echo -ne '\n'
@Starefossen
Starefossen / string.ishex.coffee
Last active December 14, 2015 11:49
String::isHex()
String::isHex = -> pat = (/^0[xX][0-9a-fA-F]+$/i); return pat.test(@)
@Starefossen
Starefossen / gist:5084735
Created March 4, 2013 19:25
Strace logging JLinkExe
strace ./JLinkExe 2>strace.log
@Starefossen
Starefossen / gist:5084745
Created March 4, 2013 19:27
Listing connected USB devices on a mac (similar to lsusb on unix systems)
system_profiler SPUSBDataType
@Starefossen
Starefossen / gist:5084860
Created March 4, 2013 19:39
The 'RUN' directive is necessary to set /dev/bus/usb/PORT/ADDRESS permissions along with /dev/usb_endpointPORT.ADDRESS_epNN The script is as follows http://www.segger2.com/index.php?page=Thread&threadID=103
BUS!="usb", ACTION!="add", SUBSYSTEM!=="usb_endpoint", GOTO="kcontrol_rules_end"
SUBSYSTEM=="usb_endpoint", ATTRS{idProduct}=="0101", ATTRS{idVendor}=="1366", MODE="0666", GROUP="usbusergroup", RUN+="/usr/local/bin/chk_jlink"
LABEL="kcontrol_rules_end"
@Starefossen
Starefossen / reboot.sh
Created March 4, 2013 19:45
Shutdown and restart from command line
#!/bin/sh
sudo shutdown -r now
gqap # format current paragraph