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 middleware | |
| import ( | |
| "log" | |
| "net/http" | |
| "github.com/labstack/echo" | |
| ) | |
| /* |
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 ( | |
| "fmt" | |
| "sync" | |
| ) | |
| func main() { | |
| var wg sync.WaitGroup | |
| var m sync.Map |
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
| //Gzip will take an uncompressed bytestream and gzip it | |
| func Gzip(unzip []byte) []byte { | |
| var zip bytes.Buffer | |
| gz := gzip.NewWriter(&zip) | |
| if _, err := gz.Write(unzip); err != nil { | |
| panic(err) | |
| } | |
| if err := gz.Flush(); err != nil { | |
| panic(err) | |
| } |
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
| start := time.Now() | |
| /* | |
| var buffer bytes.Buffer | |
| for _, x := range v { | |
| buffer.WriteString(x) | |
| buffer.WriteString("::") | |
| } | |
| test := strings.ToLower(buffer.String()) */ |
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
| redis-cli KEYS "PREFIX*" | xargs -L 100 redis-cli DEL |
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
| f, err := os.Create("cpu.trace") | |
| if err != nil { | |
| panic(err) | |
| } | |
| trace.Start(f) | |
| defer trace.Stop() |
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
| function gitu { | |
| BRANCH=${1:-master} | |
| echo "Checking out $BRANCH" | |
| git checkout "$BRANCH" && git fetch origin && git merge --ff-only origin/"$BRANCH" | |
| } |
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
| The paperclips game over at www.decisionproblem.com/paperclips/index2.html is great, but if you want to play the game indefinitely you can lose all progress if you clear browser cache or change laptop. | |
| I wanted a way to create a save file and load it later, so I did. Use the below script to generate the output to load the current game state. | |
| var saveGame=localStorage.getItem("saveGame"),savePrestige=localStorage.getItem("savePrestige"),saveProjectsActive=localStorage.getItem("saveProjectsActive"),saveProjectsFlags=localStorage.getItem("saveProjectsFlags"),saveProjectsUses=localStorage.getItem("saveProjectsUses"),saveStratsActive=localStorage.getItem("saveStratsActive"),restoreString="/************* COPY ALL TEXT BELOW THIS LINE AND SAVE IN A TEXTFILE SOMEWHERE. RUN IT IN ANY CHROME OR FIREFOX CONSOLE TO LOAD IT. *************/\nlocalStorage.setItem('saveGame', '"+saveGame+"') \nlocalStorage.setItem('savePrestige', '"+savePrestige+"') \nlocalStorage.setItem('saveProjectsActive', '"+saveProjectsActive+"') |
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
| Website only has kilojoule/calorie info so that's all we'll render I guess. Maybe I can estimate the protein... | |
| Mock data: | |
| POST /api/v1/nutrition/salad | |
| { | |
| "size": "small", | |
| "data": [ | |
| { | |
| "id": "chicken_pasta", |
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
| There are 2 possibilities I can think of to organise the data cleanly. | |
| Option 1) | |
| * Have 2 JSON objects. | |
| * One that is just a map between the salad name and the id. We can then pass ids from the form to the calculator functions. | |
| * The other json object contains all the actual data. | |
| E.g.: | |
| { |
NewerOlder