Skip to content

Instantly share code, notes, and snippets.

View drbh's full-sized avatar
🕳️
a for AI

drbh drbh

🕳️
a for AI
  • drbh
  • state space
  • 14:47 (UTC -04:00)
View GitHub Profile
@drbh
drbh / change-iterm-background-color.sh
Last active November 9, 2023 10:17
Programmatically change the background color of iTerm - or set it randomly
set_term_bgcolor(){
local R=$1
local G=$2
local B=$3
/usr/bin/osascript <<EOF
tell application "iTerm"
tell current session of current window
set background color to {$(echo "scale=2; ($1/255.0)*65535" | bc),$(echo "scale=2; ($2/255.0)*65535" | bc),$(echo "scale=2; ($3/255.0)*65535" | bc)}
end tell
end tell
@drbh
drbh / autoconnect.sh
Created November 16, 2017 18:03
A CLI app that makes it easy to SSH into a EC2 instance
#!/bin/bash
# Ask the user for their name
echo 'Hello, I will help you connect to your EC2 instance.
You will need 3 pieces of information:
Username
Host Address
Path to key file\n\n'
read -n 1 -s -r -p "[Press any key to continue]"
@drbh
drbh / install_ipython_rstudio.sh
Created November 16, 2017 18:22
Install Python2.7 and Rstudio-server on Ubuntu 16.04
#!/bin/bash
sudo apt-get update
sudo apt -y install python-pip
sudo -H pip install --upgrade pip
sudo apt-get -y install python2.7 python-pip python-dev
sudo apt-get -y install ipython ipython-notebook
sudo -H pip install jupyter
sudo echo "deb http://cran.rstudio.com/bin/linux/ubuntu xenial/" | sudo tee -a /etc/apt/sources.list
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
@drbh
drbh / forward_two_ports.sh
Last active November 16, 2017 21:44
Easily SSH into an instance and forward two ports to allow access on your local machine
#!/bin/bash
# Ask the user for their name
echo 'Hello, I will help you connect to your EC2 instance.
You will need 3 pieces of information:
Username
Host Address
Path to key file\n\n'
read -n 1 -s -r -p "[Press any key to continue]"
@drbh
drbh / import_test_csv.R
Created November 16, 2017 22:05
import a csv file and store as a Dataframe in R
getwd()
df <- read.csv("test.csv")
python -c 'import datetime;print "Week: %s" % datetime.date.today().isocalendar()[1]'
@drbh
drbh / server.js
Created March 26, 2018 02:51
server for iMessage analyzer app
// server.js
var express = require("express");
var app = express();
var main = require("./node-main.js")
var bodyParser = r equire('body-parser')
app.use(bodyParser.json()); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
@drbh
drbh / main.js
Created March 26, 2018 02:52
electron script for iMessage analyzer app
// main.js
const rq = require('request-promise');
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const child = require('child_process')
var mainWindow = null;
app.on('window-all-closed', function() {
@drbh
drbh / node-main.js
Created March 26, 2018 02:54
data graber - db interactions for iMessage analyzer app
// node-main.js
const sqlite3 = require('sqlite3')
const util = require('util')
const exec = require('child_process').exec
class DataGrabber {
constructor() {
this.OSX_EPOCH = 978307200
this.messages = []
const { exec } = require('child_process');
@drbh
drbh / DataGrabber.py
Created March 26, 2018 03:34
Extract that pesky iMessages data
import os
import sys
import sqlite3
import datetime
USERNAME = os.popen('whoami').read().strip()
class DataGrabber(object):
"""docstring for ClassName"""
def __init__(self):