Skip to content

Instantly share code, notes, and snippets.

@rayou
rayou / Image Replacement
Last active December 15, 2015 07:09 — forked from visualpropaganda/gist:4585619
CSS: Image Replacement
/* H5BP image replacement: http://nicolasgallagher.com/another-css-image-replacement-technique/ */
.ir {
border: 0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
}
@rayou
rayou / .htaccess
Last active December 15, 2015 13:59 — forked from muhittin/codeigniter_htaccess
PHP: Codeigniter_htaccess
RewriteEngine On
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1
@rayou
rayou / unzip.py
Last active December 15, 2015 19:19 — forked from cesandoval/unzip.py
Python: unzip.py
import zipfile
import os
#Extracts files on a zip file into a given directory, if no directory is given,
#it extracts the files into the zip file directory.
def unzip_file(zip_file, my_path=None):
zip_file = zipfile.ZipFile(zip_file) #open the zip file
if my_path != None: #if directory is given, and doesn't exist, create directory.
if not os.path.isdir(my_path):
@rayou
rayou / .gitignore
Last active December 16, 2015 20:39
Git: .gitignore for bcb5
*.exe
*.obj
*.res
*.tds
*.~*
BoldAsFont=no
Term=xterm-256color
FontHeight=10
Locale=zh_TW
Charset=UTF-8
RightClickAction=paste
CursorType=block
ForegroundColour=215,215,215
BackgroundColour=48,48,48
CursorColour=135,175,215
@rayou
rayou / .htaccess
Created December 26, 2014 09:27
apache htaccess rewrite
RedirectMatch 301 ^(.+).action$ /index.html.en?$1.action
function makeArray(o) {
  try {
    return Array.prototype.slice.call(o);
  } catch (e) {}
   
  for (var i = 0, l = o.length, a = new Array(i); i < l; i++) {
    if (i in o) {
      a[i] = o[i];
    }
  }
@rayou
rayou / debounce.js
Created June 14, 2015 05:26
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() {
timeout = null;
@rayou
rayou / poll.js
Created June 14, 2015 05:28
poll
function poll(fn, callback, errback, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
(function p() {
// If the condition is met, we're done!
if(fn()) {
callback();
}
// If the condition isn't met but the timeout hasn't elapsed, go again