Skip to content

Instantly share code, notes, and snippets.

View TethysSvensson's full-sized avatar

Tethys Svensson TethysSvensson

  • Copenhagen, Denmark
View GitHub Profile
#![feature(macro_registrar, managed_boxes, quote)]
#![crate_type = "dylib"]
extern crate syntax;
use syntax::codemap;
use syntax::ast;
use syntax::ext::base;
use syntax::ext::build::AstBuilder;
use syntax::parse::token;
from pwn import *
import pwn2
import sys
HELLO = 0
READY = 1
ERROR = 255
REQ_POST = 11
RESP_POST = 12
#!/usr/bin/env python
from pwn import *
import time, sys
context('linux')
# Our polyglots to branch our for a single architecture
# ARMEL: b $ + 464
# ARMEB: andvc r0, r0, #234
struct Foo(u8);
type Bar = Foo;
impl Bar {}
fn main() {}
/*
bug2.rs:3:1: 3:12 error: cannot associate methods with a type outside the crate the type is defined in; define and implement a trait or new type instead
bug2.rs:3 impl Bar {}
^~~~~~~~~~~
error: aborting due to previous error
#![feature(macro_rules)]
use std::cell::{RefCell, Ref};
use std::rc::Rc;
pub struct Thunk<T>(Rc<RefCell<ThunkValue<T>>>);
pub enum ThunkValue<T> {
Eager(T),
Lazy(proc() -> T)
}
fn foo(n: &u64) -> proc() -> u64 {
proc() { *n }
}
fn mk_foo(n: u64) -> proc() -> u64 {
foo(&n)
}
fn main() {
let x = mk_foo(1);

Keybase proof

I hereby claim:

  • I am idolfhatler on github.
  • I am idolfhatler (https://keybase.io/idolfhatler) on keybase.
  • I have a public key whose fingerprint is DC7B EEB0 8175 E641 6BB1 7901 E76B 7B2D 2F2F F530

To claim this, I am signing this object:

pub type PyPtr = *mut PyObjectHead;
#[repr(C)]
pub struct PyRef(PyPtr);
extern "C" fn say_hello(selfval: PyPtr, args: PyPtr) -> PyPtr { ... }
extern "C" fn say_hello(selfval: PyRef, args: PyRef) -> PyRef { ... }

Keybase proof

I hereby claim:

  • I am idolf on github.
  • I am idolfhatler (https://keybase.io/idolfhatler) on keybase.
  • I have a public key whose fingerprint is DC7B EEB0 8175 E641 6BB1 7901 E76B 7B2D 2F2F F530

To claim this, I am signing this object:

import random
def mymul(a, b):
if a > b:
a, b = b, a
res = 0
for n in range(a.bit_length()):
if a & (1 << n):
res ^= b << n