Skip to content

Instantly share code, notes, and snippets.

View melbahja's full-sized avatar
🦇
chmod +x bits

Mohamed El Bahja melbahja

🦇
chmod +x bits
View GitHub Profile
@cvzi
cvzi / lru.go
Created November 19, 2019 20:21
A LRU "least recently used" cache in golang
// A LRU "least recently used" cache
package lru
import (
"container/list"
"fmt"
"sync"
)
// Cache represents a LRU consisting of a map as an index and a list to hold data and indicate the last recently used queue.
@dungsaga
dungsaga / sync-time.sh
Last active December 14, 2022 22:15
sync local clock in without NTP in Linux, MacOS, Windows
# I want to sync the local clock but don't have access to any NTP server.
# Website https://time.is tells me the time difference of my system clock and I can manually adjust the local clock.
# But then I recall that a HTTP response often contains a date header with current time in GMT timezone.
# I'll use it to set the system clock with the precision of 1 or 2 seconds.
# When I need more accurate time, I can use `datetime` (or `utc_datetime`) from `http://worldtimeapi.org/api/ip.txt`
# time from worldtimeapi.org has millisecond precision, you can use it to compare with your system time:
date -uIns && time curl -s http://worldtimeapi.org/api/ip.txt | sed -n 's/^utc_datetime://p'
date -Ins && time curl -s http://worldtimeapi.org/api/ip.txt | sed -n 's/^datetime://p'
@lizthegrey
lizthegrey / attributes.rb
Last active February 24, 2024 14:11
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@ayubmalik
ayubmalik / gpg-encrypt.go
Last active March 3, 2023 08:49
Golang encrypt file using GPG openpgp. Use standard go libs.
package main
/**
Example hack to encrypt a file using a GPG encryption key. Works with GPG v2.x.
The encrypted file e.g. /tmp/data.txt.gpg can then be decrypted using the standard command
gpg /tmp/data.txt.gpg
Assumes you have **created** an encryption key and exported armored version.
You have to read the armored key directly as Go cannot read pubring.kbx (yet).
@miguelmota
miguelmota / rsa_util.go
Last active March 8, 2024 10:20
Golang RSA encrypt and decrypt example
package ciphers
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha512"
"crypto/x509"
"encoding/pem"
"log"
)
@jkjung-avt
jkjung-avt / openalpr_camera.py
Last active December 20, 2023 20:36
Real-time license plate recognition with 'openalpr' using a video file as input. Please check out my "Building and Testing 'openalpr' on Jetson TX2" post for more information: https://jkjung-avt.github.io/openalpr-on-tx2/
# test_camera.py
#
# Open an RTSP stream and feed image frames to 'openalpr'
# for real-time license plate recognition.
import numpy as np
import cv2
from openalpr import Alpr
@asukakenji
asukakenji / go-stdlib-interface-selected.md
Last active March 23, 2024 01:36
Go (Golang) Standard Library Interfaces (Selected)

Go (Golang) Standard Library Interfaces (Selected)

This is not an exhaustive list of all interfaces in Go's standard library. I only list those I think are important. Interfaces defined in frequently used packages (like io, fmt) are included. Interfaces that have significant importance are also included.

All of the following information is based on go version go1.8.3 darwin/amd64.

@mrbar42
mrbar42 / README.md
Last active March 28, 2024 16:47
bash scripts to create VOD HLS stream with ffmpeg almighty (tested on Linux and OS X)

running:

bash create-vod-hls.sh beach.mkv

will produce:

    beach/
      |- playlist.m3u8
 |- 360p.m3u8
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active March 28, 2024 21:13
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@kasparsd
kasparsd / popular-wp-plugins.php
Created October 5, 2016 19:30
Top 1000 most popular WordPress plugins