Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@daviddarnes
daviddarnes / head.html
Last active August 29, 2015 14:08
Anchor Themes head meta
<link rel="alternate" type="application/rss+xml" title="RSS" href="/feeds/rss">
<link rel="shortcut icon" href="/img/favicon.ico" type="image/x-icon">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="generator" content="CMS name">
<!-- Open graph meta -->
<meta property="og:type" content="website">
<meta property="og:site_name" content="Website title">
@emilbjorklund
emilbjorklund / breakpoints_via_css.html
Created April 24, 2012 16:03
Width detection via sneaky CSS rules
<!DOCTYPE html>
<!--[if IE 8]> <html lang="sv-SE" class="no-js ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="sv-SE" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<title>Breakpoint detection test</title>
<style type="text/css" media="screen">
@media screen and (min-width: 320px) {
#page:after {
content: 'smallest'; /* represent the current width-bracket */
@mudge
mudge / .htaccess
Created November 7, 2008 14:48
Remove file extensions in URLs with mod_rewrite but preserve 404 errors.
# The following will allow you to use URLs such as the following:
#
# example.com/anything
# example.com/anything/
#
# Which will actually serve files such as the following:
#
# example.com/anything.html
# example.com/anything.php
#
@pbojinov
pbojinov / debounce.js
Last active April 26, 2018 12:45
Debounce
// http://davidwalsh.name/function-debounce
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
@idris
idris / lesswatch.js
Created July 13, 2011 14:37
lesswatch command that can be run to watch a directory and compile .less files to .css files when they are modified.
#!/usr/bin/env node
var fs = require('fs');
var exec = require('child_process').exec;
/*
* lesswatch usage:
*
* `lesswatch` to watch the current directory
<?php
# Implements a recursive null object pattern.
#
# Implemented as a trait so any object can make it's properties use
# the null pattern without resorting to inheritance.
#
# The goal is so you can pull data off a partially populated object
# without excessive existance checks.
trait NullPattern {
@kentbrew
kentbrew / tiny-web-server.js
Created January 4, 2011 00:49
A tiny Web server, written in node.js
// hey, everybody! it's a tiny Web server!
// instead of a bunch of foo = reqire("foo")
// list our required modules and loop through
var r = [ "fs", "http", "mime", "path", "url" ];
for (var i = 0; i < r.length; i++) {
global[r[i]] = require(r[i]);
}
// some constants
anonymous
anonymous / gist:9924932
Created April 1, 2014 23:08
%% Read image and convert to grayscale
img = imread('pic.jpg');
img = rgb2gray(img);
%% Define grayscale representations of 0-255
chars = fliplr([' ', '.', ',', ':', '-', '=', '+', '*', '#', '%', '@']);
step = 256 / 11;
%% Cut image so its size is 8*w times 13*h
imgSize = size(img);
@tylerzey
tylerzey / regex.js
Last active August 5, 2020 13:53
A List Of Helpful Regex Examples
let re;
//this looks for the string between the slashes. it'll match hello but not HeLlo.
re = /hello/;
//the lower case i means be case insensitive. this will match HellO.
re = /hello/i;
// explaination for common search characters
@lorenzopolidori
lorenzopolidori / has3d.js
Last active December 4, 2020 10:52 — forked from webinista/has3d.js
Testing for CSS 3D Transforms Support
function has3d(){
if (!window.getComputedStyle) {
return false;
}
var el = document.createElement('p'),
has3d,
transforms = {
'webkitTransform':'-webkit-transform',
'OTransform':'-o-transform',