This file contains 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 random import uniform, shuffle | |
import matplotlib.pyplot as plt | |
import numpy as np | |
L = 500 # number of cells in row | |
num_iters = 500 # number of iterations | |
density = 0.48 # how many positives | |
vmax = 2 | |
p = 0.2 |
This file contains 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
function createField(width, height) { | |
var field = new Uint8Array(width * height); | |
var fcenterX = Math.floor(width / 2); | |
var fcenterY = Math.floor(height / 2); | |
// center occupied | |
field[fcenterX + fcenterY * width] = 1; | |
return { field: field, width:width, height:height}; | |
} |
This file contains 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
<html> | |
<head> | |
<script> | |
function getDictionary() { | |
var wordDictionary = {}; | |
document.getElementById("wordlist").value.trim().split("\n").forEach(line => { | |
var tokens = line.split("\t"); | |
wordDictionary[tokens[0]] = tokens[1]; | |
}); | |
return wordDictionary; |
This file contains 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
for D in `find . -mindepth 1 -type d` | |
do | |
ffmpeg -i ${D}/img%05d.jpg -c:v libx264 -vf fps=25 ${D}.mp4 | |
done | |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Wallet worth estimator</title> | |
<meta name="description" content="Small snippet of code for estimating worth of your crypto wallet"> | |
<meta name="author" content="Michał Drzał - michal.drzal@gmail.com"> | |
<meta name="version" content="0.1.1"> | |
<script> | |
var portfolio = (function() { | |
function add(currency, amount, usdValue) { |
This file contains 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
def get_revision(): | |
try: | |
with open('/proc/cpuinfo','r') as f: | |
for line in f: | |
if line.startswith('Revision'): | |
return line.split(":")[1].strip() | |
except: | |
return None | |
# sourced from: http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/ |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Security.Cryptography; | |
namespace PasswordGenerator | |
{ | |
class Program | |
{ |
This file contains 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 sys | |
from skimage import io, color | |
from scipy.ndimage.measurements import label, sum | |
from skimage.morphology import convex_hull_image | |
def main(): | |
if len(sys.argv) < 4: | |
print("Input format: <filename> <minimum size of detected shape in pixels> <threshold between 0 and 1>") | |
return |
This file contains 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
Tuple<double, double> LinearLeastSquaresFit(List<Point> points) | |
{ | |
double length = points.Count; | |
double Sx = points.Sum(p=> p.X); | |
double Sy = points.Sum(p => p.Y); | |
double Sxx = points.Sum(p => Math.Pow(p.X,2)); | |
double Sxy = points.Sum(p => p.X * p.Y); | |
var a = (Sxy * length - Sx * Sy) / (Sxx * length - Sx * Sx); | |
var b = (Sxy * Sx - Sy * Sxx) / (Sx * Sx - length * Sxx); |
This file contains 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
function shuffle(o){ | |
for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); | |
return o; | |
} | |
function cellular1d(width, height, density, rule) { | |
var blackPixelsCount = Math.floor(width*density), whitePixelsCount = width - blackPixelsCount; | |
var initial = []; | |
while(blackPixelsCount--) { |
NewerOlder