Skip to content

Instantly share code, notes, and snippets.

View sjy's full-sized avatar
🎯
Focusing

Johnson sjy

🎯
Focusing
View GitHub Profile
@sjy
sjy / switch-to-rbenv.md
Created July 16, 2023 00:20 — forked from traumverloren/switch-to-rbenv.md
Switch from RVM to rbenv

Switch from RVM to rbenv:

Get Rid of RVM if it's installed:

rvm implode

Cleanup your .bash_profile/.bashrc/.zshrc file to remove RVM from the path:

You should have something like this left from RVM. Delete it from the file. ``[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"```

@sjy
sjy / get-npm-package-version
Created May 6, 2020 13:02 — forked from DarrenN/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION
@sjy
sjy / RequestQuene.js
Created January 23, 2019 12:25
quene with max parallel task limits
export default class RequestQuene {
constructor(limits = 10, duration = 200) {
this.duration = duration
this.limits = limits
this.q = []
this.intervalId = null
this.intervalDuration = duration
this.numOfRunning = 0
}
@sjy
sjy / gist:e6b3835b523d2e01579597d3a8153596
Created November 28, 2018 13:42 — forked from wumpz/gist:5846559
list authors of a git repository including commit count and email
git shortlog -e -s -n
@sjy
sjy / dataURL to blob and blob to dataURL
Created October 23, 2018 08:48 — forked from wuchengwei/dataURL to blob and blob to dataURL
dataURL to blob and blob to dataURL
//**dataURL to blob**
function dataURLtoBlob(dataurl) {
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
while(n--){
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], {type:mime});
}
@sjy
sjy / slide-template.md
Created September 11, 2018 08:43
reveal ppt js
theme progresss controls slideNumber overview loop history
white
true
true
false
true
true
true
@sjy
sjy / curl.md
Created June 10, 2018 03:47 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@sjy
sjy / vanilla-ajax-poll.js
Created May 29, 2018 11:40 — forked from twmbx/vanilla-ajax-poll.js
Polling in JS with an async ajax call that returns a promise ( modified from: https://davidwalsh.name/javascript-polling )
// The polling function
function poll(fn, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
var checkCondition = function(resolve, reject) {
var ajax = fn();
// dive into the ajax promise
ajax.then( function(response){
// If the condition is met, we're done!
@sjy
sjy / float-regex.js
Created March 2, 2018 07:51
Valid Digit Number Pattern
const pattern = /^[1-9]\d{0,4}(\.\d{0,2})?$|^0(\.\d{0,2})?$/;
@sjy
sjy / .prettierrc
Last active January 2, 2018 16:07
prettier config
{
"arrowParens": "avoid",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"printWidth": 100,
"proseWrap": "preserve",