Skip to content

Instantly share code, notes, and snippets.

.log
0
1
1234
12345
123456
18Renmeng
2
ACrenshaw
AGorg
@valorin
valorin / Middleware-CSP.php
Last active May 2, 2024 19:29
CSP Middleware - the simple CSP middleware I use across all of my projects.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Vite;
use Illuminate\Support\Str;
/**
* Simple Content Security Policy middleware.
@joelonsql
joelonsql / PostgreSQL-EXTENSIONs.md
Last active May 5, 2024 22:09
1000+ PostgreSQL EXTENSIONs

🗺🐘 1000+ PostgreSQL EXTENSIONs

This is a list of URLs to PostgreSQL EXTENSION repos, listed in alphabetical order of parent repo, with active forks listed under each parent.

⭐️ >= 10 stars
⭐️⭐️ >= 100 stars
⭐️⭐️⭐️ >= 1000 stars
Numbers of stars might not be up-to-date.

@androidfred
androidfred / noargs_setters_builders.md
Last active March 9, 2023 15:51
Stop using noargsconstructors and setters (and builders)

Stop using noargsconstructors and setters (and builders)

TLDR summary

Noargsconstructors and setters are outdated, 90's style old school Java. They needlessly allow entire categories of defects that are easily avoided by using only allargsconstructors and no setters. Please stop writing code like that.

Longer version

How many times have you come across (or written) code like this

public class User {
@kjmph
kjmph / A_UUID_v7_for_Postgres.sql
Last active April 23, 2024 15:26
Postgres PL/pgSQL function for UUID v7 and a bonus custom UUID v8 to support microsecond precision as well. Read more here: https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
-- Based off IETF draft, https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
create or replace function uuid_generate_v7()
returns uuid
as $$
begin
-- use random v4 uuid as starting point (which has the same variant we need)
-- then overlay timestamp
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string
return encode(
@zaxbux
zaxbux / chan_pjsip--X-UCM--Headers.c
Last active August 26, 2022 03:21
Grandstream GRP26xx SIP Integration
/*! \brief Add "X-UCM-AudioRecord" header and "X-UCM-CallPark" header to outgoing message
*
* if the right is allow callee or allow both, add the header in Invite message;
if the right is allow caller or allow both, add the header in 200 for Invite message
*
* \param req The request/response to which we will add the header
*/
void add_feature_map_header(pjsip_tx_data *tdata, int outgoing_call)
{
char audio_record_code[12] = {0};
@miken32
miken32 / Cidr.php
Last active October 24, 2023 07:27
Laravel CIDR validation rule
<?php
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use const FILTER_FLAG_IPV4;
use const FILTER_FLAG_IPV6;
use const FILTER_VALIDATE_INT;
@cristianovagos
cristianovagos / .gitlab-ci.yml
Created September 26, 2019 11:37
GitLab CI/CD file for Protobuf Golang/Java generation
stages:
- build
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
build:go:
stage: build
image:
name: namely/protoc-all
@navono
navono / reconn.go
Created July 23, 2019 07:09
websocket reconnect in golang
package reconWS
import (
"errors"
"math/rand"
"net/http"
"net/url"
"sync"
"time"
@luckman212
luckman212 / v6test.sh
Last active October 23, 2023 02:38
script for pfSense to detect IPv6 router advertisements coming from a WAN interface
#!/bin/sh
# set the variable below to your FIOS interface
IF=igb0
/usr/bin/timeout 5m /usr/sbin/tcpdump -ni ${IF} 'icmp6 && ip6[40] == 134' >/tmp/${IF}_RAs.out
FSIZE=$(/usr/bin/stat -f '%z' /tmp/${IF}_RAs.out)
if [ "$FSIZE" -gt 1 ]; then
echo '<?php include("notices.inc"); $msg = "IPv6 RAs detected on interface '$IF'"; notify_via_smtp($msg);?>' | /usr/local/bin/php -q
fi