Skip to content

Instantly share code, notes, and snippets.

@ziluo
ziluo / setCursor
Created August 27, 2014 01:18
让光标定位于input的内容的最后
function setCursor(input) {
input.focus()
if (window.netscape) {
setTimeout(function() { //方法一 W3C,不过除firefox的浏览器可以直接用input.value = input.value搞定
var n = input.value.length
input.setSelectionRange(n, n);
input.focus()
}, 0)
var n = input.value.length //方法二
input.selectionStart = n
@tetsuharuohzeki
tetsuharuohzeki / safe-parse.js
Last active August 29, 2015 14:05
DOMParser/DOMImplementation.createHTMLDocumentで安全なDOMの構築. とりあえずPrestoでは使えないし、IE8も確かダメ。
"use strict";
// MIT License
// author: Tetsuharu OHZEKI
/*
* Parse from HTML text to DOM subtree which does not have scripting items.
*
* @param {string} aText
* @return {DocumentFragment}
@yanyaoer
yanyaoer / slowy
Last active December 11, 2015 03:09
Alfred Extensions: set bandwidth limit,
#!/bin/bash
# USEAGE:
# slowy "remove latest limiter
# slowy 20 "set limiter as 20KByte/s for 80 port
# another choice (http://slowyapp.com/)
if [ {query} ]; then
sudo ipfw pipe 1 config bw {query}KByte/s && sudo ipfw add 1 pipe 1 src-port 80
echo 'bandwidth.max is {query}KByte/s for 80 port'
else
@SerhoLiu
SerhoLiu / supervisord.sh
Created June 20, 2012 14:02 — forked from danmackinlay/supervisord.sh
an init.d script for supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.