This file contains hidden or 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
''' | |
Python implementation of the American Soundex algorithm to match English homophones | |
Refrence: https://en.wikipedia.org/wiki/Soundex | |
''' | |
import regex as re | |
# Define the Soundex consonant mappings | |
soundex_mappings = {'1': ['b', 'f', 'p', 'v'], | |
'2': ['c', 'g', 'j', 'k', 'q', 's', 'x', 'z'], |
This file contains hidden or 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/python3 | |
# By Steve Hanov, 2011. Released to the public domain. | |
# Updated 2014 to use DAWG as a mapping. | |
import sys | |
import time | |
DICTIONARY = "/usr/share/dict/words" | |
QUERY = sys.argv[1:] | |
# This class represents a node in the directed acyclic word graph (DAWG). It |
This file contains hidden or 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
package sandbox; | |
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; | |
import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE; | |
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; | |
import java.io.IOException; | |
import java.nio.file.ClosedWatchServiceException; | |
import java.nio.file.FileSystem; |
This file contains hidden or 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
day = 1 | |
month = 12 | |
year = 1988 | |
days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] | |
days_in_months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
is_leap_year = lambda y : y % 4 == 0 and (y % 100 != 0 or y % 400 == 0) | |
leap_years = len([y for y in xrange(1, year) if is_leap_year(y)]) | |
normal_years = year - 1 - leap_years |
This file contains hidden or 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
function AttachmentCtrl($scope, $location, $timeout, Docs) { | |
$(function() { | |
$('#detail-form-doc').fileupload({ | |
dataType: 'json', | |
url: '/angular-ib/app/fileupload?id=' + $location.search().id, | |
add: function(e, data) { | |
$scope.$apply(function(scope) { | |
// Turn the FileList object into an Array | |
for (var i = 0; i < data.files.length; i++) { | |
$scope.project.files.push(data.files[i]); |
This file contains hidden or 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/env python | |
# -*- coding: utf-8 -*- | |
import string | |
literals = string.printable | |
HOP_FORWARD = 1 | |
HOP_BACKWARD = -1 |
This file contains hidden or 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
abstract class Person { | |
String name; | |
Person(String name) { | |
this.name = name; | |
} | |
} | |
interface ICatchPlayer<T extends Throwable> { | |
void throww(T object); | |
} |
This file contains hidden or 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
(function($, undefined){ | |
String.prototype.toProperCase = function () { | |
return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); | |
}; | |
})(jQuery); |
This file contains hidden or 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 -*- | |
import sys | |
class _ValueFileParserError(Exception): | |
pass | |
class ValueFileParser: | |
def __init__(self, path): |
This file contains hidden or 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 datetime import datetime | |
import time | |
def datetime2unixticks(ts): | |
ts = ts.split()[0] | |
dt = datetime.strptime(ts, '%Y-%m-%d') | |
return int(time.mktime(dt.timetuple())) |
NewerOlder