Skip to content

Instantly share code, notes, and snippets.

View TehShrike's full-sized avatar
🕺
Groovy.

Josh Duff TehShrike

🕺
Groovy.
View GitHub Profile
@TehShrike
TehShrike / company-autocomplete.json
Created February 10, 2016 17:15
Autocomplete indexes
{
"mappings": {
"company": {
"properties": {
"companyId": {
"type": "long"
},
"ngramName": {
"type": "string",
"index": "analyzed",
@TehShrike
TehShrike / package.json
Created February 2, 2016 03:37
Browserify package.json babelify transform
{
"browserify": {
"transform": [
[
"babelify",
{
"presets": "es2015"
}
]
]
@TehShrike
TehShrike / angry gm
Created August 14, 2015 13:59
Angry GM fix bookmarklet
javascript:Array.prototype.forEach.call(document.getElementsByTagName('p'), function(elem) {elem.innerText = elem.innerText.replace(/a[!@#$%^&*]{2}/g, 'ass').replace(/f[!@#$%^&*]{3}/g, 'fuck').replace(/s[!@#$%^&*]{3}/g, 'shit')})
@TehShrike
TehShrike / nginx.conf
Created July 22, 2015 22:33
nginx conf with port forwarding and socket.io
# /etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
@TehShrike
TehShrike / autoexec.sh
Created July 22, 2015 22:31
psy autoexec.sh
echo "Launching autoexec stuff"
/opt/iojs/bin/node /opt/iojs/bin/psy daemon --pidfile=/opt/autoexec/psy.pid -l /opt/autoexec/psy.log
cd /opt/communal-checklist
/opt/iojs/bin/node /opt/iojs/bin/psy start -n communalchecklist.com --cwd=/opt/communal-checklist --env.PORT=8001 -l communalchecklist.log -- npm run start
nginx
@TehShrike
TehShrike / etc init.d autoexec
Created July 11, 2015 20:46
Getting things to run on startup on linux with init.d
#!/bin/sh
### BEGIN INIT INFO
# Provides: autoexec
# Required-Start: $remote_fs $syslog networking procps
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Autoexec Starting
# Description: Enable autoexec
### END INIT INFO
@TehShrike
TehShrike / on-one-line.js
Last active September 16, 2017 16:16
Gimme the ASIN
javascript:(function() {
function getFromUrl(url) {
return url.match(RegExp("https?://www.amazon.com/([\\w-]+/)?(dp|gp/product)/(\\w+/)?(\\w{10})"))[4]
}
document.body.innerHTML = '<h1>::asin|' + getFromUrl(Array.prototype.slice.apply(document.getElementsByTagName('link')).filter(function(element) { return element.attributes.getNamedItem('rel').value === 'canonical' })[0].href) + '|Title::</h1>'
})()
@TehShrike
TehShrike / .bash_profile
Last active April 10, 2019 16:48
.bash_profile gives me pretty colors and git and node shortcuts
source /Users/josh/scripts/git-completion.bash
C_DEFAULT="\[\033[m\]"
C_WHITE="\[\033[1m\]"
C_BLACK="\[\033[30m\]"
C_RED="\[\033[31m\]"
C_GREEN="\[\033[32m\]"
C_YELLOW="\[\033[33m\]"
C_BLUE="\[\033[34m\]"
C_PURPLE="\[\033[35m\]"
@TehShrike
TehShrike / row-to-objects
Created November 8, 2014 23:20
Parsing multiple objects from a single row
function getNames(key) {
var parts = key.split('_')
return {
type: parts.shift(),
property: parts.join('')
}
}
function rowToObjects(obj) {
@TehShrike
TehShrike / escape.js
Last active August 29, 2015 14:05
JS quine
function escape(str) {
return str.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, "\\n")
}
console.log(escape(require('fs').readFileSync('index.js', { encoding: 'utf8' })))