Skip to content

Instantly share code, notes, and snippets.

View egasus's full-sized avatar
🏠
Working from home

Colbert L. egasus

🏠
Working from home
  • remote
View GitHub Profile
####################
## docker ##
####################
alias docker-rm-none="docker rmi $(docker images | grep none | awk '{print $3F}')"
alias docker-stop-all="docker stop `docker container ls -aq`"
alias docker-rm-all="docker container rm `docker container ls -aq`"
#####################
## git ##
#####################
function countNonDigits(n) {
var cnt = 0;
while (n > 0) {
var r = n%10;
if (r !=0) {
cnt++;
}
n = (n-r) /10 ;
}
return cnt;
function arrangeStudents(boys,girls) {
// Write your code here
// if (Math.abs(a.length - b.length)>1) {
// return false;
// }
if (boys.length != girls.length) {
return false;
}
// STRING OPERATORS
// "0"*10
console.log(`"0"*10 == `, "0".repeat(10));
// substr in str
console.log(`substr in str ==`, "abc".indexOf("ab")>=0);
console.log(`substr in str ==`, "abc".includes("ab"));
// ','.join([1,2,3,4])
console.log(`','.join([1,2,3,4]) == `, [1,2,3,4].join(","));
// "1,2,3,4".split(',')
console.log(`"1,2,3,4".split(',') == `, "1,2,3,4".split(","));
// STRING OPERATORS
// "0"*10
console.log(`"0"*10 == `, "0".repeat(10));
// substr in str
console.log(`substr in str ==`, "abc".indexOf("ab")>=0);
console.log(`substr in str ==`, "abc".includes("ab"));
// ','.join([1,2,3,4])
console.log(`','.join([1,2,3,4]) == `, [1,2,3,4].join(","));
// "1,2,3,4".split(',')
console.log(`"1,2,3,4".split(',') == `, "1,2,3,4".split(","));
@egasus
egasus / gist:03810f9dc7f8f5c325091cc874c29d05
Created June 23, 2022 13:46 — forked from metaphox/gist:1755841
General principles for good URI design
General principles for good URI design:
Don't use query parameters to alter state
Don't use mixed-case paths if you can help it; lowercase is best
Don't use implementation-specific extensions in your URIs (.php, .py, .pl, etc.)
Don't fall into RPC with your URIs
Do limit your URI space as much as possible
Do keep path segments short
Do prefer either /resource or /resource/; create 301 redirects from the one you don't use
Do use query parameters for sub-selection of a resource; i.e. pagination, search queries
@egasus
egasus / recover_source_code.md
Created May 13, 2019 08:41 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb