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
const http = require('http'); | |
const url = require('url'); | |
const hostname = '127.0.0.1'; | |
const port = 3000; | |
const server = http.createServer((req, res) => { | |
res.statusCode = 200; | |
res.setHeader('Content-Type', 'text/html'); | |
try { |
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 "allocator/arena"; | |
// TODO: Why cannot import from index? | |
// import { BSONEncoder, BSONDecoder } from "../../../assemblyscript-bson/assembly"; | |
import { BSONEncoder } from "../../../assemblyscript-bson/assembly/encoder"; | |
import { BSONDecoder } from "../../../assemblyscript-bson/assembly/decoder"; | |
declare function sayHello(): void; | |
export class FooBar { | |
foo: i32 = 0; |
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
book_train_and_hotel() : void { // Needs 6 MANA. | |
// 3 for train and callback and 3 for hotel and callback. | |
// E.g. book_train and book_hotel doesn't need additional mana, so only 1 MANA for a call. | |
// Callback may need 1 additional to cancel train or hotel booking if one of them failed. | |
assert_has_mana(6); | |
let hotelBooking = bookHotel.withMana(3).withCoins(1000).book(sender()); | |
let trainBooking = bookTrain.withMana(3).withCoins(1000).book(sender()); | |
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
data Rope = Empty | Concat Int Rope Rope | Leaf String deriving (Show, Eq) | |
rope :: String -> Rope | |
rope "" = Empty | |
rope s = Leaf s | |
len :: Rope -> Int | |
len Empty = 0 | |
len (Leaf s) = length s | |
len (Concat length _ _) = length |
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
/** | |
* CSV Parser. Takes a string as input and returns | |
* an array of arrays (for each row). | |
* | |
* @param input String, CSV input | |
* @param separator String, single character used to separate fields. | |
* Defaults to "," | |
* @param quote String, single character used to quote non-simple fields. | |
* Defaults to "\"". | |
*/ |
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 string | |
class Solution: | |
# @param start, a string | |
# @param end, a string | |
# @param dict, a set of string | |
# @return an integer | |
def ladderLength(self, start, end, dict): | |
dict += [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
// Playground - noun: a place where people can play | |
import UIKit | |
let b = [1, 2, 3][1..2].filter { $0 < 3 } | |
let c = b + [5, 6] | |
func quicksort<T : Comparable>(arr : Array<T>) -> Array<T> { | |
if arr.count <= 1 { | |
return arr |
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
class Edge | |
attr_accessor :src, :dest, :length | |
def initialize(src, dest, length = 1) | |
@src = src | |
@dest = dest | |
@length = length | |
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
// | |
// CXBinder.h | |
// TheList | |
// | |
// Created by Vladimir Grichina on 28.01.13. | |
// Copyright (c) 2013 TheList, LLC. All rights reserved. | |
// | |
#import <THObserversAndBinders/THBinder.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
// | |
// NSObject+KVOWeakPropertyDebug.h | |
// KVOWeakPropertyDebug | |
// | |
// Created by Vladimir Grichina on 12.01.13. | |
// Copyright (c) 2013 Vladimir Grichina. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |