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
-------------------------------------------------------------------------------- | |
-- HYPER KEYS + GLOBAL VARIABLES | |
-------------------------------------------------------------------------------- | |
local hyper = { "ctrl", "alt", "cmd" } | |
-- We'll store the 'targetScreen' the user picks. | |
local targetScreen = nil | |
-- Which application do we want to open/move? | |
-- You can change this to any bundle ID or app name you like (e.g., "Safari"). |
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
CREATE TABLE tweets ( | |
... user text, | |
... time timestamp, | |
... tweet text, | |
... lat float, | |
... long float, | |
... PRIMARY KEY (user, time) | |
... ); | |
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 string | |
class TrieNode(object): | |
""" | |
Context: Implementation of the trie using a dictionary is trivial: | |
https://gist.github.com/itissid/6a5bec95424b5630908e877c02d957d5 | |
But if one was to implement the Trie node as a DS then one needs to think about implementation a bit more. | |
So what I did was keep the API code for search, insert, search_prefix the same as the gist; i.e. | |
to pretend we are still using a dictionary, but I implemented some magic methods for the trie in the TrieNode ( |
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
class Trie: | |
def __init__(self): | |
""" | |
Initialize your data structure here. | |
""" | |
self.root_dict = {} | |
def insert(self, word): | |
""" |
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
class Backend(object): | |
"""Allows access to backend and removes logic from handlers""" | |
def __init__(self): | |
"""Inititalize with the variables you need""" | |
self.__users_data = None | |
self.db = Connection( | |
options.db_host, | |
options.db, | |
user=options.db_user, |
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
on run argv | |
set targetTabName to quoted form of (item 1 of argv) | |
set targetFullPath to (item 2 of argv) | |
tell application "Safari" | |
--Variables | |
set targetWindow to 0 | |
set targetTab to 0 | |
set found to false | |
--Repeat for Every Window |
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
on run argv | |
set targetTabName to quoted form of (item 1 of argv) | |
set targetFullPath to (item 2 of argv) | |
tell application "Google Chrome" | |
--Variables | |
set targetWindow to 0 | |
set found to false | |
set targetTab to 0 | |
--Repeat for Every Window | |
repeat with theWindow in every window |
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
dependencies { | |
compile project(':foo'), project(':bar') | |
} |
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
sgupta-mbp:~ sgupta$ cpan -l |grep LocalEnv | |
Can't stat /Network/Library/Perl/5.18/darwin-thread-multi-2level: No such file or directory | |
at /System/Library/Perl/5.18/App/Cpan.pm line 1216. | |
Can't stat /Network/Library/Perl/5.18: No such file or directory | |
at /System/Library/Perl/5.18/App/Cpan.pm line 1216. | |
App::PerlLocalEnv undef | |
Can't cd to (/Users/sgupta/.cpan/build/Module-Install-1.16-tf5h8B/) lib: Permission denied | |
at /System/Library/Perl/5.18/App/Cpan.pm line 1216. | |
Can't cd to (/Users/sgupta/.cpan/build/Module-Install-1.16-tf5h8B/) t: Permission denied | |
at /System/Library/Perl/5.18/App/Cpan.pm line 1216. |
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
too_large = 1e12 | |
def violations(words, page_width): | |
""" | |
The greater this is the worst the worst is the violation. | |
TODO(Sid): abs?? | |
""" | |
cost = page_width - (sum(len(i) for i in words) + len(words) - 1) | |
if cost < 0: | |
return too_large | |
else: |
NewerOlder