Skip to content

Instantly share code, notes, and snippets.

Nils nilsnh

Block or report user

Report or block nilsnh

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
@nilsnh
nilsnh / WIP-deactivate-keyboard.sh
Created Sep 12, 2015
How to activate / deactivate the internal laptop keyboard when connecting an
View WIP-deactivate-keyboard.sh
#!/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 Aug 29, 2015
How to remove the need of sudo when doing npm -g
View npm-install-without-sudo
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 Aug 29, 2015
Compare files and create a new file containing the missing lines. Used like: node File1 File2 FileWithLinesMissingInFile2.txt
View CompareFilesFindMissingLines.js
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 Dec 14, 2015
Just a simple Harry Potter inspired coffee-script to wow and excite. :)
View gist:5097730
#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 Dec 13, 2015
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
View coffee-script-fizzbuzz.coffee
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 Nov 30, 2012
A roadmap for pils & programmering spring 2013
View pilsprog-roadmap-spring-2013.md

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 Oct 17, 2011
Slightly modified Jena / Jython example
View Simple Jena Jython Example.py
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):
You can’t perform that action at this time.