Skip to content

Instantly share code, notes, and snippets.

View ivanistheone's full-sized avatar

Ivan Savov ivanistheone

View GitHub Profile
@wchargin
wchargin / transforms.py
Created August 18, 2015 01:55
affine transforms on PIL images
"""A library for describing and applying affine transforms to PIL images."""
import numpy as np
import PIL.Image
class RGBTransform(object):
"""A description of an affine transformation to an RGB image.
This class is immutable.
# Simulator for depth comparison error (i.e. z-fighting)
# Nathan Reed, June 2015
# Written for Python 3.4; requires numpy
import math
import numpy as np
import optparse
# Parse command-line options
parser = optparse.OptionParser()

The problem to solve

An example problem from the textbook Physics for Scientists and Engineers by Serway and Jewett:

Let's solve this using Symbolism, a C# library for computer algebra and symbolic computation.

Symbol definitions

command count num_people_using
cd 347893.0 803.0
ls 326227.0 783.0
rm 80394.0 744.0
git 426701.0 696.0
sudo 109042.0 690.0
mkdir 22987.0 655.0
cat 54491.0 642.0
mv 39297.0 640.0
ssh 83035.0 623.0
@rikusalminen
rikusalminen / pyrocket.py
Created July 31, 2014 09:28
Solving the rocket equation in Python
def numerical():
from scipy.integrate import odeint
from numpy import array
# [position, mass, velocity, mass flow]
def acceleration(y, t, v_exhaust=1.0):
return array([y[2], y[3], v_exhaust * y[3]/y[1], 0.0])
initial_state = array([0.0, 2.0, 0.0, -1.0])
@madjar
madjar / scrapper.py
Last active March 5, 2023 15:02
A example of scrapper using asyncio and aiohttp
import asyncio
import aiohttp
import bs4
import tqdm
@asyncio.coroutine
def get(*args, **kwargs):
response = yield from aiohttp.request('GET', *args, **kwargs)
return (yield from response.read_and_close(decode=True))
@yig
yig / JavaScript reference.md
Last active April 21, 2024 23:36
An overview of JavaScript best practices. Geared towards someone with a C/C++/Java/Python background.

JavaScript reference for non-JavaScript programmers

Author: Yotam Gingold
License: Public Domain (CC0)

This document is intended as a reference or introduction to JavaScript for someone familiar with a language like C/C++/Java or Python. It follows best practices and gathers the scattered wisdom from matny stackoverflow questions and in-depth JavaScript essays. It relies on no external libraries.

@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Lingua::EN::Fathom;
use TeX::Hyphen;
use List::Util qw(min);
@grantslatton
grantslatton / hngen.py
Last active September 27, 2021 11:07
A program that uses Markov chains to generate probabilistic Hacker News titles.
import urllib2
import re
import sys
from collections import defaultdict
from random import random
"""
PLEASE DO NOT RUN THIS QUOTED CODE FOR THE SAKE OF daemonology's SERVER, IT IS
NOT MY SERVER AND I FEEL BAD FOR ABUSING IT. JUST GET THE RESULTS OF THE
CRAWL HERE: http://pastebin.com/raw.php?i=nqpsnTtW AND SAVE THEM TO "archive.txt"