Skip to content

Instantly share code, notes, and snippets.

View Demwunz's full-sized avatar
:octocat:
donuts

Fazal Demwunz

:octocat:
donuts
View GitHub Profile
@ZeeAgency
ZeeAgency / gist:948808
Created April 29, 2011 19:00
CSS Scrollbar detection Modernizr plugin
// Works only with Modernizr 1.8pre+
Modernizr.addTest('cssscrollbar', function() {
// Tested Element
var test = document.createElement('div'),
// Fake body
fake = false,
root = document.body || (function () {
@ded
ded / tween.js
Created May 13, 2011 06:07
generic time-based tween with easing support
!function ($) {
function tween(duration, from, to, tween, ease) {
ease = ease || function (t) {
return t;
}
var self = this,
time = duration || 1000,
animDiff = to - from,
startTime = new Date(),
@ded
ded / app.html
Created June 29, 2011 04:09
ender CLI example
<script src="ender.min.js"></script>
<script>
$.require('/js/core.min.js', 'core')
$.ready('core', function () {
$(document).ready(function () {
$('<p>hello world</p>').appendTo('body')
.bind('click', function (e) {
$.require('/js/ajax.min.js', function () {
@qawemlilo
qawemlilo / grayscale.js
Created July 19, 2011 09:20
Edit images to grayscale using JavaScipt and HTML5 canvas.
function toGreyScale(r, g, b) {
return r * 0.2989 + g * 0.5870 + b * 0.1140;
}
function editImage(img, targetDiv) {
var id = "editeImage", canvasContainer = document.getElementById(targetDiv),
imgCanvas, ctx, imageData, px, len, i, redPx, greenPx, bluePx, greyscale;
imgCanvas = document.createElement("canvas");
imgCanvas.id = id;
@bzerangue
bzerangue / twitter-button.xsl
Created August 31, 2011 17:21
[XSLT] Twitter Button XSL Utility
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Twitter Button: XSL Utility
Created by Zerangue, Brian on 2011-08-31.
Copyright (c) 2011 Brian Zerangue. All rights reserved.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
@chriseppstein
chriseppstein / 0_silent_selector_grid.scss
Created January 4, 2012 22:08
This gist describes a new feature we're experimenting with for Sass 3.2: placeholder selectors. They do not get generated into your output, but they can be used like a class and extended like one.
$gutter: 10px;
$grid-unit: 60px;
%clearfix {
*zoom: 1;
&:after {
content: "\0020";
display: block;
height: 0;
clear: both;
@iliadraznin
iliadraznin / istype.js
Created June 8, 2013 15:28
Simple function to detect type Array. JavaScript return type "object" whether you give it an actual object like { red:44, green:57, blue:220 }, or an array like [44, 57, 220]. So I wrote this small function to separate the two.
function istype(obj) {
return (typeof obj !== 'object' || typeof obj[0] === 'undefined')
? typeof obj
: 'array';
}

Lesson's learnt building the Guardian

Below is a collection of my favourite responses I gathered from Guardian engineers when asked the question: What have you learnt starting from scratch and building a mobile-first next generation web platform for the Guardian?

Daithi O Crualaoich

  • Work with great people.
  • Deploy like crazy. This means the team has to control the infrastructure as well as code.
  • Design is not a service. Designers have to sit in the team.
  • Infrastructure is intrinsically unreliable. Discard and replace is the robust strategy.
  • Use your CDN for HTML too.
  • Don't always do as you are told.
@r3b
r3b / interaction-timing.js
Last active December 19, 2015 08:19
Testing web UI interaction response times with CasperJS
var colorizer = require('colorizer').create('Colorizer');
var casper = require('casper').create();
var totalTests=3;
casper.start('http://jqueryui.com/resources/demos/tabs/ajax.html', function(){
casper.viewport(1024, 768);
this.test.assertHttpStatus(200, "The page has loaded.");
this.test.assertSelectorExists('#tabs', "We got tabs.");
this.test.assertVisible('#tabs-1', "Content 1 is visible.");
this.capture('ui-id-1.png');
});
@explorer2309
explorer2309 / Checking types in JS
Last active December 22, 2015 01:28
Checking types in JavaScript
var system = {};
var isChecks = ['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'];
function makeIsFunction(name) {
var value = '[object ' + name + ']';
system['is' + name] = function(obj) {
return toString.call(obj) == value;
};
}