This file contains 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
// The javascript compare objects function | |
function compareObjects(o1, o2, ignoreFields){ | |
ignoreFields = ignoreFields || []; | |
//console.log('Ignore: ' + JSON.stringify(ignoreFields)); | |
for(var p in o1) { | |
if (ignoreFields.indexOf(p) < 0) { | |
if(o1[p] !== o2[p]){ | |
return false; | |
} | |
} |
This file contains 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
// Filter File | |
// a simple script for extracting parts in a textfile between two lines. | |
// by Calle Robertsson, [email protected], 2013. | |
var fs = require('fs'); | |
var filename = process.argv[2]; | |
if (!filename) { | |
throw new Error('Missing command line argument for file name.'); |
This file contains 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
<!DOCTYPE html> | |
<!-- by [email protected] --> | |
<html> | |
<head> | |
<title>TITLE</title> | |
<style> | |
@import url("reset.css"); | |
@import url("style.css"); | |
</style> | |
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> |
This file contains 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
-- cans.hs | |
-- Calculate number of cans in one pyramid | |
cansInPyramid :: Int -> Int | |
cansInPyramid 1 = 1 | |
cansInPyramid n = n + cansInPyramid (n - 1) | |
-- Smaller solution | |
cansInPyramid' n = sum [1..n] |
This file contains 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
-- Lucas Carmichael Numbers | |
-- | |
-- inspired by the Youtube channel Numberphile | |
-- episode https://www.youtube.com/watch?v=yfr3BIk6KFc | |
-- "Something special about 399 (and 2015)" | |
-- | |
-- by [email protected], jan 2015 | |
import Data.Numbers.Primes |
This file contains 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
type Peg = String | |
type Move = (Peg, Peg) | |
hanoi :: Integer -> Peg -> Peg -> Peg -> [Move] | |
hanoi 0 _ _ _ = [] | |
hanoi n a b c = hanoi (n - 1) a c b ++ [(a, c)] ++ hanoi (n - 1) b a c | |
main = do | |
print $ hanoi 1 "a" "b" "c" | |
print $ hanoi 2 "a" "b" "c" |
This file contains 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
if (isNaN("")) { | |
console.log('Empty string is not a number'); | |
} | |
else { | |
console.log('Empty string IS a number!!!'); | |
} | |
// => Empty string IS a number!!! |
This file contains 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
// Javascript Pad String | |
// Inspired by http://dev.enekoalonso.com/2010/07/20/little-tricks-string-padding-in-javascript/ | |
function pad(filling, value) { | |
if (('' + value).length > filling.length) { | |
return value; | |
} | |
return (filling + value).slice(-1 * filling.length); | |
} |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Newtonsoft.Json; | |
namespace DownCaster | |
{ | |
static class Program | |
{ | |
static void Main() |
This file contains 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 Main where | |
import Text.Printf | |
main = do | |
input <- getContents | |
printf "%8d%8d%8d\n" | |
(length (lines input)) | |
(length (words input)) | |
(length input) |
OlderNewer