Skip to content

Instantly share code, notes, and snippets.

View culshaw's full-sized avatar
🎯
Converting a large scale python and jquery app, into a React with Django DRF app

Ian Culshaw culshaw

🎯
Converting a large scale python and jquery app, into a React with Django DRF app
View GitHub Profile
@culshaw
culshaw / gist:99ac000e3d5159d2c70e5e2f8604bb38
Created November 27, 2023 13:19 — forked from levelsio/gist:5bc87fd1b1ffbf4a705047bebd9b4790
Secret of Monkey Island: Amsterdam (by @levelsio) or how to create your own ChatGPT image+text-based adventure game
# 2023-11-27 MIT LICENSE
Here's the open source version of my ChatGPT game MonkeyIslandAmsterdam.com.
It's an unofficial image+text-based adventure game edition of Monkey Island in Amsterdam, my home town.
Please use it however you want. It'd be nice to see more ChatGPT-based games appear from this. If you get inspired by it, please link back to my X https://x.com/levelsio or this Gist so more people can do the same!
Send me your ChatGPT text adventure game on X, I'd love to try it!
@culshaw
culshaw / ES5 template literal parser
Last active September 13, 2016 09:21
javascript:Template literal parser for non es6 strings
function interpolate(text, literals) {
return text.replace(new RegExp(/\$\{(\w+)\}/, "g"), function() {
if(arguments[1] in literals) {
return literals[arguments[1]];
}
throw new Error("Literal "+arguments[1]+" doesn't exist for text replacement");
});
}
var WHForm = React.createClass({
handleBlur: function() {
this.props.commitChanges(this.state);
},
handleChange: function(ev) {
var state = this.state;
state[ev.target.name] = ev.target.value;
this.setState(state);
@culshaw
culshaw / Laravel Models
Created November 27, 2013 10:17
Sweet Laravel prebinding for model.
<?php
// Base as in "Base" Model--others inherit from this one
class BaseModel extends \Illuminate\Database\Eloquent\Model
{
public $incrementing = false;
protected function gen_uuid() {
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
@culshaw
culshaw / Previous work.md
Last active December 22, 2015 08:49
Some links to my previous work
@culshaw
culshaw / Useful regexes
Last active December 18, 2015 23:59
This is a file with some useful regexes.
# Phone number regex.
`^([\+\(\)\-\d\s]+)$`
Matches all phone numbers including the following characters ()+- and spaces. e.g. `+ 44 (0) 75-111-57-220`
# Swedish postcodes.
`^(\d\s?){5}$`
# Dutch postcode
`^(\d\s?){4}([A-Z]\s?){2}$`