This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
Control volume on an alsamixer in ubuntu from the command line using python-alsaaudio | |
Written for Crouton Chromebooks to have easy hotkeys for their volume control in ubuntu. | |
https://github.com/dnschneid/crouton/wiki/Keyboard | |
usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
1-script install xfce4 hotkeys for chromebook ubuntu | |
You might need to `killall xfconfd` or restart xfce for these to take effect. | |
""" | |
import os | |
import datetime | |
addage = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var origin = function () { | |
// IE10 Doesn't have window.location.origin :( | |
if (!window.location.origin) { | |
var port = window.location.port ? ':' + window.location.port : ''; | |
return window.location.protocol + "//" + window.location.hostname + port; | |
} else { | |
return window.location.origin; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Kombu and Celery were doing something strange were I noticed rabbit had | |
a large number of unacked messages, but when I hit .get() I got nothing. | |
This manifested on the client side of things at times where it would work once, | |
hang the next. And then work again. | |
""" | |
# This was the bad code | |
with kombu.Connection(RABBIT_HOST) as conn: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var thresh = 100e6; | |
var lis = document.querySelectorAll('.yt-lockup-meta-info li'); | |
for(var i = 0; i < lis.length; i++) { | |
var text = lis[i].textContent; | |
if(text.indexOf('views') == -1) { | |
continue; | |
} | |
if(Number(text.replace(' views','').replace(/,/g, '')) < thresh) { | |
//console.log('-' + text); | |
var li = lis[i].parentNode.parentNode.parentNode.parentNode.parentNode; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="keywords" lang="de" content="Zeitleiste, Zeitlinie, Zeitkarte, Geschichte, Chronologie"> | |
<meta name="keywords" lang="en" content="Timeline, Timemap, History, Chronology"> | |
<title>Timeline - Proof-of-concept</title> | |
<!-- That's my local d3 path. When working locally, use your local path. --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Thank you | |
http://stackoverflow.com/a/24588289/177498 | |
""" | |
def debug(): | |
import logging | |
# These two lines enable debugging at httplib level (requests->urllib3->http.client) | |
# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import pprint | |
import json | |
import requests | |
base_url = 'http://localhost:9200' | |
INDEX_COUNT = 400 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
These two repr implementations make a "repr" that you can just drop into your class if it's a simple one. | |
""" | |
class A: | |
def __init__(self, x, y): | |
self.x = x | |
self.y = y | |
def __repr__(self): | |
return "%s(**%r)" % (self.__class__.__name__, self.__dict__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subproc | |
import time | |
subproc.Popen('calc') | |
print('now close this window and see calc closing itself') | |
while True: | |
time.sleep(1) |