Skip to content

Instantly share code, notes, and snippets.

View ilmsg's full-sized avatar
😍
love me love my bug

Eak Netpanya ilmsg

😍
love me love my bug
View GitHub Profile
# It's only a POC for now
defmodule ContextBase do
@moduledoc """
Abstracts away common schema functions, such as list, get, create, update, delete, etc.
Assumes that the schema module has a `changeset` function.
Usage:
defmodule MyContext do
use ContextBase, repo: MyApp.Repo, schema: MyApp.MySchema
end
@mitchellh
mitchellh / merge_vs_rebase_vs_squash.md
Last active March 18, 2025 21:32
Merge vs. Rebase vs. Squash

I get asked pretty regularly what my opinion is on merge commits vs rebasing vs squashing. I've typed up this response so many times that I've decided to just put it in a gist so I can reference it whenever it comes up again.

I use merge, squash, rebase all situationally. I believe they all have their merits but their usage depends on the context. I think anyone who says any particular strategy is the right answer 100% of the time is wrong, but I think there is considerable acceptable leeway in when you use each. What follows is my personal and professional opinion:

@A-725-K
A-725-K / the_day_I_understood_channels.go
Created July 19, 2023 07:56
eureka-about-golang-channels
package main
import (
"fmt"
"math/rand"
"time"
"flag"
)
const (
@stevenhao
stevenhao / modal_llama2.py
Created July 18, 2023 20:30
modal script that creates llama2_image and defines a function that can run inference on it
from modal import Image, Stub, Secret, gpu
from pathlib import Path
import os
MODEL_PATH = "/model"
def download_models():
from transformers import AutoTokenizer, AutoModelForCausalLM
token = os.environ["HUGGINGFACE_TOKEN"]
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf", use_auth_token=token)
@rkibria
rkibria / gospinningcube.go
Last active May 3, 2023 09:40
Generate a .gif showing a spinning 3d wireframe cube with hidden lines in Golang
package main
import (
"fmt"
"image"
"image/color"
"image/gif"
"math"
"os"
)
// create api context
ctx := context.Background()
// get bytes from base64 encoded google service accounts key
credBytes, err := b64.StdEncoding.DecodeString(os.Getenv("KEY_JSON_BASE64"))
if err != nil {
log.Error(err)
return
}
@goodylili
goodylili / jwt.go
Created July 24, 2022 15:33
JWT tutorial in Go using the golang-jwt package
package main
import (
"encoding/json"
"fmt"
"github.com/golang-jwt/jwt"
"log"
"net/http"
"time"
)
func DoReq() error {
resp, err := http.Get("http://localhost:8080/ping")
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return errors.New("bad response")
}
@rajeshpachaikani
rajeshpachaikani / main.rs
Last active December 21, 2024 01:40
Face and Eye detection using Opencv On Rustlang
use opencv::{
Result,
prelude::*,
objdetect,
highgui,
imgproc,
core,
types,
videoio,
};
@bluzky
bluzky / request_helper.ex
Last active July 21, 2023 05:01
Elixir download/stream large file with hackney
defmodule RequestHelper do
@moduledoc """
Reference from https://gist.github.com/avdi/7990684
Stream download large file from url
"""
require Logger
@doc """
Get stream data from url
mode could be `:binary` or `:line`