Skip to content

Instantly share code, notes, and snippets.

Torgeir Thoresen torgeir

Block or report user

Report or block torgeir

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@torgeir
torgeir / gist:8718436
Created Jan 30, 2014
Lock your screen
View gist:8718436
brew install sl
echo "alias ls='sl'" >> .profile
. .profile
@torgeir
torgeir / requirejs.html
Created Jan 31, 2014
Requirejs plugin to load different resources based on some condition.
View requirejs.html
<!doctype html>
<meta charset=utf-8>
<title>requiretest</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script>
define("A", [], function () {
function A () { console.log('A') }
return A;
});
@torgeir
torgeir / jackson-json-expose-field-ignore-setter.java
Created Feb 14, 2014
Jackson json, expose field but ignore setter.
View jackson-json-expose-field-ignore-setter.java
@JsonIgnore
private field;
@JsonPropety
public String getField() {}
/* no setter */
@torgeir
torgeir / valid_git_urls_for_npm.txt
Last active Aug 29, 2015
Valid git urls for npm.
View valid_git_urls_for_npm.txt
git://github.com/user/project.git#commit-ish
git+ssh://user@hostname:project.git#commit-ish
git+ssh://user@hostname/project.git#commit-ish
git+http://user@hostname/project/blah.git#commit-ish
git+https://user@hostname/project/blah.git#commit-ish
@torgeir
torgeir / upgrade_rasplex.sh
Last active Aug 29, 2015
Upgrading an experimental RasPlex build.
View upgrade_rasplex.sh
# grab the latest build
wget http://downloads.sourceforge.net/project/rasplex/experimental/rasplex-RPi.arm-9.9.20.tar
tar -xvf rasplex-RPi.arm-9.9.20.tar
# move into the target directory
cd rasplex-RPi.arm-9.9.20/target
# create the .update/ folder if you dont already have it
ssh pi mkdir .update
@torgeir
torgeir / cross-browser-media-width-media-height.js
Created Mar 4, 2014
JavaScript cross-browser @media (width) and @media (height) values
View cross-browser-media-width-media-height.js
// http://stackoverflow.com/questions/1248081/get-the-browser-viewport-dimensions-with-javascript
var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
@torgeir
torgeir / floating-point-arithmetics-iee754.js
Created Mar 13, 2014
Floating point arithmetics, IEE754
View floating-point-arithmetics-iee754.js
// http://stackoverflow.com/questions/588004/is-floating-point-math-broken
// https://en.wikipedia.org/wiki/IEEE_754#Basic_formats
// Don't use ==
0.1 + 0.2 == 0.3 // false
0.1 + 0.2 // 0.30000000000000004
var x = 0.2;
var y = 0.3;
var equal = (Math.abs(x - y) < 0.000001)
@torgeir
torgeir / make-summary.md
Last active Aug 29, 2015
Make summary.
View make-summary.md

Make summary

Expose env variables.

export PATH := node_modules/.bin:$(PATH)

Keep file lists.

template_source := templates/*.handlebars
template_js := build/templates.js
@torgeir
torgeir / a-heartbleed-locally-using-vagrant-nodejs-and-a-vulnerable-openssl.md
Last active Aug 29, 2015
Test heartbleed locally using vagrant, node.js and a vulnerable openssl.
View a-heartbleed-locally-using-vagrant-nodejs-and-a-vulnerable-openssl.md
  1. Setup vagrant

    vagrant init hashicorp/precise32

  2. Make the vagrant config change (on your local computer, see Vagrantfile)

    vagrant up

    vagrant ssh

@torgeir
torgeir / coercing.js
Last active Aug 29, 2015
js coercion on property access and method calls on primitive values
View coercing.js
var s;
s = "wtf";
s.split = function () {};
s.split("t"); // split() works
s = String("wtf");
s.split = function () {};
s.split("t"); // split() works
You can’t perform that action at this time.