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 / list_all_primary_key_columns.sql
Last active June 10, 2022 08:17
List all primary key columns in schema and table
-- https://stackoverflow.com/questions/2341278/how-to-get-primary-key-of-table
select
kcu.column_name,
kcu.table_name
from
information_schema.table_constraints tc
join information_schema.key_column_usage kcu
using(constraint_name,
table_schema,
@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 / bash_constructs.sh
Last active April 8, 2020 07:45
collection of bash constructs like tests and if statements and stuff
# ----------------------------------------------------------------------------
# How to check if a string begins with some value in bash
#
# more cool examples here: https://www.cyberciti.biz/faq/bash-check-if-string-starts-with-character-such-as/
# ----------------------------------------------------------------------------
#
# Let us define a shell variable called vech as follows:
vech="Bus"
# To check if string “Bus” stored in $vech starts with “B”, run:
@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 / build.gradle
Last active September 26, 2018 09:41
gradle ascii doc test and problem. Problem is the diagramm only works the first build. If the adoc is changed and the conversion is run again the diagram is not generate and embedded as plaintext. Message: 'invalid style for literal block: ditaa'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.8'
classpath group: 'org.asciidoctor', name: 'asciidoctorj-diagram', version: '1.5.9'
classpath group: 'org.asciidoctor', name: 'asciidoctorj-pdf', version: '1.5.0-alpha.16'
}