Skip to content

Instantly share code, notes, and snippets.

@caike
caike / issue.md
Created November 18, 2018 18:40
solving raspberry.local issue

Found this solution to address the problem where raspberry.local can't be found on the network. Run:

dscacheutil -q host -a name raspberrypi.local

Then try it again shrug

@caike
caike / attempt-to-increase-performance.md
Last active December 28, 2017 13:00
Setting up ssh and wifi on first Raspbian Strech Lite boot
@caike
caike / a-seeds.exs
Last active September 13, 2017 14:25
creating nested records with cast_assoc in Phoenix
# In this example, Video has_many authors.
# Here is the code for creating a video with authors
# using a single call to Repo.insert
Enum.map([
%{"title" => "Elixir", "duration" => 123, "authors" => [
%{"name" => "José Valim"}
]
},
%{"title" => "JavaScript", "duration" => 666, "authors" => [
%{"name" => "Brendan Eich"}
@caike
caike / install-ruby-1.8.7.sh
Last active September 18, 2017 19:34 — forked from wmakley/install-ruby-1.8.7.sh
Install Ruby 1.8.7 on Mac OSX 10.12 Sierra with rbenv
#!/bin/sh
# The main issues with Ruby 1.8.7 are that it won't build with Clang,
# and the Net::HTTPS module won't work with modern versions of OpenSSL.
#
# This assumes you have already set up homebrew, and run: xcode-select --install
#brew install homebrew/dupes/apple-gcc42
#brew install libyaml libffi
brew install https://github.com/Homebrew/homebrew-versions/raw/586b7e9012a3ed1f9df6c43d0483c65549349289/openssl098.rb
export CC=/usr/local/bin/gcc-4.2
@caike
caike / cart.exs
Created August 30, 2016 21:56 — forked from dtzitz/cart.exs
# from ounce of elixir
#https://www.meetup.com/Women-Who-Code-Tampa/events/233014583/
ExUnit.start
defmodule CartTest do
use ExUnit.Case
test "starts with empty count" do
assert Cart.count_items([]) == 0
@caike
caike / datetime.exs
Last active August 16, 2016 03:03
Elixir. Example of a function with a default argument value set to the current DateTime - calculated on runtime.
defmodule CreditCard do
def current_amount_due(charges, apr, due_date, current_date \\ date_now()) do
current_date
# then proceed with calculation..
end
defp date_now do
DateTime.utc_now |> DateTime.to_unix
end
@caike
caike / a-main.go
Last active July 22, 2016 15:32
Example of concurrency in Go with web requests to Express
package main
import (
"demo/lib"
"sync"
)
func main() {
connections := lib.GetAllConnections()
var wg sync.WaitGroup
@caike
caike / main.go
Created May 24, 2016 17:58
Parallel example
package main
import (
"fmt"
"sync"
"time"
"math"
)
func main() {
@caike
caike / a-main.go
Last active May 24, 2016 14:15
Concurrency example in Go
// Manual Semaphore
package main
import (
"fmt"
"time"
)
func main() {
startTime := time.Now().Unix()
@caike
caike / go.go
Last active May 6, 2019 01:51
Unlearning Rubyisms
// first stab
const defaultPort = "8080"
func getPort() string {
portEnv := os.Getenv("PORT")
if portEnv != "" {
return portEnv
}
return defaultPort
}