Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import sys
from PyQt4 import QtCore, QtGui, QtWebKit
from ui_mainwindow import Ui_MainWindow
class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
# Maintain the list of browser windows so that they do not get garbage
# collected.
_window_list = []
#!/usr/bin/env python3
upper_limit = input("Highest number you'd like to go to: ")
for x in range(1, int(upper_limit)):
if x % 3 == 0 and x % 5 == 0:
print('FizzBuzz')
elif x % 3 == 0:
print('Fizz')
elif x % 5 == 0:
@silasb
silasb / .htaccess
Created March 30, 2012 17:16
GZip JS/CSS
AddEncoding gzip gz
RewriteEngine On
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]
<Files *.css.gz>
ForceType text/css
@ikks
ikks / goo.gl.py
Created May 31, 2012 19:43
Using goo.gl from python 2.X Where X is 6 or more
#Given to the public domain
#No warranties
import urllib2
import simplejson
def shorturl(urltoshorten):
"""Compress the URL using goo.gl take a look at https://developers.google.com/url-shortener/v1/getting_started
>>> shorturl('http://igor.tamarapatino.org')
'http://goo.gl/FxHOn'
@myano
myano / gist:5016700
Last active December 14, 2015 02:49
This will convert a given password "foobar" into the SHA output that Apache uses for it's .htpasswd files. You can take the output of this command and simply append it with a "username_here:{SHA}" and then place it into a .htpasswd is pointing at. This is useful if you want someone to generate a password for you but they don't have Apache instal…

Without salt:

$ echo -n "foobar" | sha1sum | cut -d' ' -f1 | xxd -r -p | base64

With salt:

$ USR="yourname";PWD="foobar";SALT="$(openssl rand -base64 3)";SHA1=$(printf "$PWD$SALT" | openssl dgst -binary -sha1 | sed 's#$#'"$SALT"'#' | base64); echo "$USR:{SSHA}$SHA1"

@myano
myano / join.py
Last active December 14, 2015 03:29
If you have saved your buffers in WeeChat with "/layout save", this script will print out an easy to copy/paste "/join #channel1,#channel2" that you can paste into WeeChat to join channels. If you have a lot of channels (more than 100). I would recommend joining only about 75-100 channels at a time.
#!/usr/bin/env python
import copy
f = open('weechat.conf', 'r')
formats = ['/join ', '/query ']
networks = {
@myano
myano / gitio.md
Last active December 16, 2015 23:39

Create git.io Short URLs in Python

git.io is an awesome URL shortener provided by Github. It works when shortening URLs from *.github.com/* to a small https://git.io/ link.

requests

&gt;&gt;&gt; import requests
@myano
myano / gist:5844270
Last active December 18, 2015 20:59

Rules for ##uno on freenode

  • No additional bots in the channel. Only ChanServ and jenni are allowed.
  • No automated scripts. (eg: No automatic /me's or messages when you go "away")
  • No personal insults.
  • No cheating.
  • Do not highlight nicks unless you are conversing with said person or persons.
  • Do not spam the channel with non-relevant commands to the current game.
  • Do not beg/insist the ops ban somebody.

My model for assessing trust with people.

  1. Random strangers
  2. Acquaintances
  3. Most friends that are more than acquaintances
  4. Close friends
  5. Only me
@myano
myano / fake_data.py
Last active December 20, 2015 07:29
#!/usr/bin/env python
'''
This file contains fake data which may be useful in
demonstrating basic principles in Python.
'''
import random
colors = [
'red',