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
#! /bin/bash | |
function usage() { | |
echo "usage: mkdo <file> [-c '<args>'] [-e '<args>'] [-o]" | |
exit 0 | |
} | |
if [ $# -eq 0 ]; then | |
usage | |
fi |
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
#include <stdio.h> | |
int main(void){ | |
int i; | |
int root; | |
double x; | |
printf("input a number > "); scanf("%d", &root); | |
x = root; |
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
# | |
# EventEmitter -- emit event for event-driven programming | |
# | |
# All classes which emit event will extend the EventEmitter class | |
# | |
class EventEmitter | |
# private _listeners | |
# | |
# All listeners is stored to _listeners. |
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
# strip indentation | |
class String | |
def dedent | |
margin = self.scan(/^ +/).map(&:size).min | |
self.gsub(/^ {#{margin}}/, '') | |
end | |
end | |
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 EventEmitter=function(){function EventEmitter(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;EventEmitter.defaultMaxListeners=10;EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");this._maxListeners=n;return this};EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(!this._events)this._events={};if(type==="error"){if(!this._events.error||isObject(this._events.error)&&!this._events.error.length){er=arguments[1];if(er instanceof Error){throw er}else{var err=new Error('Uncaught, unspecified "error" event. ('+er+")");err.context=er;throw err}}}handler=this._events[type];if(isUndefined(handler))return false;if(isFunction(handler)){switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.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
say (1, 2, *+* ... * > 1000); | |
# => (1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597) |
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
Stream.unfold({1, 2}, fn {n1, n2} -> {n1, {n2, n1+n2}} end) | |
|> Enum.take(15) | |
|> IO.inspect | |
# => [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987] |
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
# □1□2□3□4□5□6□7□8□9 = 100 | |
# □ = ' ' or '-' or '+' | |
import sys | |
for i in range(0, pow(3, 9)): | |
pattern = [0] * 9 | |
i, pattern[8] = divmod(i, 3) | |
i, pattern[7] = divmod(i, 3) |
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
// 標準入力から送られてくるデータのうち、3から9までの数字を抜き出してその都度別々のファイル記述子に出力する | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <stdlib.h> | |
#define _WITH_DPRINTF | |
#include <stdio.h> | |
#include <stdarg.h> |
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
let datasize = 65536 | |
var framework = "Darwin" | |
#if os(Linux) | |
framework = "Glibc" | |
#endif | |
let bf2swift:[Character:String] = [ | |
">": "sp += 1", | |
"<": "sp -= 1", |
OlderNewer