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 math | |
def get_distance_in_meters(lat1, lon1, lat2, lon2): | |
earth_radius = 6371007.2 # meters | |
lat1, lon1, lat2, lon2 = map(math.radians, (lat1, lon1, lat2, lon2)) | |
dlon = lon2 - lon1 | |
dlat = lat2 - lat1 | |
a = math.sin(dlat / 2) ** 2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2) ** 2 | |
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)) |
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 re | |
def roman_to_int(r): | |
r = r.strip().lower() | |
r_original = r | |
r = r.rstrip('i') | |
right_i_num = len(r_original) - len(r) | |
def parse_group(g): |
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 numpy as np | |
from shapely.geometry import Polygon, Point | |
from PIL import Image | |
import os | |
import sys | |
import csv | |
import pickle | |
import json | |
import random | |
import string |
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
'use strict'; | |
class Bidder { | |
constructor(quantity, cash) { | |
/* | |
quantity: integer even number of lots | |
each time exactly 2 lots are sold | |
so there will be exactly quantity/2 iterations | |
it's guaranteed that this number is positive |
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
#!/usr/bin/python | |
import sys | |
class BashFileIterator: | |
def __init__(self, src): | |
self.src = src | |
self.reset() | |
def reset(self): |
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
delim(){ | |
if [ -n "`/home/precious/programming/c/git_branch/git-br`" ]; then | |
echo '|' | |
fi | |
} | |
export PS1='\[\e[0;36m\]$?\[\e[0m\]|\[\e[0;31m\]`/home/precious/programming/c/git_branch/git-br`\[\e[0m\]$(delim)\[\e[0;35m\]\u\[\e[0m\]:\[\e[0;34m\]\w\[\e[0m\]\$ ' |
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
children(Parent,L) :- findall(Next,parent(Parent,Next),L). | |
ancestors(Child,L) :- findall(Next,parent(Next,Child),L). | |
repr_internal(Elem,L,R) :- (L == [] -> ancestors(Elem,R); children(Elem,R)). | |
repr_retval(Elem,R) :- children(Elem,L), repr_internal(Elem,L,R). | |
repr(Elem):- repr_retval(Elem,R), write(R). | |
read_line_pls(L) :- read_line(X),string_to_atom(X,L). | |
main :- |
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from math import * | |
import sys | |
# generator for values [a,b] with step 'step' | |
def frange(a,b,step): | |
while a <= b: | |
yield a | |
a += step |
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
(defun natural (a) | |
(and (integerp a) (> a 0)) | |
) | |
(defun fib (x) | |
(if (and (integerp x) (>= x 0)) | |
(if (< x 2) | |
1 | |
(+ (fib (- x 1)) (fib (- x 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<script> | |
function handleFileSelect(input,callback) { | |
// used links: | |
// http://www.w3.org/TR/file-upload/ |
NewerOlder