Skip to content

Instantly share code, notes, and snippets.

View derlin's full-sized avatar

Lucy Linder derlin

View GitHub Profile
@derlin
derlin / AAA. Angular utils snippets
Last active May 10, 2016 11:52
Angular directives and utils
// some useful directives and snippets for angularJS 1.X applications
@derlin
derlin / AAA. Configs
Last active April 25, 2017 13:13
miscellanous configurations
// miscellanous configuration files for IDE and tools
@derlin
derlin / angularjs_semantic-ui-helpers.js
Last active August 16, 2016 09:15
AngularJS 1.X semantic-ui helpers.
// miscellanous directives and helpers for applications using AngularJS 1.X with the semantic-ui framework
@derlin
derlin / latex_article-base.tex
Last active August 16, 2016 09:08
Base for latex articles, with titlepage, headers/footer and eia-fr background
\documentclass[a4paper,11pt]{article}
%% Load additional packages and commands.
\usepackage{tabularx}
%~ paper and margins
\usepackage[tmargin=2.2cm,bmargin=2.2cm,lmargin=2cm,rmargin=2cm]{geometry}
\setlength{\parindent}{0pt} % no indent
\setlength{\parskip}{\baselineskip} % bare line between paragraphs
\setlength{\baselineskip}{2.5pt}
@derlin
derlin / golang_mapKeysToLowerFirst.go
Created August 16, 2016 09:11
Golang utility to transform a struct to a map with keys in lowercase. Useful to map struct to json (uppercase names always make me blink).
// see https://play.golang.org/p/6YD4YdvGLr
// for an example
import (
"reflect"
"unicode"
"unicode/utf8"
)
@derlin
derlin / golang_SqlToMap.go
Created August 16, 2016 09:12
convert an sql.Rows to a map
// Convert an sql.Rows to a map
func SqlToMap(rows *sql.Rows) {
columns, err := rows.Columns()
scanArgs := make([]interface{}, len(columns))
values := make([]interface{}, len(columns))
results := make([]map[string]interface{}, 0)
@derlin
derlin / golang_JsonUtils.go
Created August 16, 2016 09:14
Simple code to ease development while dealing with json.
imoprt "encoding/json"
func printJson(in interface{}) {
b, _ := json.Marshal(in)
fmt.Println(string(b))
}
func printJsonErr(in interface{}, err error) {
if (err != nil) {
fmt.Println(err)
@derlin
derlin / perl_add-file-headers.pl
Last active August 16, 2016 09:18
Perl script to add headers to the top of source files.
#!/usr/bin/env perl
# add headers at the top of files
# how to use:
# perl add-headers.pl <header file> files
# to add headers to cpp files recursively, use:
# perl add-headers.pl $(find . -name "*.cpp")
# beware: the script does not check if the file already contains headers !
@derlin
derlin / python_add-file-headers.py
Created August 16, 2016 09:17
Python script to add headers to the top of source files.
#!/usr/bin/env python3
# add headers to .h, .cpp, .c and .ino files automatically.
# the script will first list the files missing headers, then
# prompt for confirmation. The modification is made inplace.
#
# usage:
# add-headers.py <header file> <root dir>
#
# The script will first read the header template in <header file>,
@derlin
derlin / golang_DownloadFromUrl.go
Created August 16, 2016 09:20
Download resources from a url with go.
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)