Skip to content

Instantly share code, notes, and snippets.

@dahnielson
dahnielson / UUID.php
Last active April 5, 2024 21:14
Pure PHP UUID generator
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4122 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
@debloper
debloper / index.html
Created December 14, 2011 11:37
Pulsating HTML Element with just pinchful of CSS Animation
<!DOCTYPE html>
<html>
<head>
<title>CSS Pulsator</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="pulsor">Pulsate!</div>
</body>
</html>
@maxrice
maxrice / us-state-names-abbrevs.php
Created May 23, 2012 18:32
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',
@Dreyer
Dreyer / mail-test.php
Created June 20, 2012 09:06
Quick & Dirty PHP Mail Test Script
<?php
/*
DONT FORGET TO DELETE THIS SCRIPT WHEN FINISHED!
*/
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = 'webmaster@example.com';
@isGabe
isGabe / wp_custom_title_placeholder_text.php
Last active February 25, 2019 21:28
WordPress: Custom placeholder text for custom post type title input box #snippet #WordPress
<?php
/*
replacing the default "Enter title here" placeholder text in the title input box
with something more descriptive can be helpful for custom post types
place this code in your theme's functions.php or relevant file
source: http://flashingcursor.com/wordpress/change-the-enter-title-here-text-in-wordpress-963
*/
@sterlingwes
sterlingwes / tourney.html
Created December 3, 2012 23:42
Tournament Bracket Generator (Javascript + CSS, no tables)
<!DOCTYPE html>
<html>
<head>
<title>Tournament Bracket Generator</title>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script>
$(document).on('ready', function() {
var knownBrackets = [2,4,8,16,32], // brackets with "perfect" proportions (full fields, no byes)
@kaizhu256
kaizhu256 / gist:4482069
Last active October 20, 2021 16:25
javascript - very fast and simple uuid4 generator benchmarked on http://jsperf.com/uuid4/8
/*jslint bitwise: true, indent: 2, nomen: true, regexp: true, stupid: true*/
(function () {
'use strict';
var exports = {};
exports.uuid4 = function () {
//// return uuid of form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
var uuid = '', ii;
for (ii = 0; ii < 32; ii += 1) {
@davidtheclark
davidtheclark / isElementInViewport.js
Created May 4, 2013 02:00
JavaScript: Is element in viewport?
/*
No jQuery necessary.
Thanks to Dan's StackOverflow answer for this:
http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
*/
function isElementInViewport(el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
@raveren
raveren / cryptographically_secure_random_strings.php
Last active November 21, 2023 12:35
Generate cryptographically secure random strings. Based on Kohana's Text::random() method and this answer: http://stackoverflow.com/a/13733588/179104
function random_text( $type = 'alnum', $length = 8 )
{
switch ( $type ) {
case 'alnum':
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alpha':
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'hexdec':
@manuganji
manuganji / height_regex.js
Last active November 25, 2019 18:12
JavaScript Regex to figure out the value in inches when the input value is in feet-inch notation( Eg: height) . Properly catches 5'10", 11'10", 5'2", 5'07, 5', 5'", 5 Also fails correctly for 5'13", 5'233", 521'1",
height_val = $("#id_height").val();
var regex_op = /^(\d{1,2})[\']?((\d)|([0-1][0-2]))?[\"]?$/g.exec(height_val);
//very rare chance for someone to be of two digit feet height.
//but i put it there, just in case.
var feet = regex_op[1];
var inches = regex_op[2];
// converting to inches
var height = (parseInt(feet) || 0) * 12 + (parseInt(inches) || 0);