Skip to content

Instantly share code, notes, and snippets.

Avatar
🚮
bad command or file name

Tim Ryan tcr

🚮
bad command or file name
View GitHub Profile
@tcr
tcr / code.js
Created Oct 26, 2011
How can you use Mustache with Node.js?
View code.js
var express = require('express');
var app = module.exports = express.createServer();
// Configuration
app.configure(function(){
app.set('view engine', 'mustache');
app.set('views', __dirname + '/views');
app.register(".mustache", require('stache'));
@tcr
tcr / mpcadet.py
Last active Aug 24, 2020
Monoprice Cadet Wifi-only Upload Script in Python
View mpcadet.py
# MonoPrice Cadet script for uploading .gcode files
# and listing the contents of the SD card
#
# Usage: python mpcadet.py 192.168.1.X
#
# Uploads the local CADET.gcode file in the same directory
# as your script to the device and then kicks off a build.
#
# A limited number of GCODE commands seem possible:
# https://marlinfw.org/docs/gcode/M023.html
View generated_typescript.ts
// Type output by wasm-bindgen to the .d.ts bindings. No JS code is generated, just type definitions
export type ControllerCommand =
| { "Keypress": { key_code: number, meta_key: boolean, shift_key: boolean, alt_key: boolean, } }
| { "Button": { button: number, } }
| { "Character": { char_code: number, } }
| { "InsertText": { text: string, } }
| { "RenameGroup": { tag: string, curspan: any, } }
| { "Cursor": { focus: any, anchor: any, } }
| { "RandomTarget": { position: number, } }
@tcr
tcr / sprite
Created Jul 9, 2018
8bitworkshop.com {"platform":"vcs"}
View sprite
processor 6502
include "vcs.h"
include "macro.h"
org $f000
; Sprites are a tricky beast on the 2600.
; You only have two of them.
; They are 8 bits wide and 1 bit high.
; There's no way to position the X or Y coordinate directly.
View serde_with_option_skip.rs
#![allow(unused)]
extern crate ron;
extern crate serde;
#[macro_use] extern crate serde_derive;
extern crate serde_with;
use serde::{Deserialize, Serialize, Serializer, Deserializer};
#[derive(Serialize, Deserialize)]
@tcr
tcr / rouille_with_juniper.rs
Created May 3, 2018
rouille_with_juniper.rs
View rouille_with_juniper.rs
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [dependencies]
//! juniper = "*"
//! rouille = "*"
//! serde_json = "*"
//! serde = "*"
//! ```
#[macro_use] extern crate rouille;
View gist:4083162f7fe82b6fea47fa8775125a02
make an itunes backup
Go to `~/Library/Application Support/MobileSync/Backup`
Find the backup id folder
Look up `Manifest.db` in that dir to identify Files row with `relativePath=Library/SpringBoard/IconState.plist` and its `fileID`
in the `<backup_id>/<first two digits>/<that hash>` file, run
View typescript-2.8-taggedish-unions.ts
// Declare your union variants
// Easy to name variant contructors + define tags in one place
function Age(age: number) {
return { tag: 'Age' as 'Age', age }
}
function Name(name: string) {
return { tag: 'Name' as 'Name', name }
}
@tcr
tcr / code.css
Created Oct 28, 2011
What's a way to support "white-space: pre-wrap" (significant whitespace, but lines still break) across all browsers?
View code.css
element {
white-space: pre; word-wrap: break-word; /* Internet Explorer 5.5+ */
white-space: pre-wrap; /* CSS3*/
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
}
@tcr
tcr / gist:4416956
Last active Nov 29, 2017
Make a callable() object in all browsers and Node.js
View gist:4416956
if (!Object.__proto__) {
var sandbox = function () {
// create an <iframe>
var iframe = document.createElement("iframe");
iframe.style.display = "none";
document.documentElement.appendChild(iframe);
return frames[frames.length - 1];
}
var iframe = sandbox();
You can’t perform that action at this time.