Skip to content

Instantly share code, notes, and snippets.

View dnlcrl's full-sized avatar

dnlcrl

View GitHub Profile
@dnlcrl
dnlcrl / labeler.py
Created November 24, 2017 23:01
easy image labeling
import matplotlib.pyplot as plt
def point_in_circle(xp, yp, xc, yc, r):
return (xp - xc)**2 + (yp - yc)**2 < r**2
def draw_circles(ax, centers, classes, colors):
for i in range(centers.shape[0]):
circle = plt.Circle((centers[i, 1], centers[i, 0]), 20, color=colors[classes[i]], fill=False)
@dnlcrl
dnlcrl / crypto-total.py
Last active August 29, 2017 09:51
get total amount of dollars for all your crypto coins
#!/usr/bin/env python
import sys
import urllib2
import json
endpoint = "https://api.coinmarketcap.com/v1/ticker/"
args = 'bitcoin 1 litecoin 1 ethereum 1'.split(' ')
@dnlcrl
dnlcrl / convertgeojsonformapbox.py
Created January 19, 2017 16:12
Fix 3D buildings autogenerated kml files converted to geojson in order to load them in mapbox
# coding: utf-8
import json
import geojson
from geojson import Feature, Point, FeatureCollection, Polygon
import os
def parse_geojson(fname):
print fname
with open(fname, 'r') as f:
for i in *.kml; do
new=$(printf "%s.geojson" $(echo $i | cut -f 1 -d '.'));
togeojson "$i" > "$new";
done
from math import cos,sin,acos,asin,tan
from math import degrees as deg, radians as rad
from datetime import date,datetime,time
# this module is not provided here. See text.
from timezone import LocalTimezone
class sun:
"""
Calculate sunrise and sunset based on equations from NOAA
#!/bin/bash
file="$1"
for page in $(identify -density 12 -format '%p ' "$file") ; do
if convert "$file[$((page-1))]" -colorspace RGB -unique-colors txt:- | sed -e 1d | egrep -q -v ': \(\s*([0-9]*),\s*\1,\s*\1' ; then
echo $page
fi
done
newr='./r'; for f in `find . -name "*.jpg"`; do newname="${f/./$newr}"; convert $f -resize 32x32\! $newname; done
convert -delay 100 -loop 0 *.png anim.gif
@dnlcrl
dnlcrl / Generate_Password.sh
Last active April 17, 2016 10:08
Easily generate new password and copy it in the clipboard
#!/bin/bash
date | md5 | tail -c 16 | pbcopy
@dnlcrl
dnlcrl / Array Masking.swift
Created January 27, 2016 10:06 — forked from JadenGeller/Array Masking.swift
Swift Array Masking Operations
// Example
var x = [1, 2, 3, 4, 5] // [1, 2, 3, 4, 5]
var y = [1, 1, 2, 3, 5] // [1, 1, 2, 3, 5]
var z = x - y // [0, 1, 1, 1, 0]
x[ x % 2 != 0 ] = x + 1 // [2, 2, 4, 4, 6]
y[ y > 2 * z ] = y * y // [1, 1, 2, 9, 25]
z[ x > 2 && x < 6 ] = 0 // [0, 1, 0, 0, 0]