Skip to content

Instantly share code, notes, and snippets.

View quasarj's full-sized avatar
💭
SEND HALP

Quasar Jarosz quasarj

💭
SEND HALP
View GitHub Profile
@quasarj
quasarj / scrabble.py
Created December 7, 2011 20:29
quasarj's answer for r/python's Weekly Quiz #1
import sys
import itertools
if len(sys.argv) < 3:
raise IndexError("Not enough arguments!")
with open(sys.argv[1]) as words_file:
words = [a.strip() for a in words_file]
letters = sys.argv[2:]
@quasarj
quasarj / phantom-progress.sh
Created December 31, 2011 04:08
phantom-progress.sh
#!/bin/bash
fd=/proc/$1/fd/$2
fdinfo=/proc/$1/fdinfo/$2
name=$(readlink $fd)
size=$(wc -c $fd | awk '{print $1}')
while [ -e $fd ]; do
progress=$(cat $fdinfo | grep ^pos | awk '{print $2}')
echo $((100*$progress / $size))
sleep 1
done | dialog --gauge "Progress reading $name" 7 100
from __future__ import print_function
import os
import time
from multiprocessing import Pool
from multiprocessing.dummy import Pool as ThreadPool
def images():
"""Use a generator to read/process the list of images,
so map() can be used below"""
with people as (
select
-- name and age are the primary keys
'Quasar' as name,
30 as age,
'brown' as hair_color
from dual
union select
'Josh' as name,
@quasarj
quasarj / shoot
Created April 25, 2014 14:37
shoot
#!/bin/bash
#
# By Sirupsen @ http://sirupsen.dk
#
# Description: Very simple script to make you
# select a region of your screen, which will be captured, and
# then uploaded. The URL will then be injected into your clipboard.
#
# Dependencies:
#
@quasarj
quasarj / primepal.py
Last active August 29, 2015 14:02
Print the largest prime palindrome under 1000.
#!/usr/bin/env python2
def reverse_str(string):
return string[::-1] # because there is no builtin :(
def is_palindrome(number):
if number < 10:
return True
num_str = str(number)
! 66 = Capslock Key
keycode 66 = Super_L NoSymbol Super_L
! 133 = Left Windows Key
keycode 133 = Hyper_L NoSymbol Hyper_L
! 108 = Right Alt Key (remapped to tilde)
keycode 108 = grave asciitilde grave asciitilde
! 105 = Right Control Key
clear lock
clear mod5
clear mod4
def axe_quotes(line):
if '"' not in line:
return line
brackets = 0
out = ""
for c in line:
if c == '<':
brackets += 1
elif c == '>':
@quasarj
quasarj / python_2.7.9_suds_unverified.patch
Last active February 28, 2018 18:50
Patch to allow SUDS to work with invalid (or self-signed) SSL certs, on python 2.7.9+
--- /usr/lib/python2.7/site-packages/suds/transport/http.py 2015-06-09 17:40:15.000000000 -0500
+++ http.py 2015-06-09 17:42:05.953929465 -0500
@@ -19,6 +19,7 @@
"""
import urllib2 as u2
+import ssl
import base64
import socket
from suds.transport import *
@quasarj
quasarj / cProfile-results.txt
Created October 29, 2015 02:21
dict vs list test, for generating IDs
13995651 function calls (13995631 primitive calls) in 31.438 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
5 0.000 0.000 0.000 0.000 <frozen importlib._bootstrap>:1000(__init__)
2 0.000 0.000 0.000 0.000 <frozen importlib._bootstrap>:1019(init_module_attrs)
2 0.000 0.000 0.000 0.000 <frozen importlib._bootstrap>:1099(create)
2/1 0.000 0.000 0.004 0.004 <frozen importlib._bootstrap>:1122(_exec)
3 0.000 0.000 0.002 0.001 <frozen importlib._bootstrap>:1156(_load_backward_compatible)