Skip to content

Instantly share code, notes, and snippets.

View comtom's full-sized avatar

Tomás Dowling comtom

View GitHub Profile
func worker(done chan bool) {
fmt.Print("working...")
time.Sleep(time.Second)
fmt.Println("done")
done <- true
}
func main() {
done := make(chan bool, 1)
go worker(done)
@comtom
comtom / pkg.go
Created September 27, 2018 18:58
package main
import "fmt"
@comtom
comtom / var_func.go
Last active September 27, 2018 18:55
func sum(nums ...int) {
fmt.Print(nums, " ")
total := 0
for _, num := range nums {
total += num
}
fmt.Println(total)
}
func main() {
sum(1, 2)
go func(msg string) {
fmt.Println(msg)
}("going")
var firstVar interface{}
firstVar = "this is a string"
firstString, ok := firstVar.(string)
if (!ok) {
fmt.Printf("firstString is not a string, do something about it! Value:'%v'\n", firstString)
}
@comtom
comtom / type.go
Last active September 27, 2018 17:45
func f1(arg int) (int, error) {
if arg == 42 {
return -1, errors.New("can't work with 42")
}
return arg + 3, nil
}
if rresult, err := f1(i); err != nil {
fmt.Println("f1 failed:", err)
}

Keybase proof

I hereby claim:

  • I am comtom on github.
  • I am comtom (https://keybase.io/comtom) on keybase.
  • I have a public key whose fingerprint is 131E 694F 783E B32F 7AA2 D216 19EE 87EA E285 F732

To claim this, I am signing this object:

FROM alpine:3.7
ENV KUBE_VERSION="v1.11.2"
ENV ANSIBLE_VERSION="2.5.0"
ENV TERRAFORM_VERSION="0.11.8"
# install kubectl
RUN set -ex \
&& apk add --update ca-certificates \
&& apk add --update -t deps curl \
@comtom
comtom / Dockerfile
Created July 12, 2018 14:19
Build a custom micro binary with all plugins you want in your machine and then make a docker image with it
FROM alpine:3.2
RUN apk add --update ca-certificates && \
apk add libc6-compat && \
rm -rf /var/cache/apk/* /tmp/*
ADD micro /micro
WORKDIR /
ENTRYPOINT [ "/micro" ]
@comtom
comtom / redirect_index_example.php
Last active May 24, 2018 11:10
Redirect index example for codeigniter
class IndexController extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->helper('captcha');
$this->load->model('user', 'user');
}
public function location($location_id) {
$this->index($location_id);
}
public function index($location_id = 1) {