Skip to content

Instantly share code, notes, and snippets.

View JoshMock's full-sized avatar

Josh Mock JoshMock

View GitHub Profile
@JoshMock
JoshMock / autoclose.py
Created August 16, 2021 18:21
Quitter clone for Linux
#!/usr/bin/env python3
# Linux-compatible clone of Quitter for Mac https://marco.org/apps#quitter
# implementation inspired by: https://github.com/acenturyandabit/mini-miza/blob/master/autohide.py
import subprocess
import time
import os
apps = {
@JoshMock
JoshMock / albums.md
Created January 2, 2020 17:19
My favorite albums of the 2010s
  • A$AP Ferg: Trap Lord
  • Aldous Harding: Designer
  • Angel Olsen: MY WOMAN
  • Antony & the Johnsons: Cut the World
  • Arcade Fire: The Suburbs
  • Arranged Marriage NP: Arranged Marriage NP
  • Astronoid: Air
  • Atoms for Peace: AMOK
  • Beach House: Bloom
  • Beach House: Teen Dream
@JoshMock
JoshMock / restful-http-method-cheat-sheet.md
Last active July 10, 2023 03:28
RESTful HTTP method cheat sheet

GET

  • fetch entity data only
  • does not alter any data, ever

POST

  • create a new entity with the data values provided in the body
  • if an entity already exists with these values, create it anyway (read: non-idempotent)
  • should not be used to alter an existing entity
@JoshMock
JoshMock / README.md
Last active December 7, 2015 20:59
How to generate random tweet strings using your Twitter archive
  1. Log into Twitter and go to your settings
  2. Request your Twitter archive
  3. Download and unzip the archive file
  4. Put tweets.csv in the same directory as this gist's package.json and markov-tweets.js files
  5. Run npm install to install dependencies
  6. Run node markov-tweets.js to generate some strings!

Running the script may take a few seconds depending on the size of your archive CSV. When it's done it will log out 20 random strings based on the Markov chain generated.

@JoshMock
JoshMock / .babelrc
Last active December 2, 2015 16:45
Webpack + ES6 + JSX using Babel 6
{
"presets": ["es2015", "react"],
"ignore": ["node_modules"]
}
@JoshMock
JoshMock / index.html
Last active July 9, 2016 10:51
Infinite scrolling CompositeView
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css" media="all">
#main {
width: 300px;
height: 400px;
overflow: scroll;
}
@JoshMock
JoshMock / startup_mailer
Created October 27, 2014 15:21
Get an informative email when your Raspberry Pi starts up
#!/usr/bin/python
# put this in in a file in your Pi's /etc/init.d/ directory
import urllib2
import subprocess
import smtplib
from email.mime.text import MIMEText
import datetime
(defn calc-height-step [height current-step]
(if (= 1 (mod current-step 2))
(* height 2)
(+ height 1)))
(defn calc-height []
(def steps (Integer/parseInt (read-line)))
(println (reduce calc-height-step 1 (range 1 (+ steps 1)))))
(def t (Integer/parseInt (read-line)))
@JoshMock
JoshMock / username.js
Created June 6, 2014 16:31
Get process's username
function getUsername () {
var homeDir = process.env['HOME'].split('/');
return homeDir[homeDir.length - 1];
}
@JoshMock
JoshMock / unused_functions.sh
Created April 16, 2014 18:52
Unused functions
# A terrible attempt at listing function names that appear to not be used. Lots
# of false positives, especially for functions whose names are used as
# callbacks into other functions.
codepath=/path/to/javascript
tmpfile=/tmp/allfunctions
tmpfile2=/tmp/filteredfunctions
# search for function names
ack --type=js --output='$1' -h "(\w{3,})\:\s*function" $codepath > $tmpfile