This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Karma configuration | |
// Generated on Fri Feb 07 2014 14:46:59 GMT+0100 (Romansk (normaltid)) | |
module.exports = function(config) { | |
config.set({ | |
// base path, that will be used to resolve files and exclude | |
basePath: '', | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DummyAuthModule : IHttpModule | |
{ | |
public void Init(HttpApplication context) | |
{ | |
context.AuthenticateRequest += ContextOnAuthenticateRequest; | |
} | |
private void ContextOnAuthenticateRequest(object sender, EventArgs eventArgs) | |
{ | |
var identity = new GenericIdentity("test user"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var questions = { | |
'Introduksjon-1': | |
{ | |
id: 'Introduksjon-1', | |
question: 'Er du mann eller kvinne?', | |
instructions: '', | |
questionType: 'Alternativknapper', | |
datatype: 'Int', | |
alternatives: ["Mann", "Kvinne"], | |
nextQuestions: ["Introduksjon-2", "Introduksjon-2"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
words = Hash.new([]) | |
File.open("words.txt", "r") do |file| | |
while line = file.gets | |
word = line.chomp.downcase | |
words[word.split('').sort!.join('')] += [word] | |
end | |
end | |
File.open("names.txt", "r") do |file| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "FSharp.Data.TypeProviders" | |
#r "System.Data.Services.Client" | |
open System | |
open Microsoft.FSharp.Linq | |
open Microsoft.FSharp.Data.TypeProviders | |
type RegObs = ODataService<"http://api.nve.no/hydrology/regobs/v0.8.7/Odata.svc"> | |
let data = RegObs.GetDataContext() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on open of target_files | |
set theMovie to target_files | |
tell application "QuickTime Player" | |
activate | |
open theMovie | |
set the looping of document 1 to true | |
play document 1 | |
end tell | |
end open |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WebServer | |
{ | |
public void Start() | |
{ | |
var listener = new System.Net.HttpListener(); | |
listener.Prefixes.Add(BaseUrl); | |
listener.Start(); | |
new Thread(HttpThread).Start(listener); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Answers | |
open System | |
open System.Text | |
let (|Regex|_|) regex str = | |
let m = RegularExpressions.Regex(regex).Match(str) | |
if m.Success | |
then Some (List.tail [ for x in m.Groups -> x.Value ]) | |
else None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("") | |
base = alphabet.length | |
exports.encode = (i) -> | |
return alphabet[0] if i is 0 | |
s = "" | |
while i > 0 | |
s += alphabet[i % base] | |
i = parseInt(i / base, 10) |