Skip to content

Instantly share code, notes, and snippets.

View garsaud's full-sized avatar
🌐
interneting

Cyril garsaud

🌐
interneting
View GitHub Profile
@garsaud
garsaud / _.sql
Created November 2, 2020 10:51
Record duplicate counts in a column
update mytable t1
join (select field, count(*) as dup_count from mytable group by field) t2
set t1.count_field = dup_count
where t1.field = t2.field
@garsaud
garsaud / duplicates.sql
Created February 20, 2019 17:27
SQL: Remove duplicates except one
delete t1 from book t1
inner join book t2
where t1.id > t2.id
and t1.title = t2.title
and t1.user_id = t2.user_id
and t1.category_id = t2.category_id;
@garsaud
garsaud / Dockerfile
Created February 20, 2019 17:24
Docker PHP complete extension list
RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
@garsaud
garsaud / music.js
Created August 16, 2017 17:48
Electronic music in javascript
// | . | . | . | . |
notes1 = '30934903403050302080473000102000';
notes2 = '90000010900100009000001090010000';
tAudio = 0;
audioCtx = new AudioContext;
scriptProcessor = audioCtx.createScriptProcessor(512, 0, 1);
scriptProcessor.connect(audioCtx.destination);
scriptProcessor.onaudioprocess = e => {
data = e.outputBuffer.getChannelData(0);
for (i = 0; i < data.length; i++)
@garsaud
garsaud / lowercase.py
Created June 28, 2017 20:41
Rename files in current directory to lowercase. Also works on windows.
import os
"""
Make every filename within the same directory lowercase, adding a temporary
character in the process to fool windows into believing that the filename has
really changed (windows treats filenames as case insensitive)
Usage: python lowercase.py
"""
@garsaud
garsaud / ProcessQueueAndExit.php
Last active October 18, 2021 18:14 — forked from jdforsythe/ProcessQueueAndExit.php
Laravel 5 Artisan Process Entire Queue and Exit Command
<?php
namespace App\Console\Commands;
use Exception;
use Throwable;
use Illuminate\Queue\Worker;
use Illuminate\Console\Command;
use Illuminate\Contracts\Queue\Job;
use Illuminate\Queue\WorkerOptions;