Skip to content

Instantly share code, notes, and snippets.

View gingerbeardman's full-sized avatar

Matt Sephton gingerbeardman

View GitHub Profile
@neauoire
neauoire / gist:e8f189af4c8ab7743001
Last active August 29, 2015 14:26
Pico8 Tunnel
-- GEODEZIK
-- BY ALICEFFEKT
frame = 0
function _update()
frame += 1
-- loop at f127
@christianp
christianp / scrabble.py
Created September 24, 2012 18:04
Which words have unique Scrabble scores? What's the most common score? And if you replace letters with their points values, which string is most common?
alphabet = 'abcdefghijklmnopqrstuvwxyz'
tiles = {'a': 9, 'c': 2, 'b': 2, 'e': 12, 'd': 4, 'g': 3, 'f': 2, 'i': 9, 'h': 2, 'k': 1, 'j': 1, 'm': 2, 'l': 4, 'o': 8, 'n': 6, 'q': 1, 'p': 2, 's': 4, 'r': 6, 'u': 4, 't': 6, 'w': 2, 'v': 2, 'y': 2, 'x': 1, 'z': 1}
points = {'a': 1, 'c': 3, 'b': 3, 'e': 1, 'd': 2, 'g': 2, 'f': 4, 'i': 1, 'h': 4, 'k': 5, 'j': 8, 'm': 3, 'l': 1, 'o': 1, 'n': 1, 'q': 10, 'p': 3, 's': 1, 'r': 1, 'u': 1, 't': 1, 'w': 4, 'v': 4, 'y': 4, 'x': 8, 'z': 10}
# I downloaded the "complete word list" from http://www.scrabblejunction.org/wordlists.htm
words = open('TWL_2006_ALPHA.txt').read().split('\n')
#convert every word to lower-case
words = [word.lower() for word in words]
#decide if a word is playable
@rhysforyou
rhysforyou / gist:8e396099831aa44086af
Last active August 19, 2017 17:07
Ripping PS1 Games on OS X

Note: This method doesn't work for multitrack game disks that I've tried, such as those that include audio files on separate tracks like Vib Ribbon.

Also don't go using this method to distribute copies of PS1 games on the internet. That's super illegal and uncool.

  1. Insert the game disk, wait for it to mount
  2. Open Disk Utility, right click the game disk, and choose Unmount
  3. Open Terminal and run diskutil list, make note of where the game disk was mounted (something like /dev/disk3)
  4. Run sudo dd if=<disk> of=foo.iso where <disk> is the mount point we got in the last step (you can call the ISO whatever you want)
  5. Download LiquidCD and extract it
  6. Open LiquidCD, go to the Others tab, and then click Choose a disk image… supplying the disk image you made last step, if asked, let it analyse the tracks in that ISO
@chriskrycho
chriskrycho / github-typography.css
Created January 30, 2018 16:35
Better typography on GitHub
.markdown-body {
font-family: Avenir Next
}
pre,
code,
tt,
kbd:not(.badmono),
pre,
samp,
.blob-code,
@eguneys
eguneys / gesture.js
Created August 31, 2014 11:37
A Gesture Manager for Phaser.
'use strict';
define(['phaser'], function(Phaser) {
function Gesture(game) {
this.game = game;
this.swipeDispatched = false;
this.holdDispatched = false;
this.isTouching = false;
@pudquick
pudquick / lowrez.py
Created November 8, 2016 21:57
Enable the "Open in Low Resolution" setting for an arbitrary application in macOS
#!/usr/bin/python
# Some notes about using this script:
# - Configure the application path and bundle id below
# - This script needs to be run as the user you need to set the checkmark for
# - The setting will not take effect until they log out and log back in at least once
import os.path
from Foundation import NSHomeDirectory, CFPreferencesCopyMultiple, CFPreferencesSetMultiple, kCFPreferencesAnyUser, kCFPreferencesCurrentHost, NSMutableDictionary, NSURL, NSURLBookmarkCreationMinimalBookmark, NSMutableArray
@franz-josef-kaiser
franz-josef-kaiser / example_post_status.php
Created June 14, 2012 13:07
Add a custom post status for WP (custom) post types
<?php
// No, Thanks. Direct file access forbidden.
! defined( 'ABSPATH' ) AND exit;
// INIT
add_action( 'after_setup_theme', array( 'unavailable_post_status', 'init' ) );
class unavailable_post_status extends wp_custom_post_status
{
/**
@shawnbot
shawnbot / form-save.js
Last active July 29, 2021 14:54
A JavaScript snippet for temporarily saving and restoring a form's state after refreshing
// NOTE: the '#form-id' selector below will most certainly be different
// for whatever page you're on. Remember to change it in both instances!
// run this in the terminal to save the state of your form
// in your browser's LocalStorage:
[].forEach.call(document.querySelector('#form-id').elements, function(el) {
localStorage.setItem(el.name, el.value);
});
// then refresh the page and run this to restore your form values:
@shinaisan
shinaisan / canvas.html
Created August 6, 2013 10:20
A dead simple HTML5 canvas drawing example with a drawing tool selection based on Twitter Bootstrap.
<html>
<head>
<link rel="stylesheet" href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css"></link>
<!-- jquery.js must be loaded before bootstrap.js. -->
<script type="text/javascript" src="http://getbootstrap.com/2.3.2/assets/js/jquery.js"></script>
<script type="text/javascript" src="http://getbootstrap.com/2.3.2/assets/js/bootstrap.js"></script>
<script type="text/javascript" src="paint.js"></script>
<style type="text/css">
body {
@yongkangchen
yongkangchen / ctags lua 规则增强
Last active October 29, 2021 11:21
ctags lua 规则增强
--regex-LUA=/^.*\s*function[ \t]*([a-zA-Z0-9_]+):([a-zA-Z0-9_]+).*$/\2/f,function/
--regex-LUA=/^.*\s*function[ \t]*([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+).*$/\2/f,function/
--regex-LUA=/^.*\s*function[ \t]*([a-zA-Z0-9_]+)\s*\(.*$/\1/f,function/
--regex-LUA=/([a-zA-Z0-9_]+) = require[ (]"([^"]+)"/\1/r,require/
--regex-LUA=/[ \t]{1}([a-zA-Z0-9_]+)[ \t]*[=][^=]/\1/v,variable/
--regex-LUA=/[ \t]*([a-zA-Z0-9_]+)[ \t]*=[ \t]*module_define.*$/\1/m,module/
--regex-LUA=/func_table\[ msg\.([A-Z_]+) \].+/\1/