Skip to content

Instantly share code, notes, and snippets.

View graphaelli's full-sized avatar

Gil Raphaelli graphaelli

  • Philadelphia, PA
  • 01:42 (UTC -05:00)
View GitHub Profile
#!/usr/bin/env python
import importlib
import sys
def actions(module):
mod = importlib.import_module(module)
for attrib in dir(mod):
@graphaelli
graphaelli / Dockerfile
Last active May 14, 2017 04:25
firefox in ubuntu 16.04 docker container on mac osx
FROM ubuntu:16.04
# based on http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
RUN apt-get update && apt-get install -y firefox
RUN useradd -u 501 -m developer
USER developer
ENV HOME /home/developer
CMD /usr/bin/firefox
@graphaelli
graphaelli / git-rebase-all.py
Last active April 27, 2017 17:25
rebase all branches with branch
#!/usr/bin/env python
import argparse
import os
import subprocess
import sys
def rebase(base, branch, abort=True):
try:
@graphaelli
graphaelli / quote_list.py
Created April 26, 2017 16:42
quote a list of inputs, mostly for use in sql queries
#!/usr/bin/env python
from io import StringIO
import argparse
import sys
import unittest
def quote_list(r, sep=None):
# hope r is smallish
@graphaelli
graphaelli / batch-update.sql
Created April 19, 2017 22:44
batch postgresql updates with a CTE
-- based on https://news.ycombinator.com/item?id=9018756
=# select *, 'foo'::text into test from generate_series(1,5) as id;
SELECT 5
Time: 77.975 ms
=# select * from test;
┌────┬──────┐
│ id │ text
├────┼──────┤
1 │ foo │
2 │ foo │
@graphaelli
graphaelli / test_pg_conn_mock.py
Created December 9, 2016 03:55
test pg connection mock
#!/usr/bin/env python
from __future__ import print_function
try:
import mock
except ImportError:
from unittest import mock
import unittest
@graphaelli
graphaelli / scp.terminal
Last active November 25, 2017 15:19
Mac OSX Terminal Settings
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlueColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECcw
LjE0OTAxOTYwNzggMC40OTQxMTc2NDcxIDAuOTEzNzI1NDkwMgAQAYAC0hAREhNaJGNs
YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
@graphaelli
graphaelli / gist:dd75bc730a7eafd25fe99c2d6a17ed5f
Created April 11, 2016 01:10 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
#!/usr/bin/env python
import fileinput
import urllib.parse
urllib.parse.uses_netloc.append("postgres")
dsn = next(fileinput.input()).strip()
url = urllib.parse.urlparse(dsn)
@graphaelli
graphaelli / Dockerfile
Last active October 5, 2020 20:46
Caffe with Python3 on Centos 7
FROM centos:7
MAINTAINER graphaelli "http://g.raphaelli.com/2016/01/04/centos-python3-caffe.html"
RUN yum -y update && yum clean all
# python3 deps
RUN yum -y groupinstall 'Development Tools'
RUN yum -y install bzip2-devel db4-devel gdbm-devel libpcap-devel ncurses-devel openssl-devel readline-devel sqlite-devel xz-devel zlib-devel
# jupyter deps
RUN yum -y install epel-release
RUN yum -y install blas-devel freetype-devel gcc gcc-c++ gcc-fortran git hdf5-devel lapack-devel libjpeg-turbo-devel libpng-devel make opencv-devel patch readline-devel zeromq-devel