Skip to content

Instantly share code, notes, and snippets.

@roshanca
roshanca / OpenGG.Clean.Player.js
Created June 5, 2012 04:54
OpenGG.Clean.Player 去除优酷和土豆播放器中的黑屏和广告 支持firefox, chrome, opera, 搜狗浏览器, 360高速浏览器
// ==UserScript==
// @name OpenGG.Clean.Player
// @namespace http://OpenGG.me
// @description OpenGG.Clean.Player
// @version 1.26
// @updateURL https://userscripts.org/scripts/source/120679.meta.js
// @downloadURL https://userscripts.org/scripts/source/120679.user.js
// @match http://*/*
// @match https://*/*
// @exclude http://www.kuaipan.cn/*
@roshanca
roshanca / blog_preview.applescript
Last active February 4, 2023 18:31
Octopus: Workflow of creating a new post || previewing
global projectDir
set homePath to POSIX path of (path to home folder)
set projectDir to homePath & "Ruby_app/Blog"
on goToProjectDir()
return "cd " & projectDir
end goToProjectDir
on serveWithJekyll()
return "bundle exec jekyll serve --watch"
@roshanca
roshanca / Preferences.sublime-settings
Created November 30, 2012 08:56
My settings of Sublime Text 2
{
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
"CVS",
".idea"
],
"highlight_line": true,
@roshanca
roshanca / subString.js
Created December 5, 2012 09:35
截取指定长度的中英文混合字符串
/**
* 截取指定长度的中英文混合字符串
* @param {String} str 待截取的字符串
* @param {Number} n 截取长度(中文字符为英文的 double)
* @return {String} 截取后的字符串
*/
function subString(str, n) {
var r = /[^\x00-\xff]/g;
var m;
@roshanca
roshanca / Default (OSX).sublime-keymap
Created December 7, 2012 02:14
DIY keymap for sublime text 2
[
{ "keys": ["ctrl+s"], "command": "toggle_side_bar" },
{ "keys": ["super+shift+."], "command": "expand_selection", "args": {"to": "scope"} },
{ "keys": ["alt+/"], "command": "auto_complete" },
{ "keys": ["alt+/"], "command": "replace_completion_with_auto_complete", "context":
[
{ "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false },
@roshanca
roshanca / loadScript.js
Created December 10, 2012 14:49
异步加载脚本的基本代码
(function (d, s, f) {
s = d.createElement('script');
s.async = 'async';
s.src = 'path/to/file.js';
f = d.getElementsByTagName('script')[0];
f ? f.parentNode.insertBefore(s, f) : d.body.appendChild(s);
})(document);
@roshanca
roshanca / guide.js
Last active December 14, 2015 13:58
自定义属性 "data-guide-index" 的值为数字,代表引导层出场次序。 比如 `<h2 class="title" data-guide-index="1">` ,表示引导第一步的定位点。另引导展示层的 class 为 guide-step,id 为 guideStep + 数字,用于应用样式。
/**
* 界面引导帮助
*/
function Guide() {
this.target_arr = [];
this.intervalID = null;
}
Guide.prototype.init = function() {
var _this = this;
@roshanca
roshanca / ping.js
Created August 1, 2013 01:58
use to test ping.
function ping(ip) {
var img = new Image();
var start = new Date().getTime();
img.src = 'http://' + ip + '?t=' + start;
var flag = false;
img.onload = function () {
flag = true;
console.log('ok');
}
@roshanca
roshanca / dateFormat.js
Created August 2, 2013 03:13
对日期进行格式化
/**
* 对日期进行格式化
* @param date 要格式化的日期
* @param format 进行格式化的模式字符串
* @return String
*/
function dateFormat(date, format) {
if(format === undefined){
format = date;
date = new Date();
@roshanca
roshanca / config.rb
Created December 17, 2013 03:19
compass config file example
# Publishing paths
http_path = "/"
http_images_path = "/assets/images"
http_generated_images_path = "/assets/images"
http_fonts_path = "/assets/fonts"
css_dir = "source/assets/css"
# Local development paths
sass_dir = "sass"
images_dir = "source/assets/images"