Skip to content

Instantly share code, notes, and snippets.

View emberian's full-sized avatar

emberian

View GitHub Profile
@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]
@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.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
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):
data = """
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
>>>>> def tetra(x, y):
c = x ** x
print c
>>> tetra(3, 3)
27
>>> tetra(2, 5)
4
>>> tetra(2, 3)
4
import maildb
import email
import time
import datetime
def genarate(STARTDATE, RECIPIENTS, DAYCOUNT, MESSAGE):
last_date = STARTDATE
mail = email.message_from_string(MESSAGE)
msg_lib = []
i = 0
>>> def generate(startdate, recipients, daycount, message):
... last_date = startdate
... mail = email.message_from_string(message)
... msg_lib = []
... for i in range(0, daycount):
... for recep in range(len(recipients)):
... mail['date'] = email.utils.formatdate(time.mktime(last_date.utctimetuple()))
... msg_lib.append(mail)
... last_date = last_date + datetime.timedelta(days=1)
... return msg_lib
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct
{ unsigned long length
; char *data
;
} String;
@emberian
emberian / aEFVTHdB
Created April 7, 2012 16:31 — forked from anonymous/aEFVTHdB
a guest on Apr 7th, 2012 - SVetter
$.ajax({
type: "POST",
url: "meta-parse.php",
data: $('input.#url').serialize(),
success: function(data) {
var json = $.parseJSON(data);
var images = json.images.split(',');
$('#url_preview').html("<div id='message'></div>");
$('#url_preview').toggle();
$('#add_process_board_picker').toggle();