Skip to content

Instantly share code, notes, and snippets.

View jstarrdewar's full-sized avatar

John Starr Dewar jstarrdewar

View GitHub Profile
@jstarrdewar
jstarrdewar / machine.js
Last active March 17, 2020 07:19
Generated by XState Viz: https://xstate.js.org/viz
const history = [];
const appMachine = Machine({
id: 'App',
initial: 'Off',
states: {
Off: {
on: {
Start: 'CheckKillSwitch',
}
@jstarrdewar
jstarrdewar / .gitignore
Created July 26, 2018 17:51
My standard .gitignore for Unity projects
TPS_cache/
ignore.conf
.plastic/
*.csproj
*.sln
.vs/
*.DotSettings
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
@jstarrdewar
jstarrdewar / .gitattributes
Created July 26, 2018 17:49
My standard .gitattributes for Unity projects
# Disable EOL conversions by default
* -text
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge
@jstarrdewar
jstarrdewar / .gitattributes
Created July 26, 2018 17:47
My standard .gitattributes for UE4 projects
# Unreal Engine file types.
*.uasset filter=lfs diff=lfs merge=lfs -text
*.umap filter=lfs diff=lfs merge=lfs -text
# Raw Content file types.
*.fbx filter=lfs diff=lfs merge=lfs -text
*.3ds filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.mp3 filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
@jstarrdewar
jstarrdewar / .gitignore
Created July 26, 2018 17:45
My standard .gitignore file for UE4
# Ignore all files by default, but scan all directories.
*
!*/
# Do not ignore git files in the root of the repo.
!/.git*
# Do not ignore current project's `.uproject`.
!/*.uproject
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="google" content="notranslate" />
<meta http-equiv="Content-Language" content="en_US" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<link rel="shortcut icon" href="favicon.ico">
<title>My Website</title>
@jstarrdewar
jstarrdewar / http
Created September 30, 2012 00:36
Convenient way to launch WEBrick to serve the current directory and prevent caching.
#!/usr/bin/env ruby
require 'webrick'
class NonCachingFileHandler < WEBrick::HTTPServlet::FileHandler
def prevent_caching(res)
res['ETag'] = nil
res['Last-Modified'] = Time.now + 100**4
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
res['Pragma'] = 'no-cache'
res['Expires'] = Time.now - 100**4
@jstarrdewar
jstarrdewar / fbapi_injection.js
Created March 8, 2012 07:46
Inject Facebook API
/**
* Inject the Facebook API into the page if it hasn't already been loaded. Init if it hasn't already been
* initialized. Dispatch 'jsd:facebook-api-loaded' event on completion.
*/
function loadFacebookAPI() {
if (!window.FB) {
console.log('loading facebook api');
@jstarrdewar
jstarrdewar / focus_event.html
Created February 8, 2012 20:13
Event handler for jQuery.focus() that avoids sudden deselection in browsers like Safari
<!-- simple HTML to test focus handler with -->
<input id="example" type="text" value="Select Me"/>
@jstarrdewar
jstarrdewar / limit_textarea_length.js
Created February 5, 2012 04:50
Limit the length of a textarea tag with a little bit of jQuery.
/**
* @author John Starr Dewar
*/
var textarea = $('textarea')[0];
var $counter = $('#counter');
var limit = 140;
$(textarea).keydown(function(event) {
switch (event.keyCode) {
case 8: