Skip to content

Instantly share code, notes, and snippets.

View hlapidez's full-sized avatar

Hank Lapidez hlapidez

  • Germany
View GitHub Profile
@hlapidez
hlapidez / fork_and_daemon.go
Created April 2, 2023 06:10 — forked from smallnest/fork_and_daemon.go
golang fork and exec and handle signals
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
)
@hlapidez
hlapidez / regex_useful.md
Created November 25, 2022 14:03 — forked from pyliaorachel/regex_useful.md
Some Regular Expressions that may be useful for data cleaning.
Punctuations, US-ASCII

/[!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]/

Punctuations, include Unicode ones (\u2000-\u206F: general punctuations, \u2E00-\u2E7F: supplemental punctuations)

/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]/

Chinese characters
@hlapidez
hlapidez / ldap filter pretty print
Created February 10, 2022 10:35 — forked from blaxter/ldap filter pretty print
ldap filter pretty print
#! perl -slw
use strict;
( my $input = do{ local $/; <DATA> } ) =~ tr[\n][]d;
my $tab = 0;
$input =~ s[([()])]{
$tab-- if $1 eq ')';
my $modified = "\n" . ( " " x $tab ) . $1;
$tab++ if $1 eq '(';
@hlapidez
hlapidez / README-oneshot-systemd-service.md
Created October 1, 2020 06:15 — forked from drmalex07/README-oneshot-systemd-service.md
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot

README

Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/setup-foo.sh:

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@hlapidez
hlapidez / starttls_smtp_example.go
Created December 18, 2019 18:36 — forked from jim3ma/starttls_smtp_example.go
Golang StartTLS SMTP Example
package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)
@hlapidez
hlapidez / MySQL Data Types Cheat Sheet.md
Created November 13, 2019 15:38 — forked from nmsmith22389/MySQL Data Types Cheat Sheet.md
A cheat sheet for all MySQL data types and what they do.

MySQL: Data Types

The following is a list of datatypes available in MySQL, which includes string, numeric, date/time, and large object datatypes.

String Datatypes

The following are the String Datatypes in MySQL:

Data Type Syntax Maximum Size Explanation
@hlapidez
hlapidez / rename_db
Created March 31, 2017 08:49 — forked from ryantm/rename_db
Shell script to rename a database, based on https://www.percona.com/blog/2013/12/24/renaming-database-schema-mysql/ - Please note you need to ensure you have access to MySQL via your ~/.my.cnf file
#!/bin/bash
# Copyright 2013 Percona LLC and/or its affiliates
# @see https://www.percona.com/blog/2013/12/24/renaming-database-schema-mysql/
set -e
if [ -z "$3" ]; then
echo "rename_db <server> <database> <new_database>"
exit 1
fi
db_exists=`mysql -h $1 -e "show databases like '$3'" -sss`
if [ -n "$db_exists" ]; then