Skip to content

Instantly share code, notes, and snippets.

@mdamien
mdamien / game_of_life.rs
Created June 25, 2017 00:24
game of life in rust
extern crate rand;
use std::{thread, time};
use rand::Rng;
/*
RULES
For a space that is 'populated':
Each cell with one or no neighbors dies, as if by solitude.
@mdamien
mdamien / parse.py
Last active July 27, 2019 06:46
parse_reddit.py
import requests, csv
# optional: makes requests-cache make it easy to cache your results
# import requests_cache
# requests_cache.install_cache('reddit_cache')
# where we store all the rows
DATA = []
def get(url, args={}):
@mdamien
mdamien / to_git.py
Created April 28, 2017 01:31
wikipedia to git
from slugify import slugify
import os, shlex, sys
from bs4 import BeautifulSoup
def call(cmd):
code = os.system(cmd)
if code != 0:
raise Exception('"{}"" returned {}'.format(cmd, code))
def call_bash(cmd):
@mdamien
mdamien / nginx.conf
Created February 21, 2017 12:07
daphne + nginx
server {
listen 80;
server_name dat_server.com;
client_max_body_size 1000M;
location / {
include proxy_params;
proxy_pass http://unix:/home/me/project/server.sock;
proxy_http_version 1.1;
@mdamien
mdamien / patch.diff
Last active February 16, 2017 21:42 — forked from anonymous/gist:bf5883337ef9772a047499cbc333af42
Hacking on gnome-terminator
sudo apt-get install bzr python python-vte python-psutil
bzr branch lp:terminator
./terminator # it works !
hacking can begin, for example type `self.text = '<>< ' + text + ' ><>` in `WindowTitle.set_title' of `window.py`
then title will always begin with "<>< "
@mdamien
mdamien / webpack.config.js
Last active February 16, 2017 15:00
Webpack 2: react + code splitting, to be used via "webpack --progress --watch"
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'source-map',
entry: {
graph: './src/graph.js',
vendor: ['react', 'react-dom'],
},
output: {
from selenium import webdriver
import time
driver = webdriver.Firefox()
driver.get("https://www.instagram.com/p/BP-rXUGBPJa/")
time.sleep(2)
print('click click click')
while True:
link = driver.find_element_by_css_selector('._l086v')
link.click()
@mdamien
mdamien / _idea
Created January 24, 2017 23:58 — forked from anonymous/_idea
simulate roads created by people trying to get from point A to point B
rules:
- each turn, everybody is assigned a position to go if they don't have already somewhere to go
- each time they go over a "block", it becomes easier for others to use it
@mdamien
mdamien / map.html
Last active October 6, 2016 13:30
mapbox keys control
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.25.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.25.1/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@mdamien
mdamien / html_to_lys.py
Created October 3, 2016 19:02
HTML to Lys
from bs4 import BeautifulSoup
from lys import render, L
html_doc = """
<ul class="breadcrumb">
<li class="active">Home</li>
</ul>
<ul class="breadcrumb">
<li><a href="#">Home</a></li>