Skip to content

Instantly share code, notes, and snippets.

View vzool's full-sized avatar
🎯
Focusing

Abdelaziz Elrashed vzool

🎯
Focusing
View GitHub Profile
@vzool
vzool / pagination_example.sql
Created April 5, 2023 02:44 — forked from ssokolow/pagination_example.sql
Reasonably efficient pagination without OFFSET (SQLite version)
-- Reasonably efficient pagination without OFFSET
-- SQLite version (Adapted from MS SQL syntax)
-- Source: http://www.phpbuilder.com/board/showpost.php?p=10376515&postcount=6
SELECT foo, bar, baz, quux FROM table
WHERE oid NOT IN ( SELECT oid FROM table
ORDER BY title ASC LIMIT 50 )
ORDER BY title ASC LIMIT 10
@vzool
vzool / signed-commits.md
Created February 13, 2023 18:31 — forked from chq-matteo/signed-commits.md
Signed commits with GPG

1. Generate a gpg key

With GnuPG 2.1.15

If you want to create an RSA or DSA key in a straight forward way use:

gpg --full-gen-key

If you want to use an ECC algorithm, you need to add the --expert flag

gpg --expert --full-gen-key

@vzool
vzool / encode_decode.php
Created January 29, 2023 18:29 — forked from LogIN-/encode_decode.php
PHP custom encode decode functions
<?php
// Updated code from comments
function encode($value) {
if (!$value) {
return false;
}
$key = sha1('EnCRypT10nK#Y!RiSRNn');
#!/bin/bash
# cronjob:
# * * * * * /root/bin/watch-service apcupsd > /dev/null
service=$@
/bin/systemctl -q is-active "$service.service"
status=$?
if [ "$status" == 0 ]; then
echo "$service - OK"
else
@vzool
vzool / load_dotenv.sh
Created April 4, 2022 07:59 — forked from mihow/load_dotenv.sh
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@vzool
vzool / dump_restore_mysql_utf8mb4.sh
Created March 27, 2022 11:04 — forked from attilahorvath/dump_restore_mysql_utf8mb4.sh
Dump/restore MySQL database with utf8mb4 encoding
# dump
mysqldump -u user -p database --default-character-set=utf8mb4 --result-file=dump.sql
# restore
mysql -u user -p database --default-character-set=utf8mb4 < dump.sql
@vzool
vzool / main.go
Created March 4, 2022 06:46 — forked from dopey/main.go
How to generate secure random strings in golang with crypto/rand.
package main
import (
"crypto/rand"
"encoding/base64"
"fmt"
"io"
"math/big"
)
@vzool
vzool / quotes.txt
Created February 15, 2022 12:24 — forked from erickedji/quotes.txt
Don't worry about what anybody else is going to do. The best way to
predict the future is to invent it.
-- Alan Kay
Premature optimization is the root of all evil (or at least most of it)
in programming.
-- Donald Knuth
Lisp has jokingly been called "the most intelligent way to misuse a
computer". I think that description is a great compliment because it
@vzool
vzool / server.go
Created September 29, 2021 01:53 — forked from xcsrz/server.go
A golang web server on a randomly (os) chosen port.
package main
import (
"fmt"
"github.com/skratchdot/open-golang/open"
"net"
"net/http"
)
func main() {
@vzool
vzool / golang-template-if-and.go
Created May 20, 2021 11:19 — forked from rms1000watt/golang-template-if-and.go
Golang script for using templates with IF and AND
package main
import (
"fmt"
"os"
"text/template"
)
type Person struct {
Name string