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
''' | |
Problem: | |
Given a set of points on a cartesian plane with x,y points, find the number of rectangles among the points given. | |
Clarifications: | |
- Rectangles can include squares. | |
- Rectangles must span more than one row or column. | |
- Rectangles can be angled at 45, 90 and 135 degrees. | |
- Each unique rectangle should only be counted once. |
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
import os | |
import requests | |
for file in os.listdir('.'): | |
if not file.endswith('.txt'): | |
continue | |
with open(file, 'r') as f: | |
base = f.readlines() |
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
$(document).ready(function() { | |
/* | |
https://github.com/brianreavis/selectize.js/issues/470 | |
Selectize doesn't display anything to let the user know there are no results. | |
This plugin allows us to render a no results message when there are no | |
results are found to select for. | |
*/ | |
Selectize.define( 'no_results', function( options ) { | |
var self = this; |
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
# Probability of a spelling correction, c = | |
# Probability(c is a word) * | |
# Probability(original is a typo for c) | |
# Best correction = | |
# one with highest probability | |
# Probability(c is a word) = | |
# estimated by counting | |
# Probability(original is a typo for c) = | |
# proportional to number of changes | |
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
# Probability of a segmentation = | |
# Probability(first word) * Probability(rest) | |
# Best segmentation = | |
# one with highest probability | |
# Probability(word) | |
# estimated by counting | |
# Eg. Best segmentation("nowisthetime...") | |
# Pf("n") * Pr("owisthetime...") = .003% * 10^-30% = 10^-34% | |
# Pf("no") * Pr("wisthetime...") = .26% * 10^-26% = 10^-29% |
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
[alias] | |
co = checkout | |
br = branch | |
ci = commit | |
st = status | |
deploytag = "!git tag deploy-`date \"+%Y%m%d%H%M\"` && git push --tags" | |
switch = !legit switch \"$@\" | |
branches = !legit branches | |
sprout = !legit sprout \"$@\" | |
unpublish = !legit unpublish \"$@\" |
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
#!/bin/sh | |
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the | |
# CREATE block and create them in separate commands _after_ all the INSERTs. | |
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk. | |
# The mysqldump file is traversed only once. | |
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite | |
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite |
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
@fields = [{ | |
:foo => [ | |
1, | |
2, | |
[ | |
3, | |
{:field => 'oranges', :options =>{ :label => "Oranges"}} | |
], | |
{:a => {:zaz => 42}}, | |
[ |
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
require 'awesome_print' | |
hash = { | |
"key_one" => { | |
"sub_key_one_a" => { | |
"sub_sub_key_one_a" => "hello I'm sub sub key one a" | |
}, | |
"sub_key_one_b" => { | |
"sub_sub_key_one_b" => "hello I'm sub sub key one b", | |
"sub_sub_sub_key_one_b" => { |
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
def select_lookup(val, select) | |
return nil if val.nil? || val.blank? | |
from_select = select.find{|s| s.include? val} | |
return (!from_select.nil?) ? from_select[0] : val | |
end |