Skip to content

Instantly share code, notes, and snippets.

View jdowner's full-sized avatar

Joshua Downer jdowner

View GitHub Profile
@jdowner
jdowner / sqlite2yaml.py
Last active November 14, 2023 13:23
Print a sqlite database file as YAML
#!/usr/bin/env python2
import argparse
import sys
import sqlalchemy
import yaml
def sqlite2yaml(filename):
@jdowner
jdowner / input.py
Last active September 9, 2022 15:33
asyncio timed input
#!/usr/bin/env python3
"""
The MIT License (MIT)
Copyright (c) 2016 Joshua Downer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
@jdowner
jdowner / sendmail.py
Created January 23, 2015 16:54
How to send email using python
#!/usr/bin/env python
import email.mime.text
import smtplib
username = 'foo@example.com'
password = '****************'
hostname = 'outlook.office365.com'
msg = email.mime.text.MIMEText('test')
"""Disk And Execution MONitor (Daemon)
Configurable daemon behaviors:
1.) The current working directory set to the "/" directory.
2.) The current file creation mode mask set to 0.
3.) Close all open files (1024).
4.) Redirect standard I/O streams to "/dev/null".
A failed call to fork() now raises an exception.
@jdowner
jdowner / example.qml
Last active June 2, 2021 18:34
How to pass a Qml Component as a signal parameter.
import QtQuick 1.0
Rectangle {
height: 300
width: 400
color: "gray"
// This text element is for visual feedback when the signal fires
Text {
text: "(empty)"
@jdowner
jdowner / unparse.py
Created January 15, 2017 10:23
python ast unparse
"Usage: unparse.py <path to source file>"
import sys
import ast
import cStringIO
import os
# Large float and imaginary literals get turned into infinities in the AST.
# We unparse those infinities to INFSTR.
INFSTR = "1e" + repr(sys.float_info.max_10_exp + 1)
@jdowner
jdowner / vim-build.sh
Last active November 13, 2018 09:32
vim-build
#!/bin/bash
PREFIX=${HOME}/usr/local
VIMRUNTIMEDIR=${PREFIX}/share/vim/vim80/
./configure --with-features=huge \
--enable-multibyte \
--enable-python3interp=yes \
--with-python3-config-dir=/usr/lib/python3.5/config \
--enable-cscope \
@jdowner
jdowner / Description.md
Created August 15, 2018 13:44 — forked from juanje/Description.md
Limit Chrome from eating all the memory and CPU

I was tired of Chrome eating all my laptop resources so I decided to put some limit to it with cgroup.

As I was using Ubuntu 12.04 with support for cgroup, I installed the package cgroup-bin and add the following group to the file /etc/cgconfig.conf:

group browsers {
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
 }
@jdowner
jdowner / requirements.txt
Created December 24, 2017 11:31
url to text
docopt
readability-lxml
@jdowner
jdowner / file1.txt
Created December 29, 2016 15:45
gpg public key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
mQINBFR1MNYBEACwF+IeDIXvKOWRHQrnuUD/OwEitWG1FgDJAe4M247pt0dkMhAP
SC14oXN57iDkjZ27W6YngSZyLDZLTvFOs4pzsSr80DB42NJo+K/TSHhtLx191O8b
gYBWERDXkBsd4lEwpWUsvc2gmJ+GrX2mQXejgDN1wbqECXi8nlGWztBOQVCXqid/
5nNWtOu/Hvr4MtxrOzyx7dmvz0A/tkpJ7m5K2gnxcEn9gxtjbgNOwsd/3yw36F7K
4YpSCMfx343xwieEmgfwncBI8uYBzOVHLcT2Ho6n+1RV8L3qMj33dNZiQ2T+u1uv
V+cvHRt9kqq+/o3LYkODNsBzVg8kJagZgiScWPqGFwxmS8+tiqfZeyYbWLPllG0N
5Dzo4Obx6PlO7FFyBpi18zIbmiykClUJysVIunNEG+Hb8/wE7vVjccG0SleWF8zJ