Navigation Menu

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 / PrivateTorrent.md
Created March 12, 2021 01:40 — forked from sourcec0de/PrivateTorrent.md
Host a private torrent tracker, and seed a torrent on ubuntu 12.10

Install dep, and start tracker

sudo apt-get install bittornado ctorrent
bttrack --port 6969 --dfile ~/.bttrack/dstate --logfile ~/.bttrack/tracker.log --nat_check 0 --scrape_allowed full

Now, create a torrent file

ctorrent -t -u "YOUR_SERVER_IP:6969/announce" -s new_file_name.torrent file_or_folder_for_torrent
@jhargis
jhargis / plot.awk
Created October 19, 2020 19:04 — forked from katef/plot.awk
#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average
#! /usr/bin/env python3
'''pyCookieCheat.py
2015022 Now its own GitHub repo, and in PyPi.
- For most recent version: https://github.com/n8henrie/pycookiecheat
- This gist unlikely to be maintained further for that reason.
20150221 v2.0.1: Now should find cookies for base domain and all subs.
20140518 v2.0: Now works with Chrome's new encrypted cookies.
See relevant post at http://n8h.me/HufI1w
@jhargis
jhargis / postgres_queries_and_commands.sql
Created August 9, 2019 17:42 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@jhargis
jhargis / remove_table_bloat_async_with_inheritance.md
Last active August 24, 2018 19:35 — forked from mage2k/gist:747674bb8a1a970007952adc283a857c
Trick for removing table bloat without requiring a full table lock and production halt

Given a table bar that we need to compact while maximizing availability of the data in it and minimize load/IO during compaction.

First, if there are any tables with foriegn key columns referencing columns in bar those foreign keys need to be disabled, e.g:

ALTER TABLE foo DISABLE TRIGGER fkey_bar_id

Now we can work on compacting the data by copying it to a new table.

SQL to create a new, empty table and have the current table inherit from it:

@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 / 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 / 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 / imagewiththumbnails_updateable.py
Last active August 29, 2015 14:27 — forked from valberg/imagewiththumbnails_updateable.py
Django create thumbnail form ImageField and save in a different ImageField - now with updating!
# Extension of http://www.yilmazhuseyin.com/blog/dev/create-thumbnails-imagefield-django/
# Note: image_folder and thumbnail_folder are both a callable (ie. a lambda that does a '/'.join())
class Image(Media):
image = models.ImageField(
upload_to=image_folder
)
thumbnail = models.ImageField(