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
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 / 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
@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)
environs = {
'fc32c808-7a57-4e86-b9fd-e001ccfa6554': {'name': 'OAS-1',
'ip': '10.72.107.7',
'port': '22',
'user': 'josh'},
'acc758e3-2e14-4848-b767-fedaa4c9bfb7': {'name': 'OAS-1',
'ip': '10.72.107.7',
'port': '22',
'user': 'josh'},
'26ba4804-ed21-4099-81fd-6a7ac77c0bbb': {'name': 'OAS-1',