Skip to content

Instantly share code, notes, and snippets.

@chainat
chainat / gist:4b43a7298a205fbd04fcefaf0838f21a
Created May 9, 2019 01:46
Search for non-ascii characters in the files
REGEX = [^\x00-\x7F]
@chainat
chainat / gist:e2d4d806b8b1a3ddb6d5b8400e1e30ea
Last active May 28, 2022 20:07
Compact local git repo
These two commands will minimise the diskspace used for the repo. Please note that Github, BitBucket run this all the time to minimise the diskspace.
Suggestion: Run as often as you can (i.e. once a week for small working-in-progress repo, one in every few days if many people work together).
It's no harm to run it often, cron or system task could be an option too.
# Clean unused commits
`git reflog expire --all --expire=now`
# Compact the disk by remove unneccesary files from the local git repository
`git gc --aggressive --prune=now`
@chainat
chainat / gist:825ac2a9da50989f3f55
Created April 6, 2015 23:30
Check duplicate html element ID on the page
(function findDuplicateIds(){
var ids = {};
var all = document.all || document.getElementsByTagName("*");
for(var i=0, l=all.length; i<l; i++){
var id = all[i].id;
if(id){
if(ids[id]){
console.log("Duplicate id: #" + id);
} else {
ids[id] = 1;