Skip to content

Instantly share code, notes, and snippets.

View alanjds's full-sized avatar

Alan Justino da Silva alanjds

  • Santo André, São Paulo/SP - Brazil
View GitHub Profile
@tito
tito / test.py
Last active October 10, 2020 05:59
Python-for-android / Pyjnius - test live-creation of native android widget.
'''
Use with Kivy Remote Shell:
cat test.py | ssh -p8000 -t -t admin@192.168.x.x
'''
from jnius import autoclass, cast
from android.runnable import Runnable
activity = autoclass('org.renpy.android.PythonActivity').mActivity
@garrypolley
garrypolley / decorators.py
Created September 21, 2012 15:06
Django decorate 3rd party app's views
# -*- coding: utf-8 -*-
from django.conf.urls import include
def decorated_include(urls, decorator)
"""Used to decorate all urls in a 3rd party app with a specific decorator"""
urls_to_decorate = include(urls)
for url_pattern in urls_to_decorate
url_pattern._callback = decorator(url_pattern._callback)
@schlamar
schlamar / gist:2993700
Last active September 23, 2016 20:55
urllib2 HTTPS connection with proxy and cert verification
import httplib
import urllib2
import ssl
import certifi
from backports.ssl_match_hostname import match_hostname
class CertValidatingHTTPSConnection(httplib.HTTPConnection):
default_port = httplib.HTTPS_PORT
@jobliz
jobliz / RedisPythonPubSub1.py
Created May 4, 2012 17:58
A short script exploring Redis pubsub functions in Python
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)
@schlamar
schlamar / processify.py
Last active April 17, 2024 19:19
processify
import os
import sys
import traceback
from functools import wraps
from multiprocessing import Process, Queue
def processify(func):
'''Decorator to run a function as a process.
Be sure that every argument and the return value
@joergschiller
joergschiller / a2dp_sink_ubuntu_linux.md
Created January 24, 2012 23:05
A2DP Sink on Ubuntu Linux with bluez (streaming bluetooth stereo audio from smartphone to pc)

Howto Enable and Use A2DP Sink on Ubuntu Linux with Bluez

  1. Add Enable=Source to /etc/bluetooth/audio.conf right after [General].

  2. Find address in form XX:XX:XX:XX:XX:XX of phone with hcitool scan.

  3. Pair and trust smartphone with sudo bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX and sudo bluez-test-device trusted XX:XX:XX:XX:XX:XX yes.

  4. Create loopback in pulseaudio connection bluetooth a2dp source with alsa sink:

@westonruter
westonruter / ko.sh
Created October 24, 2011 06:01
Script for opening Komodo from the (Mac) command line
#!/bin/bash
# Usage: ko [options] FILE
# @author Weston Ruter (@westonruter)
# Komodo Edit or Komodo IDE?
if [ -e "/Applications/Komodo Edit.app" ]; then
app="Komodo Edit"
else
app="Komodo IDE"
fi
@scottmessinger
scottmessinger / backbone-todos.js
Created June 19, 2011 00:09
Backbone.js todos vs knockout.js todos
We couldn’t find that file to show.
@mlafeldt
mlafeldt / scp_demo.py
Created February 24, 2011 09:09
[Python] paramiko examples
#!/usr/bin/env python
import sys, paramiko
if len(sys.argv) < 5:
print "args missing"
sys.exit(1)
hostname = sys.argv[1]
password = sys.argv[2]
@huyng
huyng / reflect.py
Created February 7, 2011 17:57
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):