Skip to content

Instantly share code, notes, and snippets.

View EricIO's full-sized avatar
🖥️
Hacking away

Eric Skoglund EricIO

🖥️
Hacking away
View GitHub Profile
def split_iter(iter, index):
for x in iter:
yeild x[index]
def split_tuple(iter):
return split_iter(0), split_iter(1)
foo = [(1,2),(3,4),(5,6)]
a,b = split_tuple(foo)
>>> def f1():
... a,b = 1,2
...
>>> import dis
>>> def f2():
... a,b = [1,2]
...
>>> dis.dis(f1)
2 0 LOAD_CONST 3 ((1, 2))
3 UNPACK_SEQUENCE 2
@EricIO
EricIO / let.scm
Created September 19, 2015 16:52
(define-syntax multiple-let
(syntax-rules ()
[(_ ((x* e*) ...) body body* ...)
((lambda (x* ...) body body* ...) e* ...)]))
#-*- coding: utf-8 -*-
import sys
import os
import pprint
import internetarchive
def _search_collection(collection_name):
""" Searches the internet archive for the specified collection.
if no items are found for the collection it returns None otherwise
@EricIO
EricIO / gist:56ea545df41c303e13cb
Created March 2, 2015 19:25
IA collection script
#-*- coding: utf-8 -*-
import sys
import pprint
import internetarchive
def _search_collection(collection_name):
""" Searches the internet archive for the specified collection.
if no items are found for the collection it returns None otherwise
the Search object is returned.
#-*- coding: utf-8 -*-
import sys
import pprint
import internetarchive
def _search_collection(collection_name):
""" Searches the internet archive for the specified collection.
if no items are found for the collection it returns None otherwise
the Search object is returned.
from selenium import webdriver
import random
import time
def get_url(tag_object):
a_tag = tag_object.find_elements_by_tag_name('a')[0]
return a_tag.get_attribute('href')
def write_results(f, url_list):
if len(url_list) == 0: return
def f(n, l=[]):
return l.append(n)
f(1,[12]) # returnerar [12,1]
f(1) # returnerar [1]
f(2) # returnerar [1,2]