Skip to content

Instantly share code, notes, and snippets.

View crishoj's full-sized avatar

Christian Rishøj crishoj

View GitHub Profile
@crishoj
crishoj / index.d.ts
Last active September 8, 2023 13:47
`index.d.ts` for `ads-client`
// Type definitions for ads-client 1.14.2
// Project: https://github.com/jisotalo/ads-client
import ADS = require("ads-client/src/ads-client-ads.js");
import EventEmitter = require("events");
interface Settings {
targetAmsNetId: string;
targetAdsPort: number;
objectifyEnumerations?: boolean;
@crishoj
crishoj / create-vod-hls-gpu.sh
Created September 2, 2023 08:54 — forked from maitrungduc1410/create-vod-hls-gpu.sh
Bash scripts to create VOD HLS stream with ffmpeg using GPU
#!/usr/bin/env bash
START_TIME=$SECONDS
set -e
echo "-----START GENERATING HLS STREAM-----"
# Usage create-vod-hls-gpu.sh SOURCE_FILE [OUTPUT_NAME]
[[ ! "${1}" ]] && echo "Usage: create-vod-hls.sh SOURCE_FILE [OUTPUT_NAME]" && exit 1
# comment/add lines here to control which renditions would be created
renditions=(
@crishoj
crishoj / tl-privacy.md
Created August 14, 2019 00:21
Privacy Policy for Thai-English Dictionary from Thai-language.com

Christian Rishøj built the Thai-English Dictionary from Thai-language.com app as a free app.

No personal information is collected by the app, and no third party services are used.

Log data remains on the device on which the app is installed, and is not transmitted elsewhere.

Please direct any questions or suggestions to [email protected].

@crishoj
crishoj / output.txt
Last active July 22, 2018 16:52
ImageMagick pixel color extraction from CMYK image
##
## Ubuntu Bionic with PHP 7.2.7 and ImageMagick 6.9.7
##
>>> $resource = new Imagick("tests/images/bookcover.jpg")
=> Imagick {#2286}
>>> $resource->getImagePixelColor(20, 20)->getColor(true)
=> [
"r" => 0.0,
"g" => 0.10196078431373,
@crishoj
crishoj / example.mbox
Created February 24, 2018 08:22
Example mail triggering `"Undefined property: stdClass::$bytes"` in https://github.com/tedious/Fetch
Delivered-To: [email protected]
Received: by 10.31.170.197 with SMTP id t188csp550289vke;
Fri, 23 Feb 2018 04:34:11 -0800 (PST)
X-Google-Smtp-Source: AG47ELugto9uFG3a2nqQcrY8q4WwyaEz+mG9hxyxkeVPh5KGmyTbm0UPd9SG8RZOaZ1vxuiBSvvW
X-Received: by 10.46.60.22 with SMTP id j22mr1221583lja.27.1519389251617;
Fri, 23 Feb 2018 04:34:11 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1519389251; cv=none;
d=google.com; s=arc-20160816;
b=MRU+m3Y8TuEPD2MQyeabItO2nub+yX8O9IV1wQBO998byTLDMna/ZjylshtbwqdrbG
MxWT1loLMOZI/j/YRANCcZdD8h91xamTe2mog8UJaj139UP31cELoDjR+bzMbhD89x9V
@crishoj
crishoj / EnsureQueueWorkerIsRunning.php
Last active August 31, 2020 07:48 — forked from ivanvermeyen/EnsureQueueListenerIsRunning.php
Ensure that the Laravel 5.5 queue worker is running with "php artisan queue:checkup" and restart it if necessary. You can run this automatically with a cron job: http://laravel.com/docs/scheduling
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class EnsureQueueWorkerIsRunning extends Command
{
protected $signature = 'queue:checkup';
protected $description = 'Ensure that the queue worker is running.';

Keybase proof

I hereby claim:

  • I am crishoj on github.
  • I am crishoj (https://keybase.io/crishoj) on keybase.
  • I have a public key ASAkPv-nLbCvA-deaFI2NKwV47Nz8gQXni4c9VZLCxpWAwo

To claim this, I am signing this object:

@crishoj
crishoj / fast_paginate.php
Created May 17, 2017 09:15
Paginate Eloquent query using SQL_CALC_FOUND_ROWS and FOUND_ROWS() — avoids running the query twice
<?php
function paginateOptimized(Builder $builder, $perPage = null, $pageName = 'page', $page = null): LengthAwarePaginator
{
$model = $builder->getModel();
$page = $page ?: Paginator::resolveCurrentPage($pageName);
$perPage = $perPage ?: $model->getPerPage();
$sql = $builder->forPage($page, $perPage)->toSql();
@crishoj
crishoj / to_sentence.php
Last active July 14, 2016 10:17 — forked from bluefuton/to_sentence.php
Simple implementation of Rails' .to_sentence for PHP
<?php
if (! function_exists('to_sentence')) {
function to_sentence(array $parts, $connector = ', ', $finally = ' and '): string
{
switch (count($parts)) {
case 0:
return '';
case 1:
return reset($parts);
@crishoj
crishoj / CamelCasedModel.php
Last active March 31, 2016 10:29
Eloquent base model for schemas with camel-cased tables and fields
<?php
namespace app;
use Illuminate\Database\Eloquent\Model;
class CamelCasedModel extends Model
{
public function getForeignKey()