Skip to content

Instantly share code, notes, and snippets.

@shospodarets
shospodarets / delete-local-branches-except-the-current.sh
Last active March 5, 2025 14:02
Delete all the local Git branches except the current one
#!/usr/bin/env bash
git branch | grep -v (git rev-parse --abbrev-ref HEAD) | xargs git branch -D
//This is an improved version of https://gist.github.com/akhilrex/532991ac60d33deae4b61cfb137a3152
// A lot of users were complaining that the original script does not stop and keeps going on page after page. This could cause older
//machines to get slow and incur a lot of data consumption. So the new script now has paging in it.
//You see the window.pg variable at the top of the script. That is all you need to be concerned about. That is the number of pages the
//script will now go through. Usage of the script is the same as of the original one.
window.pg = 3;
window.interval = window.setInterval(function() {
@kosamari
kosamari / _ServiceWorker_for_github_pages.md
Last active March 8, 2026 20:01
ServiceWorker for github pages.

ServiceWorker for github pages

This is a ServiceWorker template to turn small github pages into offline ready app.

Why ?

Whenever I make small tools & toys, I create github repo and make a demo page using github pages (like this one).
Often these "apps" are just an index.html file with all the nessesary CSS and JavaScript in it (or maybe 2-3 html/css/js files). I wanted to cache these files so that I can access my tools offline as well.

Notes

Make sure your github pages have HTTPS enforced, you can check Settings > GitHub Pages > Enforce HTTPS of your repository.

@moesy
moesy / ._wild-cherry.zsh-theme
Last active August 22, 2016 00:45
Provision scripts for workstations
@Erichain
Erichain / installAndroidSDKOnMac.md
Last active April 23, 2026 03:58
Mac OS下安装和配置android-sdk

##MAC OS下安装和配置android-sdk

###安装

在MAC上安装android-sdk,标准的安装方法是使用homebrew,运行如下命令:

brew update

brew install android-sdk

@ericelliott
ericelliott / gitclean.sh
Created January 31, 2016 04:57
gitclean.sh - cleans merged/stale branches from origin
git remote prune origin
git branch -r --merged master | egrep -iv '(master|develop)' | sed 's/origin\///g' | xargs -n 1 git push --delete origin
@nevergiveup-j
nevergiveup-j / onerror
Last active June 12, 2018 06:09
前端代码异常日志收集与监控
/**
* @param {String} msg 错误信息
* @param {String} url 出错的文件
* @param {Long} line 出错代码的行号
* @param {Long} col 出错代码的列号
* @param {Object} error 错误的详细信息,Anything
*/
window.onerror = function(msg,url,line,col,error){
//没有URL不上报!上报也不知道错误
if (msg != "Script error." && !url){
@danharper
danharper / waitFor.js
Last active February 21, 2017 12:38
three ways to "waitFor" a prop to become non-null before rendering
// decorate the class, composition
function waitFor(prop) {
return ChildComponent => class extends Component {
render() {
return this.props[prop] ? <ChildComponent {...this.props} /> : null
}
}
}
// decorate the class, inheritance
@nhagen
nhagen / PromisAllWithFails.js
Last active December 23, 2025 06:42
Wait until all promises have completed even when some reject, with Promise.all
var a = ["sdfdf", "http://oooooolol"],
handleNetErr = function(e) { return e };
Promise.all(fetch('sdfdsf').catch(handleNetErr), fetch('http://invalidurl').catch(handleNetErr))
.then(function(sdf, invalid) {
console.log(sdf, invalid) // [Response, TypeError]
})
.catch(function(err) {
console.log(err);
})
@jbrooksuk
jbrooksuk / markdown.css
Created April 10, 2015 16:36 — forked from imjasonh/markdown.css
Ordered list
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}