Skip to content

Instantly share code, notes, and snippets.

@mazz
mazz / gist:4259594
Created December 11, 2012 15:56
uses CGImageCreateWithImageInRect to perform a crop
// this chunk of code loads a jpeg image into a cgimage
// creates a second crop of the original image with CGImageCreateWithImageInRect
// writes the new cropped image to the desktop
// ensure that the xy origin of the CGRectMake call is smaller than the width or height of the original image
NSURL *originalImage = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"lockwood" ofType:@"jpg"]];
CGImageRef imageRef = NULL;
CGImageSourceRef loadRef = CGImageSourceCreateWithURL((CFURLRef)originalImage, NULL);
if (loadRef != NULL)
# These are installation specific values created when PyQt4 was configured.
_pkg_config = {
'pyqt_bin_dir': '/System/Library/Frameworks/Python.framework/Versions/2.7/bin',
'pyqt_config_args': '',
'pyqt_mod_dir': '/Library/Python/2.7/site-packages/PyQt4',
'pyqt_modules': 'QtCore QtGui QtHelp QtMultimedia QtNetwork QtDBus QtDeclarative QtOpenGL QtScript QtScriptTools QtSql QtSvg QtTest QtWebKit QtXml QtXmlPatterns phonon QtDesigner',
'pyqt_sip_dir': '/System/Library/Frameworks/Python.framework/Versions/2.7/share/sip/PyQt4',
'pyqt_sip_flags': '-x VendorID -t WS_MACX -x PyQt_NoPrintRangeBug -t Qt_4_8_4 -x Py_v3 -g',
'pyqt_version': 0x040a00,
'pyqt_version_str': '4.10',
[michael@varga (Fri Mar 29 19:14:18) /Library/Python/2.7/site-packages]% cd ~/Downloads/PyQt-mac-gpl-4.10
[michael@varga (Fri Mar 29 19:14:22) ~/Downloads/PyQt-mac-gpl-4.10]% make
/Developer/Tools/Qt/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I. -F/Library/Frameworks -D__APPLE__ -D__GNUC__ qpytextobject.h -o moc_qpytextobject.cpp
g++ -c -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -fPIC -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I/System/Library/Frameworks/Pyt
@mazz
mazz / gist:6a74a085e8557f3b1c69
Created May 27, 2014 00:41
pika ampq pyramid error
#function to get data from queue
def _get_tweets(size=10):
tweets = []
# Get ten messages and break out
count = 0
message_count = _queue_message_count()
print("size: " + str(size) + " message_count: " + str(message_count))
if message_count > 0:
@mazz
mazz / gist:0737c55e877a51d0582c
Created July 16, 2014 15:18
initpyr quickstart
cd initpyr
./initpyr.py -n foo -s
cd foo_env/foo
../bin/pserve development.ini
web browser: http://0.0.0.0:6543/login
user: admin
pass: admin
@mazz
mazz / keybase.md
Created February 28, 2015 16:06
keybase.md

Keybase proof

I hereby claim:

  • I am mazz on github.
  • I am mazz (https://keybase.io/mazz) on keybase.
  • I have a public key whose fingerprint is 81DA A3FA EF1C DDF3 B15A A6B4 A953 707A A850 34D5

To claim this, I am signing this object:

@mazz
mazz / letsencrypt_2016.md
Created August 13, 2016 18:50 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two modes when you don't want Certbot to edit your configuration:

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80) to renew certificates.

In the following, we're setting up mydomain.com to be served from /var/www/mydomain, and challenges will be served from /var/www/letsencrypt.

@mazz
mazz / mysql2sqlite.sh
Created August 14, 2016 05:35 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@mazz
mazz / sonic-pi-tutorial.md
Created August 22, 2016 20:44 — forked from jwinder/sonic-pi-tutorial.md
Sonic Pi tutorials concatenated

1 Welcome to Sonic Pi

Welcome friend :-)

Welcome to Sonic Pi. Hopefully you're as excited to get started making crazy sounds as I am to show you. It's going to be a really fun ride where you'll learn all about music, synthesis, programming, composition, performance and more.

But wait, how rude of me! Let me introduce myself - I'm

@mazz
mazz / auto_dubstep.rb
Created August 22, 2016 20:58 — forked from xavriley/auto_dubstep.rb
Auto generating dubstep with Sonic Pi
# DUBSTEP
# Combines ideas from my other gists
current_bpm = 140.0
use_bpm current_bpm
# WOBBLE BASS
define :wob do
use_synth :dsaw
lowcut = note(:E1) # ~ 40Hz
highcut = note(:G8) # ~ 3000Hz