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
// | |
// Wikipedia.m | |
// yoda | |
// | |
// Created by Utkarsh Sengar on 2/9/14. | |
// Copyright (c) 2014 area42. All rights reserved. | |
// | |
#import "Wikipedia.h" | |
#import "AFNetworking.h" |
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
from math import radians, cos, sin, asin, sqrt | |
def haversine(lon1, lat1, lon2, lat2): | |
""" | |
Calculate the great circle distance between two points | |
on the earth (specified in decimal degrees) | |
""" | |
# convert decimal degrees to radians | |
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2]) |
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
echo $(ioreg -l -n AppleSmartBattery -r | grep MaxCapacity | awk '{print $3}') / $(ioreg -l -n AppleSmartBattery -r | grep DesignCapacity | awk '{print $3}') \* 100 | bc -l |
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
<!-- Source: http://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin --> | |
<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"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.mkyong.core.utils</groupId> | |
<artifactId>dateUtils</artifactId> | |
<packaging>jar</packaging> |
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
class Main{public static void main(String...args){\u0066or(int | |
\u0020$:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²¤¨¸¬Æ".to\u0043h\u0061rArray() | |
)System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>> | |
+(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}} |
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
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>exec-maven-plugin</artifactId> | |
<executions> | |
<execution> | |
<goals> | |
<goal>exec</goal> | |
</goals> |
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
virtualenv --no-site-packages . | |
source bin/activate | |
bin/pip install Django psycopg2 django-sentry | |
bin/pip freeze > requirements.txt | |
bin/django-admin.py startproject mysite | |
cat >.gitignore <<EOF | |
bin/ | |
include/ | |
lib/ | |
EOF |
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
## {{{ http://code.activestate.com/recipes/577676/ (r9) | |
from collections import namedtuple | |
from math import fsum | |
def map_reduce(data, mapper, reducer=None): | |
'''Simple map/reduce for data analysis. | |
Each data element is passed to a *mapper* function. | |
The mapper returns key/value pairs | |
or None for data elements to be skipped. |
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
private static Class getClass(String classname) throws ClassNotFoundException { | |
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | |
if(classLoader == null) | |
classLoader = Singleton.class.getClassLoader(); | |
return (classLoader.loadClass(classname)); | |
} | |
} | |
//Source: http://snehaprashant.blogspot.com/2009/01/singleton-pattern-in-java.html | |
/** The preceding method tries to associate the classloader with the current thread; if that |
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
Source: https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs) | |
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 | |
# Enable the 2D Dock | |
defaults write com.apple.dock no-glass -bool true | |
# Disable menu bar transparency | |
defaults write -g AppleEnableMenuBarTransparency -bool false |
OlderNewer