Skip to content

Instantly share code, notes, and snippets.

View giiska's full-sized avatar
🌴
On vacation

Null giiska

🌴
On vacation
  • Godada
View GitHub Profile
@giiska
giiska / gist:fe0dbb1829846d9c5c0c
Created October 23, 2014 07:39
文本渐变变色
.site__title {
color: #f35626;
background-image: -webkit-linear-gradient(92deg,#f35626,#feab3a);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
-webkit-animation: hue 60s infinite linear;
}
@giiska
giiska / 1.js
Created October 21, 2014 08:54
How can I autoplay media in iOS >= 4.2.1 Mobile Safari?
There is one way to play the video/audio file automatically on 4.2.1. Create an iframe and set its source to the media file's URL and append the iframe to the body. It'll be autoplay.
var ifr=document.createElement("iframe");
ifr.setAttribute('src', "http://mysite.com/myvideo.mp4");
ifr.setAttribute('width', '1px');
ifr.setAttribute('height', '1px');
ifr.setAttribute('scrolling', 'no');
ifr.style.border="0px";
document.body.appendChild(ifr);
@giiska
giiska / 1.html
Created October 17, 2014 08:26
replace no js
<script>document.documentElement.className = document.documentElement.className.replace("no-js","js");</script>
@giiska
giiska / 1.html
Created October 17, 2014 08:24
微信分享抓取专用图片
<!-- 微信分享抓取专用 -->
<img id="weixin-share-icon" style="position: absolute; z-index: -222; width: 0; height: 0;" src="{{ STATIC_URL }}images/lime/share-default.jpg" />
var Events = (function() {
// Backbone.js 0.9.10
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
// Create a local reference to array methods.
var array = [];
@giiska
giiska / a.js
Created July 24, 2014 08:42
jquery.validate: accordion show when form in it is invalid by config `invalidHandler`
$form.validate({
ignore: '.ignore',
rules: rules,
messages: messages,
invalidHandler: function(event, validator) {
// console.log(event, validator);
var errorEl = validator.findLastActive() || validator.errorList.length && validator.errorList[0].element;
if(errorEl)
$(errorEl).closest('.accordion-body').collapse('show');
},
@giiska
giiska / .gemrc
Last active August 29, 2015 14:04 — forked from jch/.gemrc
中国用户的 gemrc, gemrc for coder in China
# http://guides.rubygems.org/command-reference/#gem-environment
---
:backtrace: true
:bulk_threshold: 1000
:benchmark: false
:sources:
- http://ruby.taobao.org/
:update_sources: true
:verbose: true
gem: --no-document
@giiska
giiska / zepto.js
Created July 12, 2014 06:06
set require.config path of `jquery` to `zepto` when use backbone-amd
/**
* extend/zepto.js
*/
define([
'zepto'
], function() {
"use strict";
@giiska
giiska / a.js
Created July 11, 2014 10:54
require config path before load require.js
var require = {
paths: {
'jquery': '../../bower_components/zepto/zepto.min'
}
}
@giiska
giiska / customise-backbone-save-api-param.js
Last active August 29, 2015 14:03
Set `options.attrs` will allow you customise api param
// when model.attributes is different from the params to save
// e.g. when save to restful api, one attr should be `resource_uri`
// formated as string type, but the returned attr value in json is object formated
var model = new Backbone.Model();
model.save(null, {
wait: true,
success: function() {
},
attrs: _.omit(model.attributes, 'selected')
});