Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
Hacking

Hans Kristian Flaatten Starefossen

🚀
Hacking
View GitHub Profile
@Starefossen
Starefossen / object.extend.coffee
Created Dec 16, 2012
Makes it possible to extend object in the following way: myObject.extend otherObject
View object.extend.coffee
# 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 Mar 4, 2013
Command line Russian roulette
View roulette
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo *Click*
@Starefossen
Starefossen / disassembler.py
Created Mar 4, 2013
LENA Assembly code disassembler written in Python.
View disassembler.py
hex = [
'800000',
'8884b0',
'808806',
'808806',
'808806',
'808806',
'808806',
'808806',
'808806',
@Starefossen
Starefossen / progress.sh
Created Mar 4, 2013
Some example progress bar in shell
View progress.sh
echo -ne '##### (33%)\r'
sleep 1
echo -ne '############# (66%)\r'
sleep 1
echo -ne '####################### (100%)\r'
echo -ne '\n'
View string.ishex.coffee
String::isHex = -> pat = (/^0[xX][0-9a-fA-F]+$/i); return pat.test(@)
@Starefossen
Starefossen / gist:5084735
Created Mar 4, 2013
Strace logging JLinkExe
View gist:5084735
strace ./JLinkExe 2>strace.log
@Starefossen
Starefossen / gist:5084745
Created Mar 4, 2013
Listing connected USB devices on a mac (similar to lsusb on unix systems)
View gist:5084745
system_profiler SPUSBDataType
@Starefossen
Starefossen / gist:5084860
Created Mar 4, 2013
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
View gist:5084860
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 Mar 4, 2013
Shutdown and restart from command line
View reboot.sh
#!/bin/sh
sudo shutdown -r now