Skip to content

Instantly share code, notes, and snippets.

View jhargis's full-sized avatar

Jay Hargis jhargis

  • Heroku
  • Portland, OR
View GitHub Profile
@jhargis
jhargis / .screenrc
Created February 26, 2018 23:43
.screenrc
caption string "%?%F%{= Bk}%? %C%A %D %d-%m-%Y %{= kB} %t%= %?%F%{= Bk}%:%{= wk}%? %n "
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'
@jhargis
jhargis / sig.py
Created October 26, 2017 23:57
simple signal handler example
import sys
import signal
# custom signal handler
def signal_handler(signal, frame):
print 'Interrupt caught. Exiting.'
sys.exit(0)
# register
signal.signal(signal.SIGINT, signal_handler)
@jhargis
jhargis / sierra-virtualbox-install.md
Created March 29, 2017 02:06 — forked from arobb/sierra-virtualbox-install.md
Install macOS Sierra in VirtualBox on macOS host

Step 1 (Creating a bootable macOS Sierra ISO for VirtualBox):

  1. hdiutil attach /Applications/Install\ macOS\ Sierra\ Public\ Beta.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
  2. hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
  3. hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
  4. asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
  5. rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
  6. cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
  7. cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
@jhargis
jhargis / youtubedl.mp3.sh
Created March 22, 2017 19:01 — forked from rugbyprof/youtubedl.mp3.sh
youtube dl as mp3
youtube-dl --extract-audio --audio-format mp3 <video URL>
youtube-dl -i "<Youtube URL>" -o "%(title)s.%(ext)s" --extract-audio --audio-format "mp3" --audio-quality "192k"
@jhargis
jhargis / README.md
Last active February 15, 2017 03:09
letsencrypt certbot nginx easy setup and renewals

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@jhargis
jhargis / supervisor.conf
Created August 30, 2016 22:52 — forked from tsabat/supervisor.conf
Sample supervisor config file
; Sample supervisor config file.
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default
@jhargis
jhargis / encryptpw.pl
Created August 29, 2013 04:33
generate an htpasswd with perl script
#!/usr/bin/env perl
if ($#ARGV < 1) {
die("Usage:\tUsername Password\n")
}
my $username = shift;
my $newpass = shift;
my $new_entry;
my @entry = split(':', $_);
@jhargis
jhargis / rdio_pl_export.js
Created November 20, 2015 01:20 — forked from nloko/rdio_pl_export.js
Export Rdio playlist as CSV
javascript:(function() {
var bookmarklet = {
init: function() {
this.parse();
},
parse: function() {
page = "";
/* you must be viewing songs ie. http://www.rdio.com/people/nloko/collection/songs/
when exporting a collection and this will only export the songs loaded in view,
@jhargis
jhargis / node-and-npm-in-30-seconds.sh
Created July 18, 2012 18:45 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@jhargis
jhargis / install.sh
Created June 22, 2012 01:40 — forked from crofty/install.sh
Redis install for ubuntu 8.04 without upstart
# Redis install instructions for systems without upstart
mkdir ~/redis
cd ~/redis
wget --no-check-certificate http://github.com/antirez/redis/tarball/v2.0.0-rc4 -O redis_v2.0.0-rc4.tar.gz && tar --strip-components 1 -xzvf redis_v2.0.0-rc4.tar.gz
make
sudo mv redis-server /usr/local/bin/
sudo mv redis-cli /usr/local/bin/
sudo mv redis-benchmark /usr/local/bin/
sudo mv redis-check-dump /usr/local/bin/
sudo mkdir /var/lib/redis