Skip to content

Instantly share code, notes, and snippets.

View nilsnh's full-sized avatar

Nils Norman Haukås nilsnh

View GitHub Profile
@nilsnh
nilsnh / WIP-deactivate-keyboard.sh
Created September 12, 2015 21:05
How to activate / deactivate the internal laptop keyboard when connecting an
#!/bin/bash
# How to disable the internal keyboard
http://askubuntu.com/questions/160945/is-there-a-way-to-disable-a-laptops-internal-keyboard
# How to fire script on usb connect
http://unix.stackexchange.com/questions/65891/how-to-execute-a-shellscript-when-i-plug-in-a-usb-device
# Todo
1. Is now able to grab the right numbers from xinput.
@nilsnh
nilsnh / npm-install-without-sudo
Last active August 29, 2015 14:13
How to remove the need of sudo when doing npm -g
Quick guide for installing node through NVM in a way that avoids the use of sudo.
1. [First read this](http://stackoverflow.com/a/24404451)
2. [Then add this fix.](https://github.com/creationix/nvm/issues/586#issuecomment-68220064)
Now doing npm install -g yo won't make this complaint:
[Error] npm root value is not in your NODE_PATH
@nilsnh
nilsnh / CompareFilesFindMissingLines.js
Last active August 29, 2015 14:04
Compare files and create a new file containing the missing lines. Used like: node File1 File2 FileWithLinesMissingInFile2.txt
var fs = require('fs');
var oldReport = [];
var newReport = [];
var missingLines = [];
fs.readFile(process.argv[2], {encoding: "utf8"}, function (err, data) {
if (err) throw err;
oldReport = data.split('\n');
readNewReportFile()
});
@nilsnh
nilsnh / gist:5097730
Last active December 14, 2015 13:59
Just a simple Harry Potter inspired coffee-script to wow and excite. :)
#A function
cast = (spell) ->
console.log "Casting spell: #{spell}"
#Comprehensions. "Syntactic sugar"
mySpellList = ['Expelliarmus', 'Lumos', 'Tarantallegra']
cast spell for spell in mySpellList
#Same as
for spell in mySpellList
@nilsnh
nilsnh / coffee-script-fizzbuzz.coffee
Last active December 13, 2015 20:58
Coffee-script fizzbuzz. Just had to try and make one after reading this: http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html
for i in [1..100]
if i % 3 is 0 and i % 5 is 0 then console.log "FizzBuzz"
else if i % 3 is 0 then console.log "Fizz"
else if i % 5 is 0 then console.log "Buzz"
else console.log "#{i}"
@nilsnh
nilsnh / pilsprog-roadmap-spring-2013.md
Created November 30, 2012 15:49
A roadmap for pils & programmering spring 2013

Concepts:

  • MyEmacsPP
  • Umbrella: Tv-show (will be marketed against NRK's kulturstripen)
  • FNL: Friday Night Lightning. The second Friday every month.
  • Hackathons

January

@nilsnh
nilsnh / Simple Jena Jython Example.py
Created October 17, 2011 14:06
Slightly modified Jena / Jython example
from com.hp.hpl.jena.rdf.model import ModelFactory, Resource
from com.hp.hpl.jena.vocabulary import VCARD
from javax.servlet.http import HttpServlet
#Inspired by: http://www.openvest.com/trac/wiki/JenaJython
class HelloSemanticWeb(HttpServlet):
def testSemantic(self):