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
find . -print0 | while read -d $'\0' file | |
do | |
# Statements with $file | |
done |
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
import AVFoundation | |
var engine = AVAudioEngine() | |
var player = AVAudioPlayerNode() | |
var mixer = engine.mainMixerNode | |
// | |
//func sineWave(buffer: AVAudioPCMBuffer) -> AVAudioPCMBuffer { | |
// let sr = Float(mixer.outputFormatForBus(0).sampleRate) | |
// let n_channels = mixer.outputFormatForBus(0).channelCount |
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
import Cocoa | |
import AVFoundation | |
// Setup engine and node instances | |
var engine = AVAudioEngine() | |
var delay = AVAudioUnitDelay() | |
var reverb = AVAudioUnitReverb() | |
var mixer = engine.mainMixerNode | |
var input = engine.inputNode | |
var output = engine.outputNode |
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 Expr(operation, left, right) { | |
return {op: operation, l: left, r: right}; | |
} | |
var Add = Expr.bind(null, 'add'), | |
Mult = Expr.bind(null, 'mult'); | |
function Var(name) { | |
return {name: name}; | |
} |
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
import os | |
import opengl | |
import glfw/wrapper as glfw | |
var | |
win: GLFWwindow | |
vaoID: GLuint | |
vboID: GLuint | |
cboID: GLuint | |
vertexShaderID: GLuint |
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
proc makeJumpPlayerCommand(player: var Player, | |
platform: Platform): Command = | |
var | |
moveActorCommand = makeMoveActorCommand(player, platform.x, | |
platform.y) | |
if not isStrongEnough(player.jumpStrength, platform.altitude): | |
echo("$1 is not strong enough to jump to the platform" % [player.name]) | |
return nil # <== Error: type mismatch: got (nil) but expected 'Command' |
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
import os | |
import times | |
const | |
speed = 1000 | |
iterator deltat(): int {.closure.} = | |
var | |
t0: float = epochTime() | |
t1: float |
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 nim-procbyfirst { | |
TYPE_FIRST_ARG=$1 | |
FILE=$2 | |
cat "${FILE}" | | |
grep -P "^\s*proc\s*(?:\`.+\`|\w+)\*(\[.+\])?\(\w+:\s${TYPE_FIRST_ARG=}" | | |
grep -oh -P '(?<=proc\s)(?:\`.+\`|\w+).+' | |
} | |
# Exemple (system.nim is a local file): | |
# $ nim-procbyfirst string system.nim |
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
FILE=life.nim | |
BINARY=life | |
function compile { | |
nim c -d:release --passC:-ffast-math --opt:size $FILE | |
} | |
function crunch { | |
strip --strip-all \ | |
-R .note \ |
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
import os | |
from strutils import `%` | |
import libncurses | |
const | |
sleepTime = 100 | |
charAlive = "0" | |
charDead = "_" | |
nbRow = 30 | |
nbCol = 120 |