Skip to content

Instantly share code, notes, and snippets.

View leepro's full-sized avatar
🏠
Working from home

DW Lee leepro

🏠
Working from home
View GitHub Profile
@leepro
leepro / gist:4222132
Created December 6, 2012 06:07 — forked from markmarkoh/gist:2969317
World Map Geo JSON data
var countries_data = {"type":"FeatureCollection","features":[
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[74.92,37.24],[74.57,37.03],[72.56,36.82],[71.24,36.13],[71.65,35.42],[71.08,34.06],[69.91,34.04],[70.33,33.33],[69.51,33.03],[69.33,31.94],[66.72,31.21],[66.26,29.85],[62.48,29.41],[60.87,29.86],[61.85,31.02],[60.84,31.5],[60.58,33.07],[60.94,33.52],[60.51,34.14],[61.28,35.61],[62.72,35.25],[63.12,35.86],[64.5,36.28],[64.8,37.12],[66.54,37.37],[67.78,37.19],[69.32,37.12],[70.97,38.47],[71.59,37.9],[71.68,36.68],[73.31,37.46],[74.92,37.24]]]]},"properties":{"name":"Afghanistan"},"id":"AF"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[19.44,41.02],[19.37,41.85],[19.65,42.62],[20.07,42.56],[20.59,41.88],[20.82,40.91],[20.98,40.86],[20.01,39.69],[19.29,40.42],[19.44,41.02]]]]},"properties":{"name":"Albania"},"id":"AL"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[2.96,36.8],[8.62,36.94],[8.18,36.52],[8.25,34.64],[7.49,33.89],[9.06,3
@leepro
leepro / dyndns53.py
Last active December 15, 2015 04:09 — forked from vrypan/dyndns53.py
from area53 import route53
from boto.route53.exception import DNSServerError
import requests
import sys
from datetime import datetime
# Modified from https://markcaudill.me/blog/2012/07/dynamic-route53-dns-updating-with-python/
domain = 'domain.tld'
subdomain = 'subdomain_name'
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
def get_exif_data(image):
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags"""
exif_data = {}
info = image._getexif()
if info:
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
# Public Domain, i.e. feel free to copy/paste
# Considered a hack in Python 2
import inspect
def caller_name(skip=2):
"""Get a name of a caller in the format module.class.method
`skip` specifies how many levels of stack to skip while getting caller
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.
@leepro
leepro / gist:6388404
Created August 30, 2013 10:15
CDH Maven
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<repositories>
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
</repositories>
// Set Sort Comparator Class in the Driver code
job.setSortComparatorClass(SortFloatComparator.class);
// Write a Sort Comparator and save as "SortFloatComparator.java"
import java.io.*;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
@leepro
leepro / gist:6408846
Created September 2, 2013 02:55
K-complementary
import java.util.Arrays;
class Solution {
public int solution(int K, int[] A) {
Arrays.sort(A);
return getKC(K, A);
}
public int getKC(int K, int[] A) {
@leepro
leepro / gist:6408851
Created September 2, 2013 02:55
Mth from the end of a singly linked list.
class Solution {
int list_length = 0;
int foundValue = -1;
public int solution(IntList L, int M) {
int ret = travel2end(L,M);
if(ret == list_length) return -1;
else return foundValue;
}
@leepro
leepro / gist:6408855
Created September 2, 2013 02:56
Counting Invisible Nodes of Binary Tree.
class Solution {
int total_nodes = 0;
int nonvisible_nodes = 0;
public int solution(Tree T) {
traverse(T, Integer.MIN_VALUE);
return total_nodes - nonvisible_nodes;
}
@leepro
leepro / gist:6408856
Created September 2, 2013 02:57
2D with different colours. Counting countries.
class Solution {
int[][] visited = null;
int tot = 0;
public int solution(int[][] A) {
int N = A.length;
int M = A[0].length;
visited = new int[N][M];