Skip to content

Instantly share code, notes, and snippets.

mazz / gist:4259594
Created Dec 11, 2012
uses CGImageCreateWithImageInRect to perform a crop
View gist:4259594
// 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)
View gist:5274170
# 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',
View gist:5274321
[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 / gist:6a74a085e8557f3b1c69
Created May 27, 2014
pika ampq pyramid error
View gist:6a74a085e8557f3b1c69
#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:
View gist:0737c55e877a51d0582c
cd initpyr
./ -n foo -s
cd foo_env/foo
../bin/pserve development.ini
web browser:
user: admin
pass: admin

Keybase proof

I hereby claim:

  • I am mazz on github.
  • I am 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 /
Created Aug 13, 2016 — forked from cecilemuller/
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 to be served from /var/www/mydomain, and challenges will be served from /var/www/letsencrypt.

mazz /
Created Aug 14, 2016 — forked from esperlu/
MySQL to Sqlite converter
# 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 /
Created Aug 22, 2016 — forked from jwinder/
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 / auto_dubstep.rb
Created Aug 22, 2016 — forked from xavriley/auto_dubstep.rb
Auto generating dubstep with Sonic Pi
View auto_dubstep.rb
# Combines ideas from my other gists
current_bpm = 140.0
use_bpm current_bpm
define :wob do
use_synth :dsaw
lowcut = note(:E1) # ~ 40Hz
highcut = note(:G8) # ~ 3000Hz