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 java.math.BigInteger | |
class Iban(private val iban: String) { | |
companion object { | |
/* List updated to release 73, January 2017, of IBAN Registry (75 countries) */ | |
private const val countryCodes = | |
"AD24 AE23 AL28 AT20 AZ28 BA20 BE16 BG22 BH22 BR29 BY28 CH21 CR22 CY28 CZ24 DE22 " + | |
"DK18 DO28 EE20 ES24 FI18 FO18 FR27 GB22 GE22 GI23 GL18 GR27 GT28 HR21 HU28 IE22 " + | |
"IL23 IQ23 IS26 IT27 JO30 KW30 KZ20 LB28 LC32 LI21 LT20 LU20 LV21 MC27 MD24 ME22 " + |
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 Geo(private val lat: Double, private val lon: Double) { | |
companion object { | |
const val earthRadiusKm: Double = 6372.8 | |
} | |
/** | |
* Haversine formula. Giving great-circle distances between two points on a sphere from their longitudes and latitudes. | |
* It is a special case of a more general formula in spherical trigonometry, the law of haversines, relating the | |
* sides and angles of spherical "triangles". |
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 Foundation | |
import XCPlayground | |
func httpGet(request: NSURLRequest!, callback: (NSURLResponse?, String, String?) -> Void) { | |
let session = NSURLSession.sharedSession() | |
let task = session.dataTaskWithRequest(request) { | |
(data, response, error) -> Void in | |
if error != nil { | |
callback(response, "", error!.localizedDescription) | |
} else { |
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
#!/bin/bash | |
basedir=$(pwd -P) | |
for subdir in $(find . -maxdepth 1 -type d ); | |
do | |
dir="$basedir"/$(basename "$subdir") | |
# Check if sub-directory is a Mercurial repository | |
if [ -n "$(hg --cwd $dir root)" ]; | |
then |
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
#!/bin/bash | |
## Linux and MacOS X alias script for VirtualBox console commands | |
## to start, stop, query status and list Virtual Machines | |
## | |
## Usage: vm [vm_name] <command> <argv>... | |
## | |
## VM commands: | |
## start Starts the VM | |
## stop Stops a running VM using ACPI shutdown |
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
<?php | |
/** | |
* A really simple priority queue implementation in PHP. | |
* | |
* @author João Ferrão | |
* @link https://github.com/jferrao | |
*/ | |
class PnQueue | |
{ | |
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
<?php | |
/** | |
* Allows the PHP SoapClient to persist any non http or non port 80 calls. | |
* | |
* When SoapClient in WSDL mode with a scheme or a port others then http and 80, the first | |
* connection goes through correctly but all subsequent ones revert back to http and no | |
* port in the URI. This class fixes that and allows the SoapClient to use the same scheme | |
* and port as the ones defined when a new instance of the class is created. | |
* |