Skip to content

Instantly share code, notes, and snippets.

View sabrinaluo's full-sized avatar
loading...

HiiTea sabrinaluo

loading...
View GitHub Profile
console.log("awesome!")
console.log("awesome!")
console.log("awesome!")
console.log("awesome!")
console.log("awesome!")
function error(err, options) {
var originalError = null;
if (typeof err.message === 'string' && err.message !== '') {
if (typeof options === 'string' || (options && options.message)) {
originalError = util.copy(err);
originalError.message = err.message;
}
}
err.message = err.message || null;
function copy(object) {
if (object === null || object === undefined) return object;
var dupe = {};
// jshint forin:false
for (var key in object) {
dupe[key] = object[key];
}
return dupe;
}
@sabrinaluo
sabrinaluo / object-isEmpty.js
Last active December 30, 2015 07:12
{} isEmpty()
function isEmpty(obj) {
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
return false;
}
}
return true;
}
@sabrinaluo
sabrinaluo / .travis.yml
Created December 28, 2015 05:05
.travis.yml for hexo blog
language: node_js
node_js:
- '4.0'
branches:
only:
- master
before_install:
- openssl aes-256-cbc -K $encrypted_e011a6d7eebf_key -iv $encrypted_e011a6d7eebf_iv -in .travis/id_rsa.enc -out ~/.ssh/id_rsa -d
- chmod 600 ~/.ssh/id_rsa
- eval $(ssh-agent)
@sabrinaluo
sabrinaluo / gist:8bd89b0e509c7a73f968
Created January 6, 2015 11:08
handlebars.js array index
{{#each data}}
<div>{{@index}}</div> <!-- start from 0-->
<div>{{this}}</div> <!-- "aa"-->
{{/each}}
<script>
var data = ["aa","bb"]
</script>
@sabrinaluo
sabrinaluo / gist:6779c0760d800504615c
Created January 6, 2015 06:51
jquery first child
<div>
<p>123</p>
<p>321</p>
<p>456</p>
<p>789</p>
</div>
<script>
$("div p:first-child") //return <p>123</p>
</script>
@sabrinaluo
sabrinaluo / gist:18be8a2e7e42e2cd2793
Created December 31, 2014 09:21
whether an element has children
$("#ele").children().length>0; // if has children return true
@sabrinaluo
sabrinaluo / img_rounded.html
Created December 16, 2014 07:59
css img rounded 图片 圆形
<style>
div{
height:100px;
width:100px; /*宽高必须相等*/
overflow:hidden; /*隐藏超出div的部分*/
border-radius:50%;/*圆角为宽高的50%*/
}
</style>
<div>
@sabrinaluo
sabrinaluo / jq_elementSearch.js
Last active August 29, 2015 14:11
查找元素
//查找同级元素
$("#id").next(); // 下一个同级元素
$("#id").prev(); // 前一个
$("#id").nextAll("div"); // 所有该元素之后的同级div元素
$("#id").prevAll("div");
$("#id").prevAll("div").andSelf(); //所有该元素之前的同级div元素及该元素本身