Skip to content

Instantly share code, notes, and snippets.

View charlierm's full-sized avatar

Charlie Mills charlierm

View GitHub Profile
@charlierm
charlierm / linked_list.py
Last active December 17, 2015 22:28
A very simple linked list in Python.
import random
class Item:
next = None
data = 0
def __init__(self):
self.data = random.random()
@charlierm
charlierm / linked-list.c
Last active December 17, 2015 22:29
A painfully simple linked list written in C, with example usage.
#include <stdlib.h>
#include <stdio.h>
/**
Structure for storing an individual node in the list.
**/
typedef struct Node
{
int data;
struct Node* next;
@charlierm
charlierm / Collision.java
Last active December 17, 2015 22:59
A simple Java program showing example usage of the synchronized keyword.
import java.lang.Runnable;
import java.lang.Thread;
/**
* The Main Class.
**/
public class Collision {
/**
* Main entry point into the application.
@charlierm
charlierm / LinkedList.java
Created May 31, 2013 21:08
Thread safe linked list written in java
import java.util.Iterator;
public class LinkedList<T>{
private Node head;
private int length;
public LinkedList(){
this.length = 0;
@charlierm
charlierm / linked_list.cpp
Last active April 25, 2024 09:11
Linked list written in c++
#include <iostream>
#include <cstdlib>
class Node
{
public:
Node* next;
int data;
};
public class main{
public static void main(String[] args) {
//WORKS
SingletonDemo s = SingletonDemo.getInstance();
s.setValue(12);
//FAILS
SingletonDemo ss = SingletonDemo.getInstance();
System.out.println(ss.getValue());
}
}
#include <iostream>
using namespace std;
class Singleton
{
public:
static Singleton* getSingleton();
int getValue();
void setValue(int i);
#include <stdio.h>
#include <stdlib.h>
struct SLNode {
struct SLNode *next;
long value;
};
void sl_push_front(struct SLNode **list, long v){
//Create new node, add the value.
@charlierm
charlierm / matcher.py
Created August 17, 2014 20:30
Tinder automatcher
import Queue
import threading
import tinderClient
import json
import logging
logging.basicConfig(level=logging.DEBUG)
PRODUCER_THREADS = 5
CONSUMER_THREADS = 10
@charlierm
charlierm / twatbag.py
Last active August 29, 2015 14:06
Tinder autoliker script
import Queue
import threading
import tinderClient
import json
import logging
logging.basicConfig(level=logging.DEBUG)
PRODUCER_THREADS = 3
CONSUMER_THREADS = 10