Skip to content

Instantly share code, notes, and snippets.

View mdunbavan's full-sized avatar

Mark Dunbavan mdunbavan

View GitHub Profile
@garyharan
garyharan / _mixins.scss
Created May 5, 2011 15:46
Useful scss mixins (rounded corners, gradients, text-field, button)
@mixin box-shadow($top, $left, $blur, $color, $inset: false) {
@if $inset {
-webkit-box-shadow:inset $top $left $blur $color;
-moz-box-shadow:inset $top $left $blur $color;
box-shadow:inset $top $left $blur $color;
} @else {
-webkit-box-shadow: $top $left $blur $color;
-moz-box-shadow: $top $left $blur $color;
box-shadow: $top $left $blur $color;
}
@lukemartin
lukemartin / routes.php
Created June 22, 2012 10:51
Output checkboxes with appropriate 'checked' attributes in Laravel
Route::get('edit', function() {
// fetch our post, and it's associated categories
$post = Post::with('cats')->where('id', '=', $id)->first();
// fetch all of our categories
$cats = Cat::all();
// create our empty array
$post_cats = array();
@pavellauko
pavellauko / timezones_array.php
Created July 10, 2012 10:35
Time zones as arrays (PHP)
<?php
$timezones = array(
'America/Adak' => '(GMT-10:00) America/Adak (Hawaii-Aleutian Standard Time)',
'America/Atka' => '(GMT-10:00) America/Atka (Hawaii-Aleutian Standard Time)',
'America/Anchorage' => '(GMT-9:00) America/Anchorage (Alaska Standard Time)',
'America/Juneau' => '(GMT-9:00) America/Juneau (Alaska Standard Time)',
'America/Nome' => '(GMT-9:00) America/Nome (Alaska Standard Time)',
'America/Yakutat' => '(GMT-9:00) America/Yakutat (Alaska Standard Time)',
'America/Dawson' => '(GMT-8:00) America/Dawson (Pacific Standard Time)',
@chrislkeller
chrislkeller / README.md
Last active February 3, 2022 08:02
Displaying data from a flat JSON file on a Handlebars.js template file rendered with AJAX.

Demo: ajax-handlebars

This repo's location has changed.

@sineld
sineld / laravel-upload-resize.php
Created September 25, 2012 08:11
Laravel File Upload And Resize
<?php
// Resizer and Image Manipulation
// Based on: http://forums.laravel.com/viewtopic.php?id=2648
public function post_edit_logo($id)
{
$rules = array(
'image' => 'image',
);
@TastyToast
TastyToast / handlebars-truncate-helper.js
Last active April 21, 2021 09:08
Truncate helper for Handlebars.js
Handlebars.registerHelper ('truncate', function (str, len) {
if (str.length > len) {
var new_str = str.substr (0, len+1);
while (new_str.length) {
var ch = new_str.substr ( -1 );
new_str = new_str.substr ( 0, -1 );
if (ch == ' ') {
break;
@claudiosanches
claudiosanches / add-to-cart.php
Last active October 18, 2023 14:02
WooCommerce - Template add-to-cart.php with quantity and Ajax!
<?php
/**
* Custom Loop Add to Cart.
*
* Template with quantity and ajax.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
global $product;
@wmbenedetto
wmbenedetto / css3BackgroundAnimation.html
Last active April 12, 2016 12:58
Animating a background gradient with CSS3 to mimic the iPhone's slide-to-unlock screen
<html>
<head>
<title>CSS3 Slide to unlock</title>
<style type="text/css">
body {
background:#333;
}
.slider-text {
@tarolandia
tarolandia / placeholder-color.sass
Created April 22, 2013 12:33
Sass: mixin that let you change placeholder font color.
@mixin placeholder-color($color) {
&::-webkit-input-placeholder { /* WebKit browsers */
color: $color;
}
&:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color: $color;
}
&::-moz-placeholder { /* Mozilla Firefox 19+ */
color: $color;
}
@simonwhitaker
simonwhitaker / postcode-regex.js
Last active December 15, 2023 11:29
An example of using a simplified UK postcode regex in Javascript
var tweet = "Currently chilling out at W1B 2EL, then on to WC2E 8HA or maybe even L1 8JF! :-)";
// Here's a simple regex that tries to recognise postcode-like strings.
// See http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation
// for the rules on how UK postcodes are formatted.
var postcode_regex = /[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}/g;
var postcodes = tweet.match(postcode_regex);
console.log(postcodes);