Skip to content

Instantly share code, notes, and snippets.

@jasya
jasya / Howto.md
Last active August 29, 2015 14:22 — forked from n1k0/Howto.md

Put test1.js and test2.js into a tests/ directory, then run the suite:

$ casperjs test tests/ --pre=pre.js --includes=inc.js --post=post.js
Test file: /Users/nperriault/tmp/pre-inc/pre.js                                 
Hey, I'm executed before the suite.
Test file: /Users/nperriault/tmp/pre-inc/tests/test1.js                         
# this is test 1
Hi, I've been included.
PASS Subject is strictly true
@jasya
jasya / touch.js
Last active August 29, 2015 14:20
phone javascript touch event
var millisecond = 750;
var elementProxy = {};
var holdTimeout,touchTimeout;
//调用事件
function runevent(element,name){
var evt = document.createEvent('Event');
evt.initEvent(name, true, true);
element.dispatchEvent(evt);
}
//清理时间
@jasya
jasya / new_gist_file.js
Created November 14, 2013 16:46
tumblr 认证
oauth = require('oauth'),
tumblr = require('tumblr'),
client = {
consumer_key: '',
consumer_secret: ''
},
consumer = new oauth.OAuth(
"http://www.tumblr.com/oauth/request_token", "http://www.tumblr.com/oauth/access_token",
client.consumer_key, client.consumer_secret, "1.0A", "http://127.0.0.1:3000/callback", "HMAC-SHA1");
app.get('/home', function(req, res){
{
"color_scheme": "Packages/Theme - Default/Yule.tmTheme",
"default_encoding": "UTF-8",
"draw_white_space": "all",
"font_face": "monaco",
"font_options":
[
],
"font_size": 12.0,
"ignored_packages":
@jasya
jasya / gruntfile
Created July 29, 2013 12:39
Gruntfile.js
module.exports = function(grunt){
grunt.initConfig({
pkg:grunt.file.readJSON("package.json"),
less:{
//必包含的less文件,合并到内的,合并的文件的内容会比component内的文件内容先出现
options:{
concat:true, //合并
paths:"source/less",//路径
imports:{
less:["basic.less"]//需要合并的less文件名
@jasya
jasya / clearfix
Created July 19, 2013 06:11
清除浮动
<div class="main">
<div class="left"></div>
<div class="right"></div>
<!-- <div class="clear"></div> -->
</div>
<style>
html,body{
margin: 0px;
padding: 0px;
@jasya
jasya / inArray
Created July 15, 2013 05:34
数组操作
Array.prototype.inArray = function(str){
var tmp = {};
for(var i in this){
tmp[this[i]] = i;
}
if(tmp[str]){
return tmp[str];
}
return -1;
}
<!DOCTYPE html>
<html>
<title>master</title>
<style>
</style>
<body>
<iframe id="frame" src="http://www.baidu.com"></iframe>
<script>
var flag = 0,
listpage = ["http://www.cnblogs.com/lhb25/","http://www.douban.com","http://www.v2ex.com/"];