Skip to content

Instantly share code, notes, and snippets.

View ubershmekel's full-sized avatar
🤙
What's a github status?

Yuval Greenfield ubershmekel

🤙
What's a github status?
View GitHub Profile
@ubershmekel
ubershmekel / volume
Last active April 11, 2016 01:32
Control volume on an alsamixer in ubuntu from the command line
#!/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:
@ubershmekel
ubershmekel / hotkeys_ubuntu_chromebook.py
Last active May 19, 2022 00:33
1-script install xfce4 hotkeys for chromebook ubuntu
"""
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 = [
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;
}
}
@ubershmekel
ubershmekel / gist:7c38943afccc58382e4a
Created July 11, 2014 21:30
Kombu unacked messages were missing when calling .get()
"""
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:
@ubershmekel
ubershmekel / youtube_viewcount_filter.js
Created July 21, 2014 02:51
Filter a youtube channel by viewcounts
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;
<!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. -->
@ubershmekel
ubershmekel / debug_http_requests.py
Created August 30, 2015 16:37
This will cause the requests module to print out anything it's doing
"""
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.
import sys
import pprint
import json
import requests
base_url = 'http://localhost:9200'
INDEX_COUNT = 400
@ubershmekel
ubershmekel / generic_repr.py
Created October 27, 2015 17:32
Simple repr methods that allow you to reconstruct a simple object
"""
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__)
@ubershmekel
ubershmekel / example.py
Last active February 23, 2023 08:16
Windows python process that upon death windows will kill its subprocesses
import subproc
import time
subproc.Popen('calc')
print('now close this window and see calc closing itself')
while True:
time.sleep(1)