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
val s1 = {"hello"} // s1: String = hello | |
val s = "hello" // s: String = hello |
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
<?php | |
class Node { | |
public $key; | |
public $next; | |
public function __construct($key, $next=null) { | |
$this->key = $key; | |
$this->next = $next; | |
} | |
} |
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
package main | |
import ( | |
"flag" | |
"log" | |
"net/http" | |
"net/url" | |
) | |
var ( |
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 akka.actor.Actor | |
object Greeter { | |
case object Greet | |
} | |
class Greeter extends Actor { | |
def receive = { | |
case Greeter.Greet => { | |
println("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
#!/usr/bin/env python | |
from subprocess import call | |
import os | |
servers = [ | |
{ | |
'host': 'some.remote.host', # host to connect to | |
'dir' : '/usr/local/supersecret/' # remote dir to mount | |
}, | |
{ |
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
// Initialize API key, session, and token... | |
// Think of a session as a room, and a token as the key to get in to the room | |
// Sessions and tokens are generated on your server and passed down to the client | |
var apiKey = "1127"; | |
var sessionId = "1_MX4xMTI3fn5TYXQgTWF5IDA0IDA3OjIwOjAzIFBEVCAyMDEzfjAuNDQwODI4MTR-"; | |
var token = "T1==cGFydG5lcl9pZD0xMTI3JnNpZz1jZjRhYzc3OWI5MGNkMzBkMGUyOGZmN2UxMTRjZDlmNDAxY2FiN2VlOnNlc3Npb25faWQ9MV9NWDR4TVRJM2ZuNVRZWFFnVFdGNUlEQTBJREEzT2pJd09qQXpJRkJFVkNBeU1ERXpmakF1TkRRd09ESTRNVFItJmNyZWF0ZV90aW1lPTEzNjc2NzcyMDMmbm9uY2U9MTk1MDcyJnJvbGU9cHVibGlzaGVy"; | |
// Enable console logs for debugging | |
TB.setLogLevel(TB.DEBUG); |
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
fn main() -> () { | |
let a : ~[int] = vec::with_capacity(20); | |
a[0] = 1; // rust: task failed at 'index out of bounds: the len is 0 but the index is 0' | |
} |
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
/* | |
* Question: should this be the correct way to initialize a new vector | |
* with a set capacity? Seems al little verbose. | |
*/ | |
fn main() -> () { | |
let mut a : ~[int] = ~[]; | |
vec::reserve(&mut a, 20); | |
} |
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 str = "hello world"; | |
// Split on the empty character (between every | |
// letter). | |
var str_split = str.split(''); // => ['h', 'e', 'l', 'l', ' ', 'w', 'o', 'r', 'l', 'd'] | |
// reverse the resulting array | |
var str_reverse = str_split.reverse(); // => ['d', 'l', 'r', 'o', 'w', ' ', 'l', 'l', 'e', 'h'] | |
// join each string in the array, delimited by |
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
struct Bob { | |
priv name : ~str, | |
priv age : int | |
} | |
impl Bob { | |
fn new(name: ~str, age: int) -> Bob { | |
Bob { name: name, age: age } | |
} |