package main
import("fmt"; "math")
func Sqrt(x float64) (z float64) {
z, delta := 1.0, 1.0
for delta > 1e-4 {
z0 := z
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
use std; | |
import io::reader_util; | |
enum node { | |
tag_node({ | |
name: str, | |
attributes: [attribute], | |
children: [node] | |
}), |
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
▶ TIMEOUT [expected OK] /websockets/Create-Secure-extensions-empty.htm | |
▶ Unexpected subtest result in /websockets/Create-Secure-extensions-empty.htm: | |
└ NOTRUN [expected PASS] W3C WebSocket API - Create Secure WebSocket - wsocket.extensions should be set to '' after connection is established - Connection should be closed | |
▶ Unexpected subtest result in /websockets/Create-Secure-extensions-empty.htm: | |
│ FAIL [expected PASS] W3C WebSocket API - Create Secure WebSocket - wsocket.extensions should be set to '' after connection is established - Connection should be opened | |
│ → assert_equals: extensions should be empty expected (string) "" but got (undefined) undefined | |
│ | |
│ @http://web-platform.test:8000/websockets/Create-Secure-extensions-empty.htm:9:13 |
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
// Modular exponentiation by squaring | |
fn mod_exp(base: &BigUint, exponent: &BigUint, modulus: &BigUint) -> BigUint { | |
let (zero, one): (BigUint, BigUint) = (Zero::zero(), One::one()); | |
let mut result = one.clone(); | |
let mut baseAcc = base.clone(); | |
let mut exponentAcc = exponent.clone(); | |
while exponentAcc > zero { | |
// Accumulate current base if current exponent bit is 1 | |
if (exponent & one) == one { |
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; A nice, small 32-bit x86 execve shellcode template. ; | |
; execve("//bin/sh", [ "//bin/sh", NULL ], [ NULL ]). ; | |
; Shellcode itself is 25 bytes. ; | |
; Provide definitions of PayloadSize and JumpAddress ; | |
; to generate a self-contained buffer of the desired ; | |
; size and with the desired address to jump to. ; | |
; Build with "nasm -f bin -o shellcode shellcode.asm" ; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
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
// Compile with `g++ -framework GLUT glut_hello_world.cpp` | |
#include <GLUT/glut.h> | |
void display(void) { } | |
int main(int argc, char** argv) { | |
glutInit(&argc, argv); | |
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); |
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
fn flip<T>(f: ~fn(a: T, b: T)) -> ~fn(a: T, b: T) { | |
|a, b| { f(b, a) } | |
} | |
fn hello_world(hello: &str, world: &str) { | |
println!("{:s}, {:s}!", hello, world) | |
} | |
#[test] | |
fn test_flip() { |
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
use std::rt::io::{Reader, Writer}; | |
use std::rt::io::net::ip::{Ipv4Addr,SocketAddr}; | |
use std::rt::io::net::tcp::TcpStream; | |
use std::str; | |
trait ToUintSafe { | |
fn to_uint_safe(&self) -> Option<uint>; | |
} | |
impl ToUintSafe for int { |
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
# Extended Euclidean GCD algorithm | |
# Outputs k, u, and v such that ua + vb = k where k is the gcd of a and b | |
def egcd(a, b) | |
u_a, v_a, u_b, v_b = [ 1, 0, 0, 1 ] | |
while a != 0 | |
q = b / a | |
a, b = [ b - q*a, a ] | |
u_a, v_a, u_b, v_b = [ u_b - q*u_a, v_b - q*v_a, u_a, v_a ] | |
# Each time, `u_a*a' + v_a*b' = a` and `u_b*a' + v_b*b' = b` | |
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
from os import pipe, write, close | |
from subprocess import Popen, PIPE | |
import select | |
import string | |
import sys | |
PIPE_MAX = 1<<16 # 64k | |
WELCOME_LEN = len("Welcome to the password checker!\n") | |
def args(guess): |