Skip to content

Instantly share code, notes, and snippets.

@roshanca
roshanca / example.js
Created October 10, 2014 09:52
Get pseudo-element property with javascript
// Get the color value of .element:before
var color = window.getComputedStyle(
document.querySelector('.element'), ':before'
).getPropertyValue('color');
// Get the content value of .element:before
var content = window.getComputedStyle(
document.querySelector('.element'), ':before'
).getPropertyValue('content');
@roshanca
roshanca / example.js
Created October 10, 2014 09:58
Modify styleSheets with JavaScript
function addCSSRule(sheet, selector, rules, index) {
if(sheet.insertRule) {
sheet.insertRule(selector + "{" + rules + "}", index);
}
else {
sheet.addRule(selector, rules, index);
}
}
// Use it!
// ==UserScript==
// @name Straight Google
// @id straight_google_pokerface
// @version 1.17.13
// @author Pokerface - Kevin
// @namespace in.co.tossing.toolkit.google
// @description Remove URL redirection from google products
// @license GPL v3 or later version
// @downloadURL https://userscripts.org/scripts/source/121261.user.js
// @updateURL https://userscripts.org/scripts/source/121261.meta.js
@roshanca
roshanca / jquery.easing.js
Created October 28, 2014 03:39
Easing functions
/* ============================================================
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
*
* Open source under the BSD License.
*
* Copyright © 2008 George McGinley Smith
* All rights reserved.
* https://raw.github.com/danro/jquery-easing/master/LICENSE
* ======================================================== */
@roshanca
roshanca / gray.css
Last active August 29, 2015 14:08
网站变灰 CSS
body {
-webkit-filter:grayscale(100%);
-moz-filter:grayscale(100%);
-ms-filter:grayscale(100%);
-o-filter:grayscale(100%);
filter:grayscale(100%);
filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
filter:gray;
-webkit-transform: translateZ(0); /* 解决在 Retina 屏幕下显示变模糊的问题 */
}
_.mixin({
// This will parse a delimited string into an array of
// arrays. The default delimiter is the comma, but this
// can be overriden in the second argument.
CSVtoJSON: function( strData, strDelimiter ){
// Check to see if the delimiter is defined. If not,
// then default to comma.
strDelimiter = (strDelimiter || ",");
// FIX: add an ending carriage return if missing
@roshanca
roshanca / scrollIntoView.example.html
Created November 13, 2014 10:32
element.scrollIntoView(alignWithTop); alignWithTop 如果为true,则节点被滚动到滚动区域的上边界。如果为false,节点出现在下边界。
<!DOCTYPE html>
<html>
<head>
<title>ScrollIntoView() example</title>
<script type="text/javascript">
function showIt(elID) {
var el = document.getElementById(elID);
el.scrollIntoView(true);
}
@roshanca
roshanca / .editorconfig
Created December 31, 2014 16:37
General .editorconfig
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@roshanca
roshanca / Makefile
Last active August 29, 2015 14:14 — forked from bpierre/Makefile
# JS files
JS_FINAL = js/project-name-all.js
JS_TARGETS = js/file1.js \
js/file2.js \
js/file3.js
# CSS files
CSS_FINAL = css/project-name-all.css
STYLUS_TARGETS = css/file1.styl \
FROM ubuntu:14.04
MAINTAINER Pan Jiabang, [email protected]
RUN \
# use aliyun's mirror for better download speed
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
apt-get update && \
apt-get install -y nodejs curl git-core && \
# use nodejs as node