Skip to content

Instantly share code, notes, and snippets.

Kaveh Shahbazian dc0d

Block or report user

Report or block dc0d

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dc0d
dc0d / persian_calendar.ex
Created Oct 31, 2018
Persian Calendar Functions for Elixir
View persian_calendar.ex
defmodule PersianCalendar do
@moduledoc """
for converting persian calendar to/from gregorian calendar
"""
@breaks [
-61,
9,
38,
199,
@dc0d
dc0d / git-notes.md
Last active Jul 9, 2018
working with private or public git repos
View git-notes.md

The way - in my experience - is to use SSH keys. GPG keys should work similarly but I have not used them.

I have generated them once (using GitHub, but could be any other tool). Then uploaded them to all my other accounts (GitHub, GitLab, etc).

They must reside at ~/.ssh. Then the permissions must be set:

$  sudo chmod 600 ~/.ssh/id_rsa
$  sudo chmod 600 ~/.ssh/id_rsa.pub
@dc0d
dc0d / badger-lab.go
Created Jun 8, 2018
seek/prefix not working as expected in badger (according to this)
View badger-lab.go
package main
// commit cdf9ffb40fde980875360cf2b1f7d66946fdc769 of badger
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
@dc0d
dc0d / fsm.go
Last active Jul 2, 2018
simple fsm
View fsm.go
package main
// activate activates the (start) state and it's consecutive
// states until the next state is nil.
func activate(s state) {
next := s
for next != nil {
next = next()
}
return
@dc0d
dc0d / main.go
Last active Apr 25, 2018
unseen field
View main.go
package main
import (
"go/importer"
"go/types"
"log"
)
func main() {
const smplpkg = "fully-specified-import-path/smplpkg"
@dc0d
dc0d / Accept What You Need.go
Created Apr 15, 2018
:blog define what you need
View Accept What You Need.go
type Logger interface {
Debug(args ...interface{})
Error(args ...interface{})
Panic(args ...interface{})
}
@dc0d
dc0d / Accept What You Need.go
Created Apr 15, 2018
:blog accept what you need
View Accept What You Need.go
func ExtractRSS(debug func(args ...interface{})) (*RSSInfo, error) {
// ...
}
@dc0d
dc0d / Loading Config.ex
Created Apr 15, 2018
:blog loading config in Elixir 02
View Loading Config.ex
def read_config!(), do: Jason.decode!(File.read!("config.json"))
@dc0d
dc0d / Loading Config.ex
Created Apr 15, 2018
:blog loading config in Elixir 01
View Loading Config.ex
def read_config() do
with {:ok, contents} <- File.read("config,json"), do: Jason.decode(contents)
end
@dc0d
dc0d / Loading Config.go
Last active Apr 15, 2018
:blog loading config in Go 01
View Loading Config.go
func readConfig() (*config, error) {
raw, err := ioutil.ReadFile("config.json")
if err != nil {
return nil, err
}
var decoded config
err = json.Unmarshal(raw, &decoded)
if err != nil {
return nil, err
You can’t perform that action at this time.