Skip to content

Instantly share code, notes, and snippets.

View kocoten1992's full-sized avatar
😗
Thanks for visiting

Chuong kocoten1992

😗
Thanks for visiting
View GitHub Profile
@logiclrd
logiclrd / ffmpeg film grain
Last active May 26, 2023 06:06
FFmpeg: Ultimate film grain
ffmpeg -i "HD Splice 1080p No Grain.mkv" -i "HD Splice 1080p No Grain.mkv" -filter_complex "
color=black:d=3006.57:s=3840x2160:r=24000/1001,
geq=lum_expr=random(1)*256:cb=128:cr=128,
deflate=threshold0=15,
dilation=threshold0=10,
eq=contrast=3,
scale=1920x1080 [n];
[0] eq=saturation=0,geq=lum='0.15*(182-abs(75-lum(X,Y)))':cb=128:cr=128 [o];
[n][o] blend=c0_mode=multiply,negate [a];
color=c=black:d=3006.57:s=1920x1080:r=24000/1001 [b];
@aalfiann
aalfiann / sqlite_big_data_pragma.php
Created January 31, 2019 13:30
SQLite for big data with pragma in php way
<?php
$db = new SQLite3('/my/sqlite/file.sqlite3');
$db->busyTimeout(5000);
// WAL mode has better control over concurrency.
// Source: https://www.sqlite.org/wal.html
$db->exec('PRAGMA main.cache_size=10000;PRAGMA main.locking_mode=EXCLUSIVE;PRAGMA main.synchronous=NORMAL;PRAGMA main.journal_mode=WAL;');
@loilo
loilo / portfinder.md
Last active May 3, 2024 06:41
Find Free Port with PHP

Find Free Port with PHP

This is a quick way to find a random free port on a system using PHP:

$port = find_free_port();

Benchmarked locally, where finding a port always took around 0.15ms.

@ahsankhatri
ahsankhatri / web.php
Created August 9, 2018 08:30
Preview Mailable in Browser Laravel 5.4
Route::get('/preview-mail', function () {
$mail = (new \App\Mail\ShareItenraryTripStarted())->build();
$mocked = new \ReflectionMethod($mail, 'buildView');
$mocked->setAccessible(true);
return $mocked->invoke($mail)['html'];
});
@lifehome
lifehome / README.md
Last active February 25, 2024 06:34 — forked from benkulbertis/cloudflare-update-record.sh
Cloudflare API v4 Dynamic DNS Update in Bash

Cloudflare DDNS bash client with systemd

This is a bash script to act as a Cloudflare DDNS client, useful replacement for ddclient.

Look out!

A newer version is available!

This gist will no longer update, instead please go to https://github.com/lifehome/systemd-cfddns for more updated versions.

How to use?

  1. Put the cfupdater files to /usr/local/bin
  • If you are using IPv4 for A record, append -v4 to cfupdater in the following systemd service unit.
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 5, 2024 19:57
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@drfill
drfill / gist:c18308b6d71ee8032efda870b9be348e
Created October 26, 2017 17:58 — forked from Mindgames/gist:556dc7d1e452d0cefcb7
Amazon S3 download with Curl
#!/bin/sh
file=path/to/file
bucket=your-bucket
resource="/${bucket}/${file}"
contentType="application/x-compressed-tar"
dateValue="`date +'%a, %d %b %Y %H:%M:%S %z'`"
stringToSign="GET
${contentType}
${dateValue}
${resource}"
@kn007
kn007 / test.php
Last active February 26, 2021 07:46
performance: mt_rand vs openssl_random_pseudo_bytes vs random_bytes vs uniqid vs uuid
<?php
define('LOOP_COUNT',100000);
function create_uuid_v4(){
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
import sys
def to_octets(ip):
return [int(i) for i in ip.split('.')]
def dotless_decimal(ip):
octets = to_octets(ip)
result = octets[0] * 16777216 + octets[1] * \
@mpneuried
mpneuried / postgres_add_json_sub_array_unique.sql
Last active April 5, 2023 11:35
Add and remove elements unique to a Postgres jsonb sub key: Short a Set implemetation
UPDATE public.mytable SET
jsonfieldname = jsonb_set( jsonfieldname, '{json_obj_key}', array_to_json(
ARRAY(
SELECT DISTINCT( UNNEST( ARRAY(
SELECT json_array_elements_text( COALESCE( jsonfieldname::json->'json_obj_key', '[]' ) )
) || ARRAY['Element to add'] ) )
)
)::jsonb )
WHERE id = 23
RETURNING *;