Skip to content

Instantly share code, notes, and snippets.

View falmar's full-sized avatar

David Lavieri falmar

  • flipflow.io
  • Spain
View GitHub Profile
@falmar
falmar / main.go
Created January 16, 2016 17:22 — forked from filewalkwithme/main.go
Listening multiple ports on golang http servers (using http.Handler)
package main
import (
"net/http"
)
func main() {
go func() {
http.ListenAndServe(":8001", &fooHandler{})
}()
@falmar
falmar / main.go
Created July 9, 2016 01:06 — forked from nmerouze/main.go
Example for "Build Your Own Web Framework in Go" articles
package main
import (
"database/sql"
"encoding/json"
"errors"
"fmt"
"log"
"net/http"
"time"
// http://php.net/manual/en/function.password-hash.php
$password = password_hash($string, PASSWORD_BCRYPT, ['cost' => 9]);
// http://php.net/manual/en/function.password-verify.php
$correct = password_verify($string, $password);
# MYSQL_PASSWORD=... docker-compose up -d
version: '2'
services:
ds:
image: alpine:3.4
command: sh
volumes:
- ./:/usr/share/nginx/html
@falmar
falmar / nset.php
Last active August 7, 2017 21:22
Nested Sets in SQL
<?php
// Update the nested set table, reorder all the rows
function leftRightOrder($PDO, $fatherId, $left)
{
if(!is_null($fatherId)) {
$stmt = $PDO->prepare('SELECT id FROM ws_example WHERE parentId = ?');
$stmt->bindValue(1, $fatherId);
} else {
@falmar
falmar / fedora pkg kit
Last active October 22, 2017 23:24
Remove package kit from fedora, remove bloat rpm cache files
from https://bugzilla.redhat.com/show_bug.cgi?id=1306992#c11
pick one
- pkcon refresh force -c -1
- set /etc/PackageKit/PackageKit.conf
# Keep the packages after they have been downloaded
KeepCache=false
@falmar
falmar / docker-clean.md
Created October 27, 2017 20:58 — forked from kuznero/docker-clean.md
Cleanup docker images and containers after failed builds

Cleanup docker images and containers after failed builds

Sometimes, there are some untagged images left behind after failed builds. In order to get rid of those, this script can be used.

#!/bin/bash
docker rm $(docker ps -aq)
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
@falmar
falmar / docker-compose.override.yml
Created November 23, 2017 00:08
Docker compose files: local + swarm stack
version: '3.4'
services:
mysql:
volumes:
- db:/var/lib/mysql
ports:
- 3306:3306
environment:
- MYSQL_PASSWORD=database_password
@falmar
falmar / openssl.MD
Created February 22, 2019 20:18 — forked from jchandra74/openssl.MD
HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

Overview

My main development workstation is a Windows 10 machine, so we'll approach this from that viewpoint.

Recently, Google Chrome started giving me a warning when I open a site that uses https and self-signed certificate on my local development machine due to some SSL certificate issues like the one below:

Self-Signed SSL Issue in Chrome

@falmar
falmar / CopyToClipboard.jsx
Created August 11, 2017 12:45 — forked from netsi1964/CopyToClipboard.jsx
ReactJS component: Copy to clipboard
class CopyToClipboard extends React.Component {
constructor(props) {
super(props);
}
copy() {
const copyTextarea = this.refs.data;
const { text, onCopy, silent } = this.props;
copyTextarea.value = onCopy.call(this, text);
copyTextarea.select();