Skip to content

Instantly share code, notes, and snippets.

#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@daedalus
daedalus / zeta.c
Created March 8, 2012 23:18
Riemann Zeta Function
#include <stdio.h>
#include <math.h>
double lim(double (*f)(double), double p)
{
double a(int n)
{
if (isinf(p)) {
return pow(2, n);
}
#!/usr/bin/env python
import base64, hashlib, hmac, json, sys, getpass
from Crypto.Cipher import AES
from Crypto.Hash import RIPEMD, SHA256
base58_chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
def prompt(p):
return getpass.getpass(p + ": ")
@daedalus
daedalus / conway.py
Last active August 29, 2015 14:23
conway game of life
#!/usr/bin/env python
# Copyright (c) 2009 Dario Clavijo
#
# -*- coding: utf-8 -*-
# This is the game life http://en.wikipedia.org/wiki/The_Game_of_Life
import os, time, random
#
# given the x**2-2=0 condition we bruteforce an aproximation to sqrt(2)
def sqrt2test():
x = 2
error = 1
step = 0.5
lower_error = 1
i = 0
while (error != 0):
i = i + 1
@daedalus
daedalus / r.py
Created March 11, 2016 21:32 — forked from wizardofozzie/r.py
r.py
#!/usr/bin/python
#################################################################################
# #
#.______ _______. ______ ___ .__ __. #
#| _ \ / | / | / \ | \ | | #
#| |_) | ______ | (----`| ,----' / ^ \ | \| | #
#| / |______| \ \ | | / /_\ \ | . ` | #
#| |\ \----. .----) | | `----./ _____ \ | |\ | #
#| _| `._____| |_______/ \______/__/ \__\ |__| \__| v0.2.0 #
#!/usr/bin/env python
# example of proof-of-work algorithm
import hashlib
import time
import random
import math
max_nonce = 2 ** 32 # 4 billion
#!/usr/bin/python
import socket
import struct
DNS_QUERY_SECTION_FORMAT = struct.Struct("!2H")
DNS_QUERY_MESSAGE_HEADER = struct.Struct("!6H")
def decode_question_section(message, offset, qdcount):
questions = []
import datetime
import hashlib
import hmac
import random
import string
import time
import unirest as unirest
key = "da01c7e1f0dc4f166c6aa3d56add3293"
secret = "XXXXXXXXXXXXXXXXXXXXXXXXXX"
import os
import sys
def readfile(fn):
fd = open(fn,'r')
r = fd.read()
fd.close()
return r
def writefile(fn,s):