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.
| 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]; |
| <?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;'); |
| Route::get('/preview-mail', function () { | |
| $mail = (new \App\Mail\ShareItenraryTripStarted())->build(); | |
| $mocked = new \ReflectionMethod($mail, 'buildView'); | |
| $mocked->setAccessible(true); | |
| return $mocked->invoke($mail)['html']; | |
| }); |
This is a bash script to act as a Cloudflare DDNS client, useful replacement for ddclient.
This gist will no longer update, instead please go to https://github.com/lifehome/systemd-cfddns for more updated versions.
cfupdater files to /usr/local/bin-v4 to cfupdater in the following systemd service unit.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.
| #!/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}" |
| <?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] * \ |
| 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 *; |