Skip to content

Instantly share code, notes, and snippets.

View toadkicker's full-sized avatar
🏠
Let's fix some stuff

Todd Baur toadkicker

🏠
Let's fix some stuff
View GitHub Profile
@toadkicker
toadkicker / gist:7609641
Last active June 18, 2023 19:44
This is the intro in Lion King. 'Pride Rock'. I use it instead of lorem ipsum sometimes.
Ndabe zitha nkosi yethu mholi wezwe lethu lefatshe la bonata rona lea halalela busa le lizwe bo busa le lizwe bo busa le lizwe bo Lethu busa. Ngoxolo is'khathi sifikile is'khathi busa iyo is'khathi sifikile busa lomhlaba is'khathi sifikile is'khathi sifikile. Busa simba busa bimba. Hem na iyo hem na iyo mem na nkosi bo. Busa simba iyo hem na iyo. Oh busa simba iyo Hem na iyo. Oh busa nkosi bo Hem na nkosi bo. Oh busa simba iyo busa simba iyo. Busa simba iyo ubuse ngo thando. Ubuse ngo thando ubuse. Ngo xolo busa simba, busa simba ubuse ngo xolo. Ubuse ngo thando ubuse ngo xolo. Ubuse ngo thando ubuse ngo xolo.
/*
Polyfill for the Object.watch/Object.unwatch functions available in Mozilla browsers
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/watch
you have a test here:
http://www.telecable.es/personales/covam1/deployToNenyures/SourceCode/Object.watch.test.js
and can read more here:
http://deploytonenyures.blogspot.com.es/2013/02/objectwatch-polyfill.html
*/
#element{
background-image: url('/images/sprite.png');
background-repeat: no-repeat;
background-position: -3px 0;
}
@media print, screen,
(-webkit-min-device-pixel-ratio: 1.25),
(~`"-o-min-device-pixel-ratio: 1.25/1"`),
(min--moz-device-pixel-ratio: 1.25),
function generateToken() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
@toadkicker
toadkicker / gist:6717098
Created September 26, 2013 17:01
pretty json terminal output
curl "http://example.com/users.json" | python -mjson.tool
(function(){
//allowed domains
var whitelist = ["foo.example.com", "www.example.com"];
function verifyOrigin(origin){
var domain = origin.replace(/^https?:\/\/|:\d{1,4}$/g, "").toLowerCase(),
i = 0,
len = whitelist.length;
@toadkicker
toadkicker / isValidPhone
Created September 3, 2013 21:06
Validate phone numbers
String.prototype.isValidPhone = function() {
var filter = /^[0-9a-zA-Z\s.:#\(\)\+\-]+$/;
if (!filter.test(this)) {
return false;
} else {
return true
}
}
String.prototype.isValidEmail = function() {
var filter = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
if (!filter.test(this)) {
return false;
} else {
return true
}
}
@toadkicker
toadkicker / gist:6311772
Created August 22, 2013 19:34
Does a variable exist?
Scope.prototype.find = function(name, options) {
if (this.check(name, options)) {
return true;
}
this.add(name, 'var');
return false;
}
@toadkicker
toadkicker / array.first.js
Last active December 21, 2015 09:59
Stop writing for loops
if (!Array.prototype.first)
{
Array.prototype.first = function(predicate)
{
"use strict";
if (this == null)
throw new TypeError();
if (typeof predicate != "function")
throw new TypeError();