Skip to content

Instantly share code, notes, and snippets.

View JoshMock's full-sized avatar

Josh Mock JoshMock

View GitHub Profile
@JoshMock
JoshMock / .vimrc
Created November 4, 2010 00:21
Vim settings
" Pathogen settings to auto-load new plugins (http://www.vim.org/scripts/script.php?script_id=2332)
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
filetype plugin indent on
"Enable filetypes
filetype on
filetype plugin on
filetype indent on
@JoshMock
JoshMock / app.js
Created November 16, 2010 05:29
Sample Titanium App - Wikipedia search
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create base UI tab and root window
var window = Titanium.UI.createWindow({
title:'Search',
backgroundColor:'#fff'
});
var textfield = Titanium.UI.createTextField({
@JoshMock
JoshMock / .babelrc
Last active December 2, 2015 16:45
Webpack + ES6 + JSX using Babel 6
{
"presets": ["es2015", "react"],
"ignore": ["node_modules"]
}
@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 / gist:5527082
Created May 6, 2013 18:32
Ana Sia Moogfest 2012 setlist
Julio Bashmore - Au Seve
Ill Blue - 2nd Nature
Midland - Placement (Lone Remix)
Grenier - RDY4U
Joy Orbison & Boddika - Dun Dun
Portishead - Machinegun (Jimmy Edgar Edit)
Grenier - DTF (ft Salva)
Astronomar - Sword Fight (Kid Kamillion Edit)
Mike Q - Let It All Out
the Goonies - Africa
@JoshMock
JoshMock / moveshit
Created July 11, 2013 01:17
Move windows around in AppleScript
try
tell application "Google Chrome"
set the bounds of the second window to {-1400, 0, -100, 900}
set the bounds of the first window to {100, 0, 1500, 2000}
end tell
end try
try
tell application "Mail"
set the bounds of the first window to {-1400, 0, -100, 900}
@JoshMock
JoshMock / backbone-socket-event-server.js
Created November 27, 2013 17:57
Fire Backbone model/collection events via websockets using Socket.io. Client code depends on RequireJS for AMD and Cocktail (https://github.com/onsi/cocktail) to apply websocket functionality as a mixin. Assumes views are listening to model/collection changes and updating the DOM accordingly. Some cruft may be specific to the project I'm working…
module.exports = function (io) {
"use strict";
// set up websockets
io.sockets.on('connection', function (socket) {
var eventTypes = [
'Backbone.Model.change',
'Backbone.Collection.add',
'Backbone.Collection.remove',
'Backbone.Collection.sort'
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
})
};
@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 / 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];
}