Skip to content

Instantly share code, notes, and snippets.

@dalitun
dalitun / main.go
Created January 7, 2018 02:30 — forked from chadlung/main.go
An example Go (golang) REST service that uses JWT (JSON Web Tokens) and Negroni http://www.giantflyingsaucer.com/blog/?p=5994
package main
// Generate RSA signing files via shell (adjust as needed):
//
// $ openssl genrsa -out app.rsa 1024
// $ openssl rsa -in app.rsa -pubout > app.rsa.pub
//
// Code borrowed and modified from the following sources:
// https://www.youtube.com/watch?v=dgJFeqeXVKw
// https://goo.gl/ofVjK4
@dalitun
dalitun / jwt_golang_example.go
Created January 7, 2018 02:27 — forked from thealexcons/jwt_golang_example.go
JSON Web Tokens in Go
package main
import (
"io/ioutil"
"log"
"strings"
"net/http"
"encoding/json"
"fmt"
"time"
@dalitun
dalitun / jwt-example.go
Created January 7, 2018 02:26
JsonWebTokens Example with generated key.
/* rewritten example of JsonWebToken example
* from https://gist.github.com/thealexcons/4ecc09d50e6b9b3ff4e2408e910beb22
* Keys are generated and packed to PEM-format at server start
* Plus some fixes and refactors
*
* My respect to thealexcons
*/
package main
import (
@dalitun
dalitun / ssh.go
Created December 29, 2017 17:11 — forked from andrielfn/ssh.go
Go lang SSH connection
package main
import (
"bytes"
"code.google.com/p/go.crypto/ssh"
"fmt"
"io/ioutil"
"os"
)
@dalitun
dalitun / populate.go
Created December 29, 2017 17:10 — forked from andrielfn/populate.go
Script to populate MySQL databases up to the *size-limit*. OS X binary download: https://www.dropbox.com/s/2gecxhqkxa7wpmq/bombsql?dl=0.
package main
import (
"database/sql"
"fmt"
"log"
"os"
"strconv"
_ "github.com/go-sql-driver/mysql"
@dalitun
dalitun / answer_pic.go
Created December 22, 2017 18:43 — forked from tetsuok/answer_pic.go
An answer of the exercise: Slices on a tour of Go
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
// Allocate two-dimensioanl array.
a := make([][]uint8, dy)
for i := 0; i < dy; i++ {
a[i] = make([]uint8, dx)
}
@dalitun
dalitun / golang-fr.md
Created October 25, 2017 18:33 — forked from leg0ffant/golang-fr.md
Golang introduction [FR]

Cours langage GO - annotation - Anthony Le Goff


#INTRO ALGORITHME SOUS GO De l'écriture du premier programme à la logique informatique golang

http://golang.org

Premier programme et présentation de "hello world"

@dalitun
dalitun / ansible-bootstrap-ubuntu-16.04.yml
Created July 7, 2017 14:39 — forked from gwillem/ansible-bootstrap-ubuntu-16.04.yml
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# [email protected]
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@dalitun
dalitun / github_repo.py
Created July 7, 2017 14:13 — forked from toast38coza/github_repo.py
An Ansible module for managing github repos
#!/usr/bin/python
DOCUMENTATION = '''
---
module: github_repo
short_description: Manage your repos on Github
'''
EXAMPLES = '''
- name: Create a github Repo
@dalitun
dalitun / github_repo.py
Created July 7, 2017 14:13 — forked from toast38coza/github_repo.py
An Ansible module for managing github repos
#!/usr/bin/python
DOCUMENTATION = '''
---
module: github_repo
short_description: Manage your repos on Github
'''
EXAMPLES = '''
- name: Create a github Repo