This file contains hidden or 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
//This next variable could be declared in a seperate file if you wanted to. Not neccesary, its just a global | |
unsigned long int next; | |
int rand(void){ | |
//extern because I like to be explicit about my constants | |
extern unsigned long int next; | |
next = next * 1103515245 + 12345; | |
return (unsigned int)(next/65536) % 32768; | |
} |
This file contains hidden or 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
#include <stdio.h> | |
#include <limits.h> //CHAR_BIT is defined in limits.h | |
/*Bit Shifting Exercises */ | |
/* getbits: get n bits from position p*/ | |
unsigned getbits(unsigned x, int p, int n){ | |
return (x >> (p+1-n)) & ~(~0 << n); | |
/*Explanation: | |
(p+1-n) gets you the number of bits you'll have to shift off to move the n bits at position p to the rightmost position |
This file contains hidden or 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
#include <stdio.h> | |
char * chorus = "For he's a jolly good fellow"; | |
char * ending = "Which no body can deny"; | |
main(){ | |
int i; | |
for(i=0; i < 3; ++i){ | |
printf("%s\n",chorus); | |
sleep(1); |
This file contains hidden or 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
#!/bin/bash | |
#Script to change background image randomly when switching workspaces | |
#image directories: | |
dbus-monitor --profile "path='/org/mate/panel/applet/WindowListApplet/1'" | | |
while read -r msg; do | |
#echo $msg |
This file contains hidden or 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
import java.util.List; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
public class ListReference{ | |
public static int id = 0; | |
protected static class MyLittleObject{ | |
public int val; | |
public MyLittleObject(){this.val=ListReference.id; ListReference.id +=1; } |
This file contains hidden or 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 wsgiref.util import setup_testing_defaults | |
from wsgiref.simple_server import make_server | |
import os | |
def callXemark(): | |
return os.popen("./xemark < example.xe").read() | |
def xemarkapp(environ, start_response): | |
status = '200 OK' |
This file contains hidden or 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
MYSQL_HOST="localhost" | |
MYSQL_USER="username" | |
MYSQL_PASS="password" | |
MYSQL_DB ="databasename" | |
#Query for getting column names from database | |
TABLE_INFO = "SELECT distinct column_name FROM information_schema.columns WHERE table_name = '%s' order by ordinal_position asc" | |
class ORM_Base(): | |
def __init__(self,pk_id=None): |
This file contains hidden or 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
1 tails = 0 | |
2 heads = 0 | |
3 success = 0 | |
4 numTrials = 10000000 | |
5 | |
6 import random | |
7 | |
8 | |
9 for t in range(numTrials): | |
10 for i in range(256): |
This file contains hidden or 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
/* | |
Needs strmap http://pokristensson.com/strmap.html | |
*/ | |
/* | |
* Parse the url and store values into the hash table | |
* returns the number of values successfully placed into the hashtable | |
*/ | |
int parseURL(char * url, int urlLength, StrMap * table){ | |
int i; | |
int j; |
This file contains hidden or 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
""" | |
Author: Ethan Joachim Eldridge | |
Website: ejehardenberg.github.io | |
Contact me through my github. | |
This code is available for use in the public domain to help out with | |
people migrating from WP to Harp, http://harpjs.com/ | |
I do appreciate a star on the gist if it helped you though. | |
""" |