Skip to content

Instantly share code, notes, and snippets.

View Alquimista's full-sized avatar

Roberto Gea Alquimista

  • Querétaro, Qro, México
View GitHub Profile
Windows
copy /b file1+file2 destfile
Linux
cat file1+file2 > destfile
#!/usr/bin/env python
# -*- coding: utf-8 -*-s
from pyPdf import PdfFileWriter, PdfFileReader
from optparse import OptionParser
def mergepdf(outputfile, filestobemerged):
output = PdfFileWriter()
for infile in filestobemerged:
# Read the input PDF file
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from itertools import *
l = [[1, 2], [3, 4]]
print(list(chain(*l)))
#!/usr/bin/env python
# -*- coding: utf-8 -*-s
#http://pythonnewbie.wordpress.com
#/2011/01/12/split-a-list-using-python-zip-function/
mylist = [1,2,3,4,5,6,7,8,9,10]
j = 5
print zip(*[iter(mylist)]*j) #prints [(1, 2, 3, 4, 5), (6, 7, 8, 9, 10)]
j = 2
openscad -o render.png --imgsize=2048,2048 assembly.scad
convert render.png -resize 512x512 render.png
class CaseInsensitiveDict(dict):
def __setitem__(self, key, value):
super(CaseInsensitiveDict, self).__setitem__(key.lower(), value)
def __getitem__(self, key):
return super(CaseInsensitiveDict, self).__getitem__(key.lower())
def run_command(command):
process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE)
while True:
output = process.stdout.readline()
if output == '' and process.poll() is not None:
break
if output:
self.logger.info(output.strip())
rc = process.poll()
return rc
@Alquimista
Alquimista / pcalc
Last active December 16, 2015 05:19
alias pcalc="python -ic 'from __future__ import division;from math import *,from cmath import *'"
def compare(a, b):
return list(frozenset(a).intersection(b))
python -c "import SimpleHTTPServer, SocketServer, BaseHTTPServer; SimpleHTTPServer.test(SimpleHTTPServer.SimpleHTTPRequestHandler, type('Server', (BaseHTTPServer.HTTPServer, SocketServer.ThreadingMixIn, object), {}))" 9090