Skip to content

Instantly share code, notes, and snippets.

@kennethreitz
kennethreitz / gist:1294570
Created October 18, 2011 03:54 — forked from Miserlou/gist:1294412
Posting JSON in Python without Requests Library
1 import urllib2
2 import json
221 def basic_authorization(user, password):
222 s = user + ":" + password
223 return "Basic " + s.encode("base64").rstrip()
224
225 def submit_pull_request(user, repo):
226 auth = (settings.username, settings.password)
227 url = 'https://api.github.com/repos/' + user + '/' + repo + '/pulls'
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

# This is a really old post, in the comments (and stackoverflow too) you'll find better solutions.
def find(key, dictionary):
for k, v in dictionary.iteritems():
if k == key:
yield v
elif isinstance(v, dict):
for result in find(key, v):
yield result
elif isinstance(v, list):
@iggym
iggym / gist:6023041
Last active October 11, 2024 18:21
Apple iTunes Search API and RSS feeds. --- Apple very usefully provides unauthenticated json feeds for both the iTunes search and iTunes rss
Apple very usefully provides unauthenticated json feeds for both the iTunes search and iTunes rss
The Search API returns your search results in JavaScript Object Notation (JSON) format. JSON is built on two structures:
All JSON results are encoded as UTF-8. For more information on JSON, please see http://www.json.org.
---
Search API
http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
---
RSS Info
@consti
consti / hosts
Last active November 15, 2024 08:12
/etc/hosts to block shock sites etc.
# This hosts file is brought to you by Dan Pollock and can be found at
# http://someonewhocares.org/hosts/
# You are free to copy and distribute this file for non-commercial uses,
# as long the original URL and attribution is included.
#<localhost>
127.0.0.1 localhost
127.0.0.1 localhost.localdomain
255.255.255.255 broadcasthost
::1 localhost
@mattcassinelli
mattcassinelli / App Store
Created February 2, 2014 07:49
Action list to open the App Store, search for a term, and open the Top Paid, Free, or Grossing charts.
http://[[list:App Store|Open=appstore.com/|Search=search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?media=software&term=[prompt:Query]|Top Paid=itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?genreId=36&popId=30|Top Free=itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?genreId=36&popId=27|Top Grossing=itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?genreId=36&popId=38]]
http://
[[
list:App Store
|Open=appstore.com/
|Search=search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?media=software&term=[prompt:Query]
|Top Paid=itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?genreId=36&popId=30
|Top Free=itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?genreId=36&popId=27
|Top Grossing=itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?genreId=36&popId=38
@jahanson
jahanson / pasteimage.html
Created March 3, 2014 17:42
Paste image from clipboard to canvas. Convert to base64 image string.
<!DOCTYPE html>
<html>
<head>
<title>Paste Image</title>
<script type="text/javascript">
var imageObj = new Image();
window.onload = function() {
document.getElementById("pasteTarget").
addEventListener("paste", handlePaste);
var canvas = document.getElementById('canvasTarget');
@cuibonobo
cuibonobo / bluetooth_kivy.py
Last active October 10, 2023 12:19 — forked from tito/bluetooth.py
Bluetooth example with Kivy. A more fleshed-out example here: https://github.com/tito/android-demo. A more modern way of doing it: https://github.com/kivy/plyer. And this guy used Kivy to connect to an Arduino: https://github.com/brean/arduino-kivy-bluetooth. Native Kivy code (?): https://groups.google.com/d/msg/kivy-users/n_cMbFzf_1A/5edKgQgycx0J
# Same as before, with a kivy-based UI
'''
Bluetooth/Pyjnius example
=========================
This was used to send some bytes to an arduino via bluetooth.
The app must have BLUETOOTH and BLUETOOTH_ADMIN permissions (well, i didn't
tested without BLUETOOTH_ADMIN, maybe it works.)
@fredrikaverpil
fredrikaverpil / treewidget_example.py
Last active July 27, 2021 07:24
Tree widget example #python #pyside
from PySide import QtCore, QtGui
import sys
app = QtGui.QApplication(sys.argv)
QtGui.qApp = app
folderTree = QtGui.QTreeWidget()
header = QtGui.QTreeWidgetItem(["Virtual folder tree","Comment"])
#...
@shamil
shamil / mount_qcow2.md
Last active November 19, 2024 14:46
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8