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 / AppServiceProvider.php
Last active February 22, 2021 14:11 — forked from danharper/CatchAllOptionsRequestsProvider.php
Enable CORS in Lumen 5.2 - ServiceProvider + Middleware
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
@falmar
falmar / main.go
Created October 12, 2019 19:13
Update Laravel's migrations varchar to max length of 191 for allowing use of utf8mb4
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"log"
"os"
"path/filepath"
@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();
@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 / 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 / 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 / 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 / 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 {
# MYSQL_PASSWORD=... docker-compose up -d
version: '2'
services:
ds:
image: alpine:3.4
command: sh
volumes:
- ./:/usr/share/nginx/html
// 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);