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
const std = @import("std"); | |
const net = std.net; | |
const Allocator = std.mem.Allocator; | |
pub const io_mode = .evented; | |
var client_id_counter: u32 = 0; | |
var should_server_close: bool = false; | |
pub fn main() !void { |
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
# nim c -d:FLAGS duktape.nim | |
# | |
# FLAGS | |
# -d:duktapeStd | -d:duktapeDL | -d:duktapeConan | |
# -d:duktapeSetVer=2.5.0 | |
# -d:duktapeStatic | |
import nimterop/[build, cimport] | |
static: |
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
enum BarcodeScanner.Error { | |
Unkown | |
} | |
module BarcodeScanner { | |
fun scan : Promise(BarcodeScanner.Error, String) { | |
` | |
new Promise((resolve, reject) => { | |
cordova.plugins.barcodeScanner.scan((result) => { | |
resolve(result.text) |
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
# src/{{app_name}}.cr | |
require "kemal" | |
require "./controllers/*" | |
alias Env = HTTP::Server::Context # this could be provided by Kemal | |
module Main | |
get "/", &->index(Env) | |
get "/:name", &->greet(Env) | |
end |
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
function findTByKeyValue (element, target){ | |
var found = true; | |
for(var key in target) { | |
if (!element.hasOwnProperty(key) || element[key] !== target[key]) { | |
found = false; | |
break; | |
} | |
} | |
if(found) { |
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
require "big_int" | |
def fact(n) | |
return 1 if n == 0 | |
n * fact(n - 1) | |
end | |
n = BigInt.new(ARGV[0]) | |
puts fact(n) |
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
/** | |
* Lodash mixins for combinatorics | |
* by: wassname & visangela | |
* url: https://gist.github.com/wassname/a882ac3981c8e18d2556/edit | |
* lodash contrib issue: https://github.com/node4good/lodash-contrib/issues/47 | |
* lic: same as lodash | |
* Inspired by python itertools: https://docs.python.org/2.7/library/itertools.html | |
* | |
* Usage: | |
* permutations([0,1,2],2) // [[0,1],[0,2],[1,0],[1,2],[2,0],[2,1]] |