Skip to content

Instantly share code, notes, and snippets.

View alazycoder101's full-sized avatar

Lazy coder alazycoder101

View GitHub Profile
@alazycoder101
alazycoder101 / bubble-sort.rb
Created December 17, 2021 16:19
Bubble sort with given block in Ruby
class Array
def bubble_sort!
sorted = false
while !sorted
sorted = true
(0...self.length - 1).each do |index|
comparison = if block_given?
yield self[index], self[index+1]
else
self[index] > self[index + 1]
@alazycoder101
alazycoder101 / current-time-in-millisecond.html
Created January 9, 2022 15:48
show current time for audio/video in millisecond
<!-- https://pretagteam.com/question/html5-display-audio-currenttime -->
<div>
<audio id="track" src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" ontimeupdate="document.getElementById('tracktime').innerHTML = this.currentTime.toFixed(2) + ' / ' + this.duration.toFixed(2);" controls="controls">
<p>Your browser does not support the audio element</p>
</audio>
<span id="tracktime">0 / 0</span>
</div>
<div>
#!/usr/bin/perl
#Filename: FlashVideoCapture.pl
use strict;
##################################################
# Setup the variables
##################################################
my $PROGNAME = $0; $PROGNAME =~ s|.*/||;
my $LSOF = 'lsof';
.tracks[]|"wget `curl -H 'appvers: 1.0.15.10102924' -H 'baseapi: 23' -H 'basever: 1.0.15.10102924' -H 'beta: 0' -H 'channel: 0' -H 'channelid: 0' -H 'osver: 10.0.1' -H 'skey: pZw4DtHy' -H 'user-agent: Whear/1.0.15 WHBrand/xiaomi Dalvid/2.1.0 (Linux; U; Android 10.0.1; Redmi Note 8 Build/MRA58K)' -H 'vid: 2319074' -H 'wrts_listentime: 0' -H 'wrts_signature: 1623431083_1621078395_eeabecbf444e0e50fcdb7f' 'https://i.at.qq.com/getplayinfo?trackId=" + .trackId + "&type=0&model='|jq -r '.url'` -O " + .title + ".m4a"
@alazycoder101
alazycoder101 / send_email.sh
Last active December 25, 2022 12:55
bash function to send email via sendgrid
send_email() {
# sendgrid api key
API_KEY=$mykey
to=$1
from=$2
subject=$3
content=$4
JSON_FORMAT='{"personalizations": [{"to": [{"email": "%s"}]}],"from": {"email": "%s"},"subject": "%s","content": [{"type": "text/plain", "value": "%s"}]}\n'
data=$(printf "$JSON_FMT" "$to" "$from" "$subject" "$content")
curl --request POST \
curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get -yq update && apt-get -yq install google-chrome-stable
CHROMEDRIVER_VERSION=$(curl -s http://chromedriver.storage.googleapis.com/LATEST_RELEASE) && \
cd /tmp/ && curl -L -O "http://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" && \
unzip chromedriver_linux64.zip && chmod +x chromedriver && mv chromedriver /usr/bin

::Digest::SHA256.hexdigest

echo 'hello'|md5
b1946ac92492d2347c6235b4d2611184

encoding

bundle exec rake zeitwerk:check

zeitwerk example

load_defaults "6.0 # use zeitwerk
config.autoloader = :classic # not use zeitwerk

podman + podman-composer

podman machine init
Downloading VM image: fedora-coreos-35.20220116.2.0-qemu.aarch64.qcow2.xz: do…
Extracting compressed file
podman machine start