Skip to content

Instantly share code, notes, and snippets.

@siim-
siim- / asd.js
Created November 13, 2014 14:53
Nõnda saab päringust infi
$.ajax({
url: 'sinuscriptl2ebsiia',
data: {'nimi': 'value'},
success: function(response) {
/*
Response on vastuse body. Kui su cgi annab välja application/json Content-Type siis on ta kohe javascript object
by default on ta vist siiski string
*/
console.log(response);
},
$.ajax({
url: 'sinuscriptl2ebsiia',
data: {'nimi': 'value'},
success: function(response) {
console.log('Yay!');
},
error: function() {
console.log('Ikaldus!');
}
}).done(function() {
@siim-
siim- / lenin.c
Created June 4, 2014 09:02
kodused leniniga
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ASCII_ZERO 48
#define STRING_LENGTH 256
#define RND_OPEN 40
#define RND_CLOSE 41
@siim-
siim- / analist.c
Created May 19, 2014 14:48
week16 Leniniga
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define WORD_LENGTH 40
typedef struct wordEntry {
unsigned int count;
@siim-
siim- / gist:9186989
Created February 24, 2014 11:51
Lenini harjutused
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int sum(int *arr, size_t sz) {
int sum = 0;
for(int i=0;i<sz;i++) {
sum += arr[i];
}
return sum;
import networkx as nx
import matplotlib.pyplot as plt
import unittest
import time
def timing_f( f, graph, s):
"""
Time the given function with the input n times
Input:
f - function to time
"""
Excercise ?? - The Mandlebrot set
"""
from PIL import Image
def draw_file(grid, filename):
img = Image.new('RGB', (len(grid[0]),len(grid)), "black")
pixels = img.load();
for i in range(img.size[1]):
for j in range(img.size[0]):
blue = grid[i][j]%255
"""
Excercise 12 - Generating heatmaps of letter pair frequencies with PIL
"""
from PIL import Image, ImageDraw
import random
def words(lines):
"""
Iterate through all the words
@siim-
siim- / regexes.txt
Last active December 27, 2015 00:59
Excercise 01: (0|1)+
Excercise 02: (0|1)*0
Excercise 03: ((0|1){2})+
Excercise 04: .*(0110|1001)+.*
Excercise 05: (.*(0110).*(1001).*)|.*(01101001).*|.*(100110).*|.*(011001).*|.*(011001).*
Excercise 09: pick(\s|-)?up truck
Excercise 10: ^(\w|\d)+\s+(\w|\d)+\s+(\w|\d|\?)+\s*((\w|\d)+$)?
Excercise 11: (cat)+\s(\w+\s){0,2}\s*(hat)+
Excercise 12: ([0-9]|1[0-9]|2[0-3]):([0-5][0-9])
"""
Excercise 8 - A basic blackjack dealer with unittesting
"""
import unittest
class Dealer():
tens = ['T','J','Q','K']
symbols = ['S','C','H','D']
def value_of_hand(self,hand):