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 / README
Last active August 29, 2015 14:06
pyjnius / allow customization of the JNIENV function to get
P4A_pyjnius_DIR=~/code/pyjnius ./distribute.sh -b minimal -m 'pyjnius python' -u pyjnius
cd .; ./build.py --package org.minimal.test --name _MINIMAL --version 1 --private ~/code/testmininal --asset debug installd
adb logcat *:S python:D
#make some settings accessible via settings.FOO from within templates
from django.conf import settings
def exposed_settings(request):
context_settings = dict()
for x in settings.TEMPLATE_CONTEXT_SETTINGS:
context_settings[x] = getattr(settings, x)
return { 'settings': context_settings }
@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
@p-lewis
p-lewis / encode.js
Last active August 4, 2016 05:08
Encode a message in node.js for a Celery worker
var uuid = require("node-uuid");
// Create a message to be consumed by the queuedemo.tasks.add Celery task
// will incorporate arguments x & y as part of `add(x,y)` message
function makeCeleryAddMessage(x, y){
var msgId = uuid.v4();
// This is the outer AMQP envelope
var msgEnvelope = {
@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
@weakish
weakish / doctest.md
Created November 4, 2018 15:33
#survey of #Ruby #doctest

Ruby Doctest

Doctest in Python is a good design. Doctest ensures code, documentation, and tests are in a single place. So readers can understand the logic of code easier, without a lot of navigation.

Unlike Python, Ruby does not have built-in doctest, but there are some third party libraries enabling doctest in Ruby.

@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)
@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
@inadarei
inadarei / minikube-sierra.md
Last active October 20, 2020 01:57
Minikube Setup: Docker for Mac / Sierra

Prerequisite: latest Docker for Mac on MacOS Sierra

$ brew update
$ brew install --HEAD xhyve
$ brew install docker-machine-driver-xhyve
$ sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
$ sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve

$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.18.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
@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]