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 / 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 / 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 / index.html
Last active October 26, 2015 07:08 — forked from jfsiii/index.html
Flexbox全屏模版
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Holy Grail</title>
<style>
/* some basic styles. nothing to do with flexbox */
header, footer,
nav, article, aside {
border: 1px solid black;
/**
*
* @author akhmad
*/
public class Application extends javax.swing.JFrame {
private Connection connection;
/**
* Creates new form Application