Skip to content

Instantly share code, notes, and snippets.

@getadeo
getadeo / dtmf.rb
Last active May 16, 2018 02:08 — forked from radralph/mads_call.rb
wait(1500)
result = ask "Please enter 3 numbers", {
:choices => "[3 DIGITS]",
:terminator => '#',
:timeout => 15.0,
:mode => "dtmf",
:onChoice => lambda { |event|
say "Thank you."
}
}
{
"title": "Leopold FC660 Capslock to FN w/ function keys and escape",
"rules": [
{
"description": "Map capslock to fn",
"manipulators": [
{
"conditions": [{ "type": "device_if", "identifiers": [{
"product_id": 257, "vendor_id": 1204
}]}],
@getadeo
getadeo / gist:c389c730262a8e8b5f2c99cdb8598bd4
Created June 28, 2017 09:50 — forked from jessedearing/gist:2351836
Create self-signed SSL certificate for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key
// kills long running ops in MongoDB (taking seconds as an arg to define "long")
// attempts to be a bit safer than killing all by excluding replication related operations
// and only targeting queries as opposed to commands etc.
killLongRunningOps = function(maxSecsRunning) {
currOp = db.currentOp();
for (oper in currOp.inprog) {
op = currOp.inprog[oper-0];
if (op.secs_running > maxSecsRunning && op.op == "query" && !op.ns.startsWith("local")) {
print("Killing opId: " + op.opid
@getadeo
getadeo / alembic.ini
Created March 9, 2016 14:18 — forked from spinningD20/alembic.ini
migrate include_objects problem
[excluded]
tables = ProjectInfo, AddressTypes, AddressTypes_tracking, ClientAddresses_tracking, ClientContacts, ClientContacts_tracking, ClientTypes, ClientAddresses, Clients, Clients_tracking, ContactGroups, ContactGroups_tracking, Contacts, Contacts_tracking
@getadeo
getadeo / Exclude_tables.md
Created March 9, 2016 14:06 — forked from utek/Exclude_tables.md
Define ignored tables in alembic.ini

Add this in your ini file:

[alembic:exclude]
tables = spatial_ref_sys

In env.py:

def exclude_tables_from_config(config_):
    tables_ = config_.get("tables", None)

if tables_ is not None:

@getadeo
getadeo / gist:b6a89bb90b5e8a01e21e
Created December 7, 2015 10:23 — forked from hest/gist:8798884
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
import paramiko
k = paramiko.RSAKey.from_private_key_file("/Users/whatever/Downloads/mykey.pem")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print "connecting"
c.connect( hostname = "www.acme.com", username = "ubuntu", pkey = k )
print "connected"
commands = [ "/home/ubuntu/firstscript.sh", "/home/ubuntu/secondscript.sh" ]
for command in commands:
print "Executing {}".format( command )
$ python3 -c 'from unicodedata import name; print("\n".join("{} {}".format(name(chr(c)),chr(c)) for c in (0x2695,0x2698,0x269A)))'