Skip to content

Instantly share code, notes, and snippets.

View codenoid's full-sized avatar

codenoid

  • Wonogiri, Jawa Tengah
  • 06:23 (UTC +07:00)
View GitHub Profile
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 September 22, 2022 20:31
Golang Upload -> Resize -> Return modified image
curl -F "file=@input.jpg" http://localhost:8080/upload --output result.jpg
@codenoid
codenoid / curl.sh
Last active December 25, 2023 09:09
s.id Shortlink Generator Public API
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'
@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 / 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})
_ ->
@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)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Login</title>
<style type="text/css" media="screen">
form {
margin:0 auto;
width:300px