Skip to content

Instantly share code, notes, and snippets.

@cyio
cyio / proxy.worker.js
Created June 12, 2022 13:35 — forked from abersheeran/proxy.worker.js
A proxy download cloudflare worker
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
async function handleRequest(request) {
console.log(`${request.method} ${request.url}`)
@cyio
cyio / install-ripgrep-on-ubuntu.sh
Last active July 17, 2019 08:21
Install ripgrep on Debian / Ubuntu
#!/bin/bash
[[ $UID == 0 ]] || { echo "run as sudo to install"; exit 1; }
if ! [ -x "$(command -v jq)" ]; then
echo 'Error: jq is not installed.' >&2
apt install jq -y
fi
REPO="https://github.com/BurntSushi/ripgrep/releases/download/"
RG_LATEST=$(curl -sSL "https://api.github.com/repos/BurntSushi/ripgrep/releases/latest" | jq --raw-output .tag_name)
@cyio
cyio / bind.js
Last active March 14, 2017 10:11
实现 bind 方法,用于不支持ES5的浏览器
// Credit to Douglas Crockford for this bind method​
if (!Function.prototype.bind) { // 如果不存在 bind 方法
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") { // bind 方法的调用对象只能是函数,如果不是则抛出异常
// closest thing possible to the ECMAScript 5 internal IsCallable function​
throw new TypeError ("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call (arguments, 1), // 浅复制 bind 的参数,从第 2 个开始到结束 http://stackoverflow.com/a/26618338/5657916
fToBind = this,
@cyio
cyio / localStorage.js
Last active September 20, 2016 10:56 — forked from anhang/localStorage.js
HTML5 Local Storage with Expiration
AZHU.storage = {
save : function(key, jsonData, expirationMin){
if (!Modernizr.localstorage){return false;}
var expirationMS = expirationMin * 60 * 1000;
var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS}
localStorage.setItem(key, JSON.stringify(record));
return jsonData;
},
load : function(key){
if (!Modernizr.localstorage){return false;}
@cyio
cyio / workstation
Created August 15, 2016 13:54 — forked from moesy/._wild-cherry.zsh-theme
Provision scripts for workstations
# Ubuntu
# OSX
@cyio
cyio / signapk.sh
Created July 25, 2016 02:47 — forked from TommyLau/signapk.sh
Android sign apk
#!/bin/bash
# Sample usage is as follows;
# ./signapk myapp.apk debug.keystore android androiddebugkey
#
# param1, APK file: Calculator_debug.apk
# param2, keystore location: ~/.android/debug.keystore
# param3, key storepass: android
# param4, key alias: androiddebugkey
USER_HOME=$(eval echo ~${SUDO_USER})
@cyio
cyio / chrome_extension_get_cookie.js
Created July 11, 2016 16:52 — forked from neekey/chrome_extension_get_cookie.js
Chrome 插件获取指定域下的Cookie,代码示例
#!/bin/bash
###################################
# Usage: sudo ./installer.sh [os] #
###################################
OS=$1;
UBUNTU="";
#############
@cyio
cyio / twicli_elsewhither.css
Last active January 18, 2016 11:07 — forked from tkawa/twicli_elsewhither.css
twicli用CSS Elsewhitherをベースに、Old Twitterになんとなく似せる感じ
@charset "utf-8";
/* ----- twicli.css ----- */
/*
twicli用CSS Elsewhither(http://else.jimdo.com/others/storage/)をベースに、
Old Twitterになんとなく似せる感じ
*/
@import url('//cdn.bootcss.com/font-awesome/4.4.0/css/font-awesome.min.css');
* {
@cyio
cyio / twicli.css
Created January 16, 2016 07:12 — forked from monsier-oui/twicli.css
twicli CSS
@charset "UTF-8";
/* アイコンフォント読み込み */
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css');
/**
* 全体
*/
* {
outline: none;