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
package main | |
import ( | |
"fmt" | |
"sort" | |
) | |
// Item has a priority and an order | |
type Item struct { | |
Prio int |
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 | |
main = do | |
print $ map fibN' [1..10] | |
print $ fibN' 1001 | |
print $ length $ show $ fibN' 500000 | |
fibN' 1 = 0 | |
fibN' 2 = 1 | |
fibN' n = iter 0 1 n where |
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
package main | |
import ( | |
"fmt" | |
"math/big" | |
) | |
func main() { | |
for i := 1; i <= 10; i++ { |
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
package main | |
import ( | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"net/url" | |
"os" | |
"strconv" |
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"math/rand" | |
"os" | |
"strconv" | |
"time" | |
) |
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
// jsonformat.js | |
// a simple script that format JSON data in a more readable way. | |
// by Calle Robertsson, [email protected], 2015. | |
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
module Main where | |
import Text.Printf | |
main = do | |
input <- getContents | |
printf "%8d%8d%8d\n" | |
(length (lines input)) | |
(length (words input)) | |
(length input) |
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
// 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
if (isNaN("")) { | |
console.log('Empty string is not a number'); | |
} | |
else { | |
console.log('Empty string IS a number!!!'); | |
} | |
// => Empty string IS a number!!! |
NewerOlder