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" | |
func main() { | |
res := summedsquare(getInts(), 0) | |
if !(res <= 0) { | |
fmt.Println(res) | |
} | |
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
function makecola(name, calories, color, sold) { | |
name = name || "Water"; | |
calories = calories || 0; | |
color = color || "clear"; | |
sold = sold || 0; | |
return { | |
name: name, | |
calories: calories, | |
color: color, | |
sold: sold |
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 call in console: | |
* $ node digitcombinatorial.js [maxnumber] [digitpattern] | |
* | |
* If maxnumber and digitpattern is not supplied in command line, it will | |
* fallback to the default 10000 and 14 respectively | |
*/ | |
// Initial parameter definition. Since it is parameter, it's expected won't | |
// be changed during runtime. |
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
var mycommander = require('./mycommander'); | |
console.log(mycommander); | |
console.log(process.argv.slice(2)); | |
mycommander | |
.option('-f, --foo i', 'Integer value for foo', parseInt, 0) | |
.option('-b, --bar j', 'Integer value for bar', parseInt, 0) | |
.option('-z, --baz', 'Boolean argument baz') | |
.parse(process.argv.slice(2)); |
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
input { | |
width: 100%; | |
display: block; | |
} |
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 implementation of Sleeping Barber Problem | |
## https://en.wikipedia.org/wiki/Sleeping_barber_problem | |
## The `seatAvailable` is guarded with `queue` Lock while the barber | |
## explicitly acquired and released | |
## Using pointer math as written in this post | |
## https://forum.nim-lang.org/t/1188#7366 | |
## compile and run: $ nim c -r --threads:on --threadAnalysis:off barbershop.nim | |
from os import sleep | |
from random import random, randomize |
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
// run it with | |
// > wscript rename.js | |
// in the folder where the script resides | |
// | |
// or double-click it | |
var script = WScript.CreateObject("WScript.Shell"); | |
var fso = WScript.CreateObject("Scripting.FileSystemObject"); | |
for (var i = 28; i < 100; i++) { | |
var file = fso.GetFile('pg' + i + '.png'); |
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
# Configuration file for the Nim Compiler. | |
# (c) 2017 Andreas Rumpf | |
# Feel free to edit the default values as you need. | |
# You may set environment variables with | |
# @putenv "key" "val" | |
# Environment variables can be accessed like so: | |
# gcc.path %= "$CC_PATH" |
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
import macros | |
macro match(head, body: untyped): untyped = | |
result = newNimNode nnkStmtList | |
var casenode = newNimNode nnkCaseStmt | |
casenode.add head | |
for node in body: | |
node.expectKind nnkInfix |
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
import winim | |
proc quit(value: DWORD) = | |
quit value.int | |
proc refreshDirectory(handle: var HANDLE) = | |
handle = FindFirstChangeNotification(".", false, | |
FILE_NOTIFY_CHANGE_FILE_NAME) | |
if handle == INVALID_HANDLE_VALUE: | |
quit GetLastError() |
OlderNewer