This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) | |
sock.bind(('XX:XX:XX:XX:XX:XX', 1)) # find local address using `sudo bluetoothctl list` | |
sock.connect(('YY:YY:YY:YY:YY:YY', 1)) # target device after having paired it | |
sock.send(b'coucou\n') | |
sock.recv(100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
file_get_contents( | |
'https://blah.com/toto.php?something=whatever', | |
false, | |
stream_context_create(['http' => [ | |
'method' => 'POST', | |
'header' => 'Content-type: application/x-www-form-urlencoded', | |
'content' => http_build_query(['hello' => 'goodbye']), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using with(){} — Deprecated but practical | |
with (new XMLHttpRequest()) { | |
open('get', 'search?q='+encodeURIComponent('chaises'), true); | |
onreadystatechange = function () { | |
if (readyState !== 4 || status !== 200) return; | |
console.log(JSON.parse(responseText)); | |
}; | |
send(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | . | . | . | . | | |
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++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |