Skip to content

Instantly share code, notes, and snippets.

View cary205's full-sized avatar
:octocat:
(ㄏ ̄□ ̄)ㄏ

Cary Wu cary205

:octocat:
(ㄏ ̄□ ̄)ㄏ
View GitHub Profile
@cary205
cary205 / git_rebase.md
Created May 27, 2019 02:19 — forked from ravibhure/git_rebase.md
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

var doSomethingForALongTime = function (params) {
console.log("doSomethingForALongTime, params: " + params);
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log("DONE");
resolve(params + 1);
}, 3000);
})
}
@cary205
cary205 / double-number.js
Created June 10, 2019 05:24 — forked from joepie91/double-number.js
CommonJS module example
module.exports = function(number) {
return number * 2;
}
@cary205
cary205 / my-module.js
Created June 10, 2019 08:14
ES6 module
function cube(x) {
return x * x * x;
}
const foo = Math.PI + Math.SQRT2;
var graph = {
options: {
color:'white',
thickness:'2px'
@cary205
cary205 / curl.md
Last active July 9, 2019 06:45 — 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.

List<String> list = new ArrayList<>();
Predicate<String> pdr = new Predicate<String>() {
public boolean test(String t) {
return t.equals("RED");
}
};
ToIntFunction<String> tif = new ToIntFunction<String>() {
public int applyAsInt(String value) {
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName=" + attachId);
//<form id="sampleForm" name="sampleForm" enctype="multipart/form-data" action="" method="post">
if("jpg".equals(dataObject.getString("FILEFORMAT").toLowerCase())){
response.setContentType("image/jpeg");
} else if("jpeg".equals(dataObject.getString("FILEFORMAT").toLowerCase())){
response.setContentType("image/jpeg");
} else if("gif".equals(dataObject.getString("FILEFORMAT").toLowerCase())){
@cary205
cary205 / prototype.js
Last active July 29, 2019 06:15
prototype chain
class Animal {};
class Cat extends Animal {};
class Garfield extends Cat {};
let gfMaow = new Garfield();
console.log("typeof: " + typeof Animal); //typeof: function
console.log(Animal instanceof Function); //true
console.log(Animal instanceof Object); //true
@cary205
cary205 / CAPTURING_BUBBLING.html
Last active July 31, 2019 01:48
DOM CAPTURING & BUBBLING
<html>
<head>
<title>test title</title>
</head>
<body id="mybody">
<ul id="myul">
<li id="li1">1</li>
<li id="li2">2</li>
@cary205
cary205 / my-default-module.mjs
Created September 3, 2019 12:19
ECMAScript Modules --experimental-modules
//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
export default function cube(x) {
return x * x * x;
}
/* SyntaxError: Duplicate export of 'default'
export default function xube(x) {
return x * x * x * x;
}