This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Mostly for JS projects | |
| # | |
| # In the scenario where you end up with multiple same name files, | |
| # e.g. `my-component.tsx` `my-component.spec.ts` `my-component.module.css` | |
| # | |
| # It is much tidier to put all related files inside a folder and use an index file naming convention | |
| # e.g. `my-component/index.tsx` `my-component/index.spec.ts` `my-component/index.module.css` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "io" | |
| "net/http" | |
| "os" | |
| "strings" | |
| ) | |
| func dummmy(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "golang.org/x/text/language" | |
| "golang.org/x/text/message" | |
| ) | |
| // create a new printer withe the locale set to english | |
| var print = message.NewPrinter(language.English) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module dummy/foo | |
| go 1.14 | |
| require ( | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ( | |
| "io" | |
| "log" | |
| "io" | |
| "net/http" | |
| ) | |
| func dumpResponse(r http.Response) { | |
| io.Copy(os.Stdout, r.Body) | |
| log.Println("") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getPromise = function (resolveValue) { | |
| return Promise.resolve({ result: resolveValue }); | |
| }; | |
| const handleUsingThen = function () { | |
| return getPromise("doA").then((res) => res.result); | |
| }; | |
| const handleAsync = async function () { | |
| const res = await getPromise("doB"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const getDelayed = function (resolveVal) { | |
| return new Promise((resolve) => | |
| setTimeout(() => resolve("delayed: " + resolveVal), 2000) | |
| ); | |
| }; | |
| const func1 = function () { | |
| console.log("Hello func1"); | |
| return getDelayed("func1"); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const doFoo = (passedObj) => { | |
| passedObj.foo = true; | |
| passedObj.bar = false; | |
| return { | |
| cat: 'meow', | |
| passedObj | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { someApiCall } from './' | |
| const myService = async function(parameter, passedObject) { | |
| const restResponse = await someRestCall(parameter); | |
| passedObject.details = restResponse[0]; | |
| return { | |
| content: restResponse.foo, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Option A | |
| Integer totalFixedRateResultCount = fixedRateCounts | |
| .stream() | |
| .reduce(0, (aggValue, current) -> { | |
| Integer value = (Integer) current.getValue(); | |
| return aggValue + value; | |
| }, (aLong1, aLong2) -> aLong1); | |
| // Option B | |
| Integer totalFixedRateResultCount = fixedRateCounts |
NewerOlder