Skip to content

Instantly share code, notes, and snippets.

View codepunkt's full-sized avatar

Christoph Werner codepunkt

View GitHub Profile
@molily
molily / bem.sass
Last active August 29, 2015 14:26
BEM helper mixins for Sass
// Mixins for generating Block Element Modifier (BEM) class names.
// See https://css-tricks.com/snippets/sass/bem-mixins/
// They can be nested to produce meaningful classes.
// To create a descendant selector like `.block--modifier .block__element`
// the block needs to be repeated. For example:
// +block(some-block)
//
// +element(some-element)
// color: red
//
@kof
kof / bootstrap.js
Created March 30, 2011 22:52
bootstrap file for mongoose models
var fs = require('fs'),
m = require('mongoose');
fs.readdirSync(__dirname).forEach(function(filename) {
var schamaName = filename.replace(/\.js$/, ''),
Schema = require('./' + schemaName);
m.model(schemaName, Schema);
});
@romannurik
romannurik / centered_triangle.html
Created May 3, 2011 05:43
A simple CSS trick to create a horizontally- or vertically-centered 'selected' callout triangle using zero images.
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 40px;
}
a {
display: inline-block;
@tdreyno
tdreyno / isoTransform.js
Created May 6, 2011 21:51
Isotope CSS3 jQuery cssHooks
// ========================= getStyleProperty by kangax ===============================
// http://perfectionkills.com/feature-testing-css-properties/
var getStyleProperty = (function(){
var prefixes = ['Moz', 'Webkit', 'Khtml', 'O', 'Ms'];
var _cache = { };
function getStyleProperty(propName, element) {
@ralphholzmann
ralphholzmann / oauthPercentDecode
Created May 25, 2011 14:32
encodeURIComponent doesn't follow rfc3986 that oauth requires. This is my fix...
var oauthPercentEncode = (function(){
var escapeChars = "!*'();:@&=+$,/?%#[]",
matchChars = new RegExp( "([\\" + ( escapeChars.split('').join('\\')) + "])", "gi");
return function( p ) {
return p.replace( matchChars, function( char ) {
return '%' + ( "" + char ).charCodeAt(0).toString(16).toUpperCase();
})
}
@behringer24
behringer24 / gist:1012015
Created June 7, 2011 10:34
Easy method to build SQL queries and escape parameters
/**
* Replacement callback function
*
* @param array $match
* @return string
*/
private function queryReplacementCallback($match) {
if (!isset($this->queryReplacementData[$match[2]]) || $this->queryReplacementData[$match[2]] === null) {
$replace = 'null';
} else {
@addyosmani
addyosmani / browser-prefix-detection
Created June 7, 2011 13:14
Compact browser prefix checking
/* GPL */
/*Whitelist version with quick test*/
function k(q){
var s,
d = document.createElement("div"),
n = q,
p = [ "webkit", "moz", "ms", "O", "" ],
o = n,
r, j=0, len, l;
@briancavalier
briancavalier / withSourceMaps.js
Last active January 5, 2016 07:40
Helper for simple support for source maps in when.js unhandled rejection reporting
var when = require('when');
unhandledRejectionsWithSourceMaps(when.Promise);
function unhandledRejectionsWithSourceMaps(Promise) {
Promise.onPotentiallyUnhandledRejection = function(r) {
setTimeout(function() {
if(!r.handled) {
throw r.value;
}
@jrburke
jrburke / apiexamples.js
Created April 7, 2011 05:50
Description of browser-friendly module APIs: AMD and Loader Plugins
//*******************************************
// Level 1, basic API, minimum support
//*******************************************
/*
Modules IDs are strings that follow CommonJS
module names.
*/
//To load code at the top level JS file,
//or inside a module to dynamically fetch
@asciidisco
asciidisco / pubsub_with_requirejs_backbone.js
Created October 31, 2012 11:26
PubSub with requirejs & backbone
// PubSub impl. with require.js & backbone.js
// events.js
define(['underscore', 'backbone'], function (_, Backbone) {
'use strict';
var events = {};
_.extend(events, Backbone.Events);
return events;
});