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
puts "Hello, World!" |
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
class Book | |
attr_accessor :title, :page_num | |
def initialize( title, page_num ) | |
@title = title | |
@page_num = page_num | |
end | |
def title | |
puts @title |
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
def Object.const_missing(name) | |
replaced_string = name.to_s.gsub(/([A-Z]+)/, '/\1').downcase | |
require File.expand_path(File.dirname(__FILE__) + replaced_string + '.rb') | |
raise "Const missing." unless const_defined? name | |
const_get(name.to_s) | |
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
import Data.Char | |
main = do | |
contents <- getContents | |
putStr "test" | |
putStr $ map toUpper contents |
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
safeHead :: [a] -> Maybe a | |
safeHead [] = Nothing | |
safeHead (x:_) = Just x | |
safeTail :: [a] -> Maybe [a] | |
safeTail [] = Nothing | |
safeTail (_:xs) = Just xs |
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 std.array; | |
bool binarySearch(T)(T[] input, T value) { | |
if(input.empty) { | |
return false; | |
} | |
auto i = input.length / 2; | |
auto mid = input[i]; | |
if(mid > value) return binarySearch(input[0 .. i], value); | |
if(mid < value) return binarySearch(input[i .. $], value); |
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 std.stdio; | |
void main() { | |
int delegate()[int] dict; | |
foreach(it; 0 .. 10) { | |
dict[it] = ((i) => (() => i))(it); | |
} | |
foreach(key, func; dict) { | |
writeln(key, " => ", dict[key]()); |
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 std.stdio; | |
struct Structure { | |
public: | |
int public_integer = 10; | |
private: | |
int private_integer = 20; | |
} | |
void main() { |
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 std.stdio; | |
import std.conv; | |
class TestCase(string methodName) { | |
void run() { | |
__traits(getMember, this, methodName); | |
} | |
} | |
class WasRun(string methodName) : TestCase!(methodName) { |
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
var SERVER_PORT = 80; | |
var LIFE_TIME = 30000; | |
var REDIS_HOST = "xxx.xxx.xxx"; | |
var REDIS_PORT = 6379; | |
var http = require('http'); | |
var io = require('socket.io'); | |
var server = http.createServer(); | |
var manager = null; |
OlderNewer