Skip to content

Instantly share code, notes, and snippets.

Josh Mock JoshMock

Block or report user

Report or block JoshMock

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JoshMock
JoshMock / restful-http-method-cheat-sheet.md
Last active Nov 29, 2017
RESTful HTTP method cheat sheet
View restful-http-method-cheat-sheet.md

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 Dec 7, 2015
How to generate random tweet strings using your Twitter archive
View README.md
  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 Dec 2, 2015
Webpack + ES6 + JSX using Babel 6
View .babelrc
{
"presets": ["es2015", "react"],
"ignore": ["node_modules"]
}
@JoshMock
JoshMock / index.html
Last active Jul 9, 2016
Infinite scrolling CompositeView
View index.html
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css" media="all">
#main {
width: 300px;
height: 400px;
overflow: scroll;
}
@JoshMock
JoshMock / startup_mailer
Created Oct 27, 2014
Get an informative email when your Raspberry Pi starts up
View startup_mailer
#!/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
View utopian-tree.clj
(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 Jun 6, 2014
Get process's username
View username.js
function getUsername () {
var homeDir = process.env['HOME'].split('/');
return homeDir[homeDir.length - 1];
}
View unused_functions.sh
# 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
View gist:9842601
### Keybase proof
I hereby claim:
* I am joshmock on github.
* I am joshmock (https://keybase.io/joshmock) on keybase.
* I have a public key whose fingerprint is 7DE2 6FB1 0244 C3B7 5796 6A96 A0D0 224E 2C14 6AE2
To claim this, I am signing this object:
View gist:7935786
function myFn1 (arg1) {
var var1 = doSomethingWith(arg1), // set breakpoint here
var2 = doSomethingElseWith(var1);
_.each([1, 2, 3], function (val) {
doAnotherThingWth(var2); // var2 is still available in dev tools here, but var1 is not
})
};
You can’t perform that action at this time.