Skip to content

Instantly share code, notes, and snippets.

@janily
janily / dabblet.css
Created February 12, 2014 11:03 — forked from LeaVerou/dabblet.css
Move in a circle without wrapper elements
/**
* Move in a circle without wrapper elements
* Idea by Aryeh Gregor, simplified by Lea Verou
*/
@keyframes rot {
from {
transform: rotate(0deg)
translate(-150px)
rotate(0deg);
@janily
janily / replace
Created February 13, 2014 06:30
图片加载失败时显示提示图片
function imgError(image) {
image.onerror = "";
image.src = "/images/noimage.gif";
return true;
}
<img src="image.png" onerror="imgError(this);"/> or
<img src="image.png" onError="this.onerror=null;this.src='/images/noimage.gif';" />
@janily
janily / sticky footer
Created February 13, 2014 06:34
固定底部
@janily
janily / nginx
Created February 13, 2014 06:35
nginx 里设置font-face 跨域
server {
...
# Fix @font-face cross-domain restriction in Firefox
location ~* \.(eot|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
...
}
原贴来自snipt.net
@janily
janily / linkcss
Created March 7, 2014 09:13
Style External Links
/* long version */
a[href^="http://"]:not([href*="mysite.com"]),
a[href^="https://"]:not([href*="mysite.com"]),
a[href^="//"]:not([href*="mysite.com"]), {
}
/* shorter version! */
a[href*="//"]:not([href*="mysite.com"]) {
/* external link styles, use :before or :after if you want! */
}
@janily
janily / timeago
Created March 8, 2014 02:26
Displays date in “ago” format with PHP
// Displays the date with ago like facebook
function getHowLongAgo($date, $display = array('year', 'month', 'day', 'hour', 'minute', 'second'), $ago = 'ago'){
$date = getdate(strtotime($date));
$current = getdate();
$p = array('year', 'mon', 'mday', 'hours', 'minutes', 'seconds');
$factor = array(0, 12, 30, 24, 60, 60);
for ($i = 0; $i < 6; $i++) {
if ($i > 0) {
$current[$p[$i]] += $current[$p[$i - 1]] * $factor[$i];
$date[$p[$i]] += $date[$p[$i - 1]] * $factor[$i];
@janily
janily / rAF.js
Created March 11, 2014 12:53 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

var gulp = require('gulp');
var minifycss = require('gulp-minify-css');
var autoprefixer = require('gulp-autoprefixer');
var notify = require('gulp-notify');
var sass = require('gulp-ruby-sass');
gulp.task('css', function() {
return gulp.src('sass/main.sass')
.pipe(sass({ style: 'compressed' }))
.pipe(autoprefixer('last 15 version'))
var gulp = require('gulp'),
sys = require('sys'),
exec = require('child_process').exec;
gulp.task('phpunit', function() {
exec('phpunit', function(error, stdout) {
sys.puts(stdout);
});
});