Skip to content

Instantly share code, notes, and snippets.

View sleekslush's full-sized avatar

Craig Slusher sleekslush

  • Philadelphia, PA
View GitHub Profile
@sleekslush
sleekslush / wildcard-to-regexp.js
Created June 21, 2023 14:48 — forked from donmccurdy/wildcard-to-regexp.js
Wildcard and glob matching in JavaScript.
/**
* Creates a RegExp from the given string, converting asterisks to .* expressions,
* and escaping all other characters.
*/
function wildcardToRegExp (s) {
return new RegExp('^' + s.split(/\*+/).map(regExpEscape).join('.*') + '$');
}
/**
* RegExp-escapes all characters in the given string.
@sleekslush
sleekslush / gist:1676619
Created January 25, 2012 14:53 — forked from dnoyes/gist:1674741
creating a team (django)
# teams/views.py
@login_required()
def create(request):
form = CreateTeamForm(request.POST or None, request.FILES or None)
if form.is_valid():
team = form.save(commit=False)
team.status = STATUS.ACTIVE
team.creator = request.user
team.save()
@sleekslush
sleekslush / gist:1260266
Created October 3, 2011 21:11 — forked from madzak/gist:1260246
Client-side smash markup
<html>
<head>
<link rel="wesumosheet" type="text/css" href="http://meyerweb.com/eric/tools/css/reset/reset.css" />
<link rel="wesumosheet" type="text/css" href="http://a.fsdn.com/sd/classic.css?release_20110818.02" />
<script type="text/javascript" src="wesumo.debug.js?key=po0eYa_0R9W1QZ8Q7BGRiw&smash=css"></script>
</head>
<body>
<span id="message">Smash that shit</span>
<script type="wesumoscript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"></script>
<script type="wesumoscript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.js"></script>