Skip to content

Instantly share code, notes, and snippets.

View neekey's full-sized avatar
🎯
Focusing

Neekey neekey

🎯
Focusing
View GitHub Profile
var http = require('http'),
httpProxy = require('http-proxy');
// Create an instance of node-http-proxy
var proxy = new httpProxy.HttpProxy({
target: {
host: 'localhost',
port: 9001
}
});
@neekey
neekey / background.html
Last active August 29, 2015 14:01
在chrome插件中实现复制文本内容
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<textarea class="J_ForCopy"></textarea>
<script type="text/javascript" src="./lib/jquery.js"></script>
@neekey
neekey / common.js
Created May 21, 2014 06:55
commonJS for all platform
!(function(){
/**
* 判断当前JS环境
*/
var hasDefine = typeof define === 'function';
var hasExports = typeof module !== 'undefined' && module.exports;
var Mod = function(){
/* write your code */
@mixin animation($value) {
-webkit-animation: unquote($value);
-moz-animation: unquote($value);
-o-animation: unquote($value);
animation: unquote($value);
}
@mixin animation-property($property, $value) {
-webkit-animation-#{$property}: unquote($value);
-moz-animation-#{$property}: unquote($value);
var analytics = require('analytics-node');
analytics.init({
secret: '4ck4zvbtccun95rua8bh',
flushAt : 1
});
analytics.identify({
userId : Identity,
traits : {
}
@neekey
neekey / chrome_extension_get_cookie.js
Created September 8, 2013 15:16
Chrome 插件获取指定域下的Cookie,代码示例
@neekey
neekey / img-resize.js
Created August 24, 2013 09:13
根据容器宽高和当前图片宽高确定适应宽高
/**
* 根据容器宽高和当前图片宽高确定适应宽高
* @param conW 容器宽度
* @param conH 容器高度
* @param imgW 图片宽度
* @param imgH 图片高度
* @returns {{w: *, h: *}}
*/
getImgResize: function( conW, conH, imgW, imgH ){
if( imgW <= conW && imgH <= conH ){
@neekey
neekey / gist-blog-sass-http-import.md
Last active December 17, 2015 19:29
SASS HTTP Import

由于SASS语言本身的强大和灵活,使用SASS可以构建出非常丰富的组件。我自己再平时的项目中会封装很多组件,通过mixin的方式来调用。然后组件多了思考着如何能共享这些样式模块了。

通过文件复制的方式自然是最土鳖但是最直接的方案之一,但是通过查阅SASS文档,可以看到其本身是支持很多拓展的。因此我们可以通过拓展importer来实现远程导入:

SASS中关于CUSTOM-IMPORTERS的描述:

but importers could be added to load from a database, over HTTP, or use a different file naming scheme than what Sass expects.

由于我不会Ruby,所以无法自己编写扩展。好在有网友已经实现了一个简单的(实际情况是做这块尝试的人还真的是很少)gem模块 remote-sass.

# Additional caching and such might be helpful for performance.
# Sass's regeneration only on changed files should work as long as the server provides the Last-Modified header
require 'net/http'
require 'time'
require 'sass'
module Sass
module Importers
# Importer which issues HTTP requests
@include keyframes(appear-and-roundify) {
0% { opacity: 0; @include border-radius(2px); }
100% { opacity: 1; @include border-radius(10px); }
}