Skip to content

Instantly share code, notes, and snippets.

View emberian's full-sized avatar

emberian

View GitHub Profile
number = 1
#creates the nth triangle number
def triangle(number):
return (number * (number + 1)) / 2
#finds factors for triangle numbers
def factors(number):
num_factors = 0
for i in xrange(1, int(number**0.5) + 1):
@emberian
emberian / foo.asm
Created October 20, 2012 19:59
a program
ORG $400
LEA STRING,A1 a1 points to mem to be printed
MOVE.B #14,D0 d0 holds our trap code
TRAP #15 print from a1
LEA SPACE,A1 point a1 to space
TRAP #15 print space
MOVEA.L #DATA,A0 point a0 at our data list
@emberian
emberian / queuebot.lua
Last active December 14, 2015 14:59 — forked from anonymous/queuebot.lua
require "irc"
local lanes = require "lanes".configure()
local linda = lanes.linda()
local re = require "re"
local sleep = require "socket".sleep
local id = 0
local queued_requests = {}
@emberian
emberian / foo.py
Last active December 14, 2015 22:39 — forked from martianman/gist:5159740
a = bin(999999999)[2:]
temp = []
for i, v in enumerate(a):
if v == '1':
temp.append(len(a) - i)
print a
print temp
# 111011100110101100100111111111
# [30, 29, 28, 26, 25, 24, 21, 20, 18, 16, 15, 12, 9, 8, 7, 6, 5, 4, 3, 2, 1]
use std::os;
enum Token {
Add,
Sub,
Mul,
Div,
Mod,
Func {name: ~str, args: ~[~str]},
Num (int),
@emberian
emberian / bf.rs
Last active December 20, 2015 21:08 — forked from tiffany352/bf.rs
use std::uint;
use std::io;
use std::str;
enum Token {
Add,
Sub,
Inc,
Dec,
Out,
@emberian
emberian / flist.rs
Created August 15, 2013 16:22 — forked from anonymous/flist.rs
#[deriving(Clone)]
enum List<T> {
Empty,
Cons(T, ~List<T>)
}
impl<T: Eq + Clone> List <T> {
fn map(&self, f: &fn(T)->T)->List<T>{
match *self {
Empty => Empty,
Cons(ref x, ref xs) => Cons(f(x.clone()),~xs.map(f))
@emberian
emberian / rustbot.rs
Last active December 31, 2015 20:39
use std::fmt;
use std::io::net::tcp::TcpStream;
use std::io::net::ip::{Ipv4Addr, SocketAddr};
use std::io::buffered::BufferedStream;
#[deriving(Clone)]
pub struct RustBot {
nick: ~str,
user: ~str,
stream: BufferedStream<TcpStream>,
@emberian
emberian / main.rs
Last active December 31, 2015 22:59 — forked from smvv/main.rs
use std::run::{Process, ProcessOptions};
struct Gdb {
process: Process,
}
impl Gdb {
fn new(debuggee: ~str) -> Gdb {
let args = [~"gdb", ~"--return-child-result", ~"--quiet", ~"--nx",
@emberian
emberian / baz.rs
Last active January 1, 2016 19:49 — forked from klutzy/trace.rs
pub fn h(x: ||) { x() }