Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am leahein on github.
  • I am leahein (https://keybase.io/leahein) on keybase.
  • I have a public key whose fingerprint is CBB8 A05A 6B68 F347 FDE9 A737 5900 F322 69FB 28AA

To claim this, I am signing this object:

git clone <git repository A url> <new-directory>
cd <new-directory>
git remote rm origin
git filter-branch --subdirectory-filter <directory 1> -- --all
@leahein
leahein / sort_by.py
Last active October 23, 2016 03:43
Sort
def sort_by(self, criteria):
keywords = list()
for keyword, data in self.report.items():
keywords.append((keyword, data[criteria]))
return sorted(keywords, key=operator.itemgetter(1))
Adwords(report).sort_by("Clicks")
# =>[('Do Androids Dream of Electric Sheep? ', 109), ('science fiction books about time travel', 50),
# ('science fiction books about space', 10), ('doctor who books', 8), ('I, Robot', 3)...]
@leahein
leahein / adwords.py
Created October 23, 2016 03:26
adwords_class
import json
class Adwords(object):
def __init__(self, report):
self.report = json.loads(report)
@leahein
leahein / parse_by_class.py
Last active October 23, 2016 03:25
parse_by_class
def parse_by_class(self, value):
if type(value).__name__ == 'unicode': # Do something with strings
if type(value).__name__ == 'list': # Do something with arrays
if type(value).__name__ == 'dict': # Do something with dictionaries
public interface IQueryable : IEnumerable
public interface IQueryable : IEnumerable
List<Animals> Leopards = Feline(AllSpotted()).ToList();
List<Animals> Hyenas = Canine(AllSpotted()).ToList();
public IEnumerable<Books> AllHumor()
{
return from book in BookCase.Books
where book.genre.Humor == true
select book;
}
public IEnumerable<Books> Fiction(IEnumerable<Books> sample)
{
return from book in sample
public interface IEnumerable
{
IEnumerator GetEnumerator();
}