Skip to content

Instantly share code, notes, and snippets.

🔥
Web Engineer

Rubi codenoid

🔥
Web Engineer
View GitHub Profile
View golang-net-http-count-goroutine.go
package main
import (
"fmt"
"net/http"
"runtime"
"time"
)
func main() {
@codenoid
codenoid / app.py
Last active Apr 23, 2020
Flask handle 404 with rickroll
View app.py
@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
View space_age.go
package space
import "math"
type Planet string
var orbitalPeriod = map[string]float64{
"Mercury": 0.2408467,
"Venus": 0.61519726,
"Earth": 1.0,
@codenoid
codenoid / curl.sh
Last active Dec 28, 2019
Golang Upload -> Resize -> Return modified image
View curl.sh
curl -F "file=@input.jpg" http://localhost:8080/upload --output result.jpg
@codenoid
codenoid / curl.sh
Last active Dec 20, 2019
s.id Shortlink Generator Public API
View curl.sh
curl 'https://s.id/api/public/link/shorten' -H 'User-Agent: Chrome/62.0 (BSD x86_64; rv:71.0) Gecko/20100101 Firefox/71.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'X-Requested-With: XMLHttpRequest' -H 'Origin: https://s.id' -H 'Connection: keep-alive' -H 'Referer: https://s.id/' --data 'url=https%3A%2F%2Fne.com'
View before_request.go
package main
import (
"log"
"net/http"
)
import (
"github.com/julienschmidt/httprouter"
)
@codenoid
codenoid / api_controller.ex
Created Jun 26, 2019
phoenix + mongo crud
View api_controller.ex
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})
_ ->
You can’t perform that action at this time.