Skip to content

Instantly share code, notes, and snippets.

@crufter
crufter / db.go
Created September 20, 2021 13:53
M3o DB api toy increment/decrement toy example
package main
import (
"fmt"
"net/http"
"os"
m3o "github.com/micro/services/clients/go"
db "github.com/micro/services/clients/go/db"
)
@crufter
crufter / gist:2ed2356397ecf640444bf393e9fa1c39
Created January 7, 2021 14:45
install openapi plugin for make
go get github.com/zchee/protoc-gen-openapi
npm install redoc -g
npm install redoc-cli -g
@crufter
crufter / 1backend-install.md
Last active February 11, 2018 13:25
1Backend installation locally (or anywhere)

Install 1Backend with only 4 lines:

# Start mysql container. Comes with the database schema preloaded.
sudo docker run -e MYSQL_ROOT_PASSWORD=root --name 1backend-mysql -p=3306:3306 -d 1backend/mysql

# Start redis container.
sudo docker run -p=6379:6379 --name 1backend-redis -d redis redis-server --appendonly yes

# Wait a tiny bit for the MySQL and Redis containers to start up.
@crufter
crufter / free-web-app-hosting.md
Created February 8, 2018 20:07
Free web application hosting

Free web hosting

Host your applications for free on https://1backend.com.

The platform enables you to launch Golang, NdeJS, TypeScript and many more applications with only a single click of a button.

@crufter
crufter / 1backend-config.json
Last active February 5, 2018 10:18
Example 1backend config file - should be put in /var/1backend-config.json
{
"SiteUrl": "http://127.0.0.1",
"StripeKey": "sk_test_your_stripe_test_Key",
"SendGridKey": "your_sendgrid_api_key",
"Path": "/home/crufter/code/src/github.com/1backend/1backend/backend",
"ApiGeneration": {
"Enabled": true,
"GithubOrganisation": "1backend-test",
"GithubUser": "1backend-bot",
"GithubPersonalToken": "your_personal_token"
@crufter
crufter / heroku-alternative.md
Last active January 3, 2018 09:42
Cheaper Heroku alternative

Cheaper, consumption based heroku alternative

https://github.com/1backend/1backend <--- You can drop this on your dedicated own server or servers and cut costs immensely.

Alternatively use the managed version at https://1backend.com and live a worry free life.

You can even get a ton of free credits. For startups and nonprofits who make a lot of calls custom pricing is available.

@crufter
crufter / gist:7357370
Created November 7, 2013 16:22
Haskell stuff
import Data.List
import Data.List.Split
isEven x = rem x 2 == 0
isLong x = length x > 2
ftext xs = filter isLong . concat . map tails $ splitOn " " xs
doubleChars cs = concat $ map (\c->[c,c]) cs
LEIN_ROOT <path-to-leiningen>
LEIN_JAR %LEIN_ROOT%\leiningen-20.0.0-preview10.jar
JAVA_HOME <path to java>
and to PATH add %LEIN_ROOT%
-- This works
import Network.Wai
app Request{requestMethod = m, pathInfo = p} = do
case (m, p) of
("GET", []) -> return index
_ -> return notFound
-- But not this
import qualified Network.Wai as Wai
app Wai.Request{requestMethod = m, pathInfo = p} = do
@crufter
crufter / gist:4317823
Created December 17, 2012 12:03
Not working hello world webserver in Haskell
import Control.Monad
import System.IO
import Network
main = withSocketsDo $ do
sock <- listenOn (PortNumber 9000)
putStrLn "Listening on port 9000"
forever $ do
(handle, hostname, port) <- accept sock
x <- hGetContents handle