Skip to content

Instantly share code, notes, and snippets.

View codenoid's full-sized avatar

codenoid

  • Wonogiri, Jawa Tengah
  • 12:24 (UTC +07:00)
View GitHub Profile
package main
import (
"fmt"
"net/http"
"runtime"
"time"
)
func main() {
@codenoid
codenoid / app.py
Last active April 23, 2020 02:59
Flask handle 404 with rickroll
@app.errorhandler(404)
def handle404(error):
html = "<center>"
html += "<br><br><br>"
html += '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?controls=0&autoplay=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
html += "<br>"
html += "nothing to do here :p"
html += "</center>"
return html
@codenoid
codenoid / main.go
Last active March 25, 2020 09:23
Golang Simple Token-Auth Example (non RFC compliant)
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"time"
)
package space
import "math"
type Planet string
var orbitalPeriod = map[string]float64{
"Mercury": 0.2408467,
"Venus": 0.61519726,
"Earth": 1.0,
@codenoid
codenoid / vapor.gif
Created October 30, 2019 15:36 — forked from xiel/vapor.1.gif
vapor.gif
@codenoid
codenoid / vapor.gif
Last active October 30, 2019 15:34 — forked from mathdroid/vapor.1.gif
vapor.gif
@codenoid
codenoid / server.go
Last active October 6, 2019 05:48
golang net/http template usage
package main
import (
"fmt"
"net/http"
)
func index(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
@codenoid
codenoid / before_request.go
Created September 8, 2019 16:33
before_request.go
package main
import (
"log"
"net/http"
)
import (
"github.com/julienschmidt/httprouter"
)
@codenoid
codenoid / api_controller.ex
Created June 26, 2019 14:27
phoenix + mongo crud
defmodule PhoenixCrudWeb.ApiController do
use PhoenixCrudWeb, :controller
# create
def insert(conn, %{"username" => username, "password" => password}) do
case Mongo.insert_one(:local_database, "users", %{username: username, password: password}) do
{:ok, _} ->
conn |> json(%{success: true})
_ ->