Skip to content

Instantly share code, notes, and snippets.

➜ lovecraft git:(master) make up
docker-compose -p lovecraft -f docker-compose.yml up -d proxy
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/compose/compose/cli/main.py", line 55, in main
File "/compose/compose/cli/docopt_command.py", line 23, in sys_dispatch
File "/compose/compose/cli/docopt_command.py", line 26, in dispatch
File "/compose/compose/cli/main.py", line 172, in perform_command
File "/compose/compose/cli/command.py", line 52, in project_from_options
File "/compose/compose/cli/command.py", line 87, in get_project
@debnath
debnath / gist:9ac1e1548a4cc7c6041d4ed744e3a5dd
Created March 21, 2017 04:49
Working ubuntu install script for dynamodb (As of 21-march-2017)
#!/bin/bash
DYNAMODB_USER=vagrant
sudo apt-get install openjdk-7-jre-headless -y
cd /home/${DYNAMODB_USER}/
mkdir -p dynamodb
cd dynamodb
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.:
{
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",
@debnath
debnath / paperclips-savegame
Last active June 5, 2024 15:30
How to save and load the state of the paperclips game (www.decisionproblem.com/paperclips/index2.html)
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+"')
@debnath
debnath / gitu
Created November 10, 2017 03:36
function gitu {
BRANCH=${1:-master}
echo "Checking out $BRANCH"
git checkout "$BRANCH" && git fetch origin && git merge --ff-only origin/"$BRANCH"
}
@debnath
debnath / gist:ff084e83d77dae8aafd737c6ca510958
Created December 1, 2017 03:43
Tracing Golang app execution
f, err := os.Create("cpu.trace")
if err != nil {
panic(err)
}
trace.Start(f)
defer trace.Stop()
@debnath
debnath / gist:a9879ffd5492113e7db2a33f016ced8c
Created December 4, 2017 03:20
Redis script to delete all keys starting with a prefix
redis-cli KEYS "PREFIX*" | xargs -L 100 redis-cli DEL
@debnath
debnath / gist:05e16ecc0177543f17c7a6b9e6b12703
Last active December 6, 2017 03:27
Failed experiment: strings.join vs buffer.WriteString
start := time.Now()
/*
var buffer bytes.Buffer
for _, x := range v {
buffer.WriteString(x)
buffer.WriteString("::")
}
test := strings.ToLower(buffer.String()) */
@debnath
debnath / gzip
Created January 3, 2018 03:14
gzip / gunzip functions
//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)
}