Skip to content

Instantly share code, notes, and snippets.

View markbrown4's full-sized avatar

Mark Brown markbrown4

View GitHub Profile
/*
* mQuery, My journey into the world of js libraries
* Selectors, Events, DOM, Ajax and Animation
*/
var $ = (function() {
/*!
* Sizzle CSS Selector Engine - v1.0
* Copyright 2009, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
/* 1 - keep js separate */
// these are the same but #2 can be passed around.
function myFunc(a) {
}
var myFunc = function(a) {
}
@markbrown4
markbrown4 / History.js
Created March 4, 2011 01:23
Lighter version of pushState / hash fallback with strict URL convention
/* Uses a strict URL convention, specifically a language code as an identifier for the root of the site and then the page name.
* e.g. http://example.com/cool-site/en/listing/?cool=true
* Lang = 'en'
* Page = 'listing'
* The URL's for the pages and the ajax content are identical,
* We just used the X-Requested-With header to serve the content only if it's an ajax request.
*/
var History = {
lang: 'en|es|de|fr|pt|zh-s|zh-c|ja|ko|id|th|en-us|it',
page: 'listing',
var Controls = {
init: function (container) {
// Matches "control-something"
var typeRegex = /control-([a-z0-9\-]+)(\s|$)/i;
container.select('.init').each(function (el) {
var control_name = typeRegex.exec(el.className)[1].camelize().ucfirst();
try {
this.createnewControl(control_name, el);
@markbrown4
markbrown4 / gist:1148446
Created August 16, 2011 04:41
Controls
var Page = {
init: function() {
Controls.init();
}
}
// Lets go
var $body = $("body");
$(document).ready(Page.init);
@markbrown4
markbrown4 / sunspot_solr_globalize.rb
Created November 9, 2011 01:37
solr translated fields from Globalize3
class Job < ActiveRecord::Base
translates :title
globalize_accessors :locales => I18n.available_locales, :attributes => translated_attribute_names
searchable do
I18n.available_locales.each do |locale|
sym = ("title_" + locale.to_s).to_sym
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Domenico Carbotta</string>
<key>name</key>
<string>Rogie</string>
<key>settings</key>
<array>
@markbrown4
markbrown4 / dabblet.css
Created January 2, 2012 20:47
Cute little value previewers
/* Cute little value previewers */
.previewer {
position: absolute;
border-radius: 8px;
box-shadow: 1px 1px 8px rgba(0,0,0,.7);
}
/* tick */
.previewer:before {
content: '';
@markbrown4
markbrown4 / dabblet.css
Created January 2, 2012 20:55
#abslength previewer
/* #abslength previewer */
#abslength {
max-width: 100%;
height: 20px;
border: 1px solid white;
border-radius: 0;
transition: .3s;
transition-property: width;
}
@markbrown4
markbrown4 / dabblet.css
Created January 2, 2012 21:00
#time previewer
/* #time previewer */
#time {
width: 74px;
height: 74px;
margin-left: -37px;
background: linear-gradient(right,
hsla(24, 20%, 95%, .4),
hsl(24, 20%, 95%) 95%);
/* half the width/height for a perfect circle */
border-radius: 37px;