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
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 / 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" />
@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.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 / 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 / random.js
Last active August 29, 2015 14:08 — forked from kerimdzhanov/random.js
// @return [float] a random number between min and max
function getRandom(min, max) {
return Math.random() * (max - min) + min;
}
// @return [integer] a random int between min and max
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
@giiska
giiska / v1.js
Created November 13, 2014 02:07
auto_create_ts grunt task for auto append timestamp to static files
grunt.registerMultiTask('auto_create_ts', 'The best Grunt plugin ever.', function() {
function replaceAssets(fileSrc) {
//read page file data
var htmlData = grunt.file.read(fileSrc);
//get the full asset text, like "text/javascript" src="js/hello.js?auto_create_ts=3232323233"
// console.log(/(".*?auto_create_ts=)(\d+)([\"|\'])/g.test(htmlData));
var newdata = htmlData.replace(/(".*?auto_create_ts=)(\d+)([\"|\'])/g, "$1" + (Math.round(+new Date() / 1000)) + "$3");
@giiska
giiska / 4spaces_to_2spaces.sublime-macro
Created November 13, 2014 06:46
convert 2 tab or 4 space to 2 space in sublime text
[
{
"args": {
"setting": "tab_size",
"value": 4
},
"command": "set_setting"
},
{
"args":
@giiska
giiska / gist:33c5c797c76422a06cae
Created December 19, 2014 01:21
Shortcut for adding animation class name to dom element
/**
* Shortcut for adding animation class name to dom element
* @param {string} cls class name
* @param {Function} cb callback
* @param {Function} lastItemCb callback execute at last elment animated
* @return {object} this
*/
$.fn.classAnimoEnd = function(cls, cb, lastItemCb) {
var el = this;
@giiska
giiska / 0.php
Created December 22, 2014 01:45
WP_CONTENT_URL WP_CONTENT_DIR defines
<?php
// Pre-2.6 compatibility
if( !defined('WP_CONTENT_URL') )
define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
if( !defined('WP_CONTENT_DIR') )
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );