Skip to content

Instantly share code, notes, and snippets.

View coolicer's full-sized avatar
🎯
Focusing

e.e.p coolicer

🎯
Focusing
View GitHub Profile
@coolicer
coolicer / config.rb
Last active January 1, 2016 19:49
一个范例
# Require any additional compass plugins here.
#set the css file encoding
Encoding.default_external = "utf-8"
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "stylesheets"
sass_dir = "sass"
images_dir = "images"
@coolicer
coolicer / default
Last active January 1, 2016 14:19
Thinkphp3.2 URL Rewrite
server {
listen 8080;
root /home/www/;
index index.html index.htm index.php;
server_name localhost;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
server {
listen 8080 default_server;
server_name 127.0.0.1;
root /home/www/php/;
index index.html index.htm index.php;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
@coolicer
coolicer / cc_router.js
Created September 9, 2013 06:45
A api example for node.js http request.
var CG = require('../closure-google');
module.exports = function(app){
app.get('/',function(req,res){
res.render('index', {
title: 'Express',
output: app.get('data') || ''
});
});
app.post('/',function(req,res,next){
var code = req.body.origin_code;
var fs = require("fs"),
path = require('path'),
http = require('http'),
url = require('url'),
zlib = require('zlib'),
mime = require('./mime').types,
config = require('./config');
var PORT = 9090;
@coolicer
coolicer / simple.js
Last active December 20, 2015 21:39
a very simple static file server made by node.js .
var http = require('http'),
url = require('url'),
path = require('path'),
fs = require('fs');
var PORT = 8080,
mimeTypes = {
"html": "text/html",
"jpeg": "image/jpeg",
"jpg": "image/jpeg",
@coolicer
coolicer / removeDuplicates.js
Created August 8, 2013 09:19
Removes all duplicates from an array
/**
* Removes all duplicates from an array (retaining only the first
* occurrence of each array element). This function modifies the
* array in place and doesn't change the order of the non-duplicate items.
*
* For objects, duplicates are identified as having the same unique ID as
* defined by {@link goog.getUid}.
*
* Runtime: N,
* Worstcase space: 2N (no dupes)
//_.bind方法是把func绑定到obj上
var ctor = function(){};
_.bind = function(func, context) {
var args, bound;
//如果有原生则使用原生的bind方法
if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
if (!_.isFunction(func)) throw new TypeError;
//转化为参数数组
args = slice.call(arguments, 2);
@coolicer
coolicer / _.each.js
Last active December 20, 2015 01:49
_.each
var each = _.each = _.forEach = function(obj, iterator, context) {
if (obj == null) return;
if (nativeForEach && obj.forEach === nativeForEach) {
//如果是数组,使用数组原生的forEach
obj.forEach(iterator, context);
} else if (obj.length === +obj.length) {
//如果是数组,且没有原生方法
for (var i = 0, l = obj.length; i < l; i++) {
if (iterator.call(context, obj[i], i, obj) === breaker) return;
}
@coolicer
coolicer / inline-block 空隙测试
Created March 8, 2013 06:43
inline-block 空隙测试
<!DOCTYPE html>
<html>
<head>
<meta charset="gbk">
<title>inline-block 空隙测试</title>
<style type="text/css">
* {
margin: 0;
padding: 0;