Skip to content

Instantly share code, notes, and snippets.

Avatar

Ayose Cazorla ayosec

View GitHub Profile
@ayosec
ayosec / config.ru
Created Aug 9, 2012
HAProxy basic example
View config.ru
# Simple web server
# Use N_ envvar to identify the process
run lambda {|env|
[ 200, {}, "Ok @ #{ENV["N_"]}"]
}
View change-volume-ffmpeg.sh
#!/bin/bash
ffmpeg -ss 4:00:00 -i INPUT.webm -filter:a volume=0.5 half-volume.webm
ffmpeg -i INPUT.webm -t 4:00:00 -c copy start.webm
cat > files <<EOF
file 'start.webm'
file 'half-volume.webm'
EOF
View find_seqs_iterator.rs
struct Seqs<I> {
iter: I,
}
impl<'a, I: Iterator<Item = &'a u8>> Iterator for Seqs<std::iter::Enumerate<I>> {
type Item = (usize, usize);
fn next(&mut self) -> Option<Self::Item> {
// Jump to first byte '1'
let start = loop {
View 8.2.3. HTTP log format
8.2.3. HTTP log format
----------------------
The HTTP format is the most complete and the best suited for HTTP proxies. It
is enabled by when "option httplog" is specified in the frontend. It provides
the same level of information as the TCP format with additional features which
are specific to the HTTP protocol. Just like the TCP format, the log is usually
emitted at the end of the session, unless "option logasap" is specified, which
generally only makes sense for download sites. A session which matches the
"monitor" rules will never logged. It is also possible not to log sessions for
View linux-syscalls.sh
git clone --depth 1 https://github.com/torvalds/linux.git
cd linux
rg --json \
--mmap \
--multiline \
'^SYSCALL_DEFINE\d+\s*?\((?s).*?\)' \
| jq -r '
select(.type == "match")
@ayosec
ayosec / code-blocks.awk
Last active Oct 31, 2020
Extract code blocks
View code-blocks.awk
# Usage:
#
# $ awk -f block.awk -v START="fn myfunc" foo.rs bar.rs | pygmentize -l rs
{
if(acc == 0) {
if($0 ~ START) {
indent = match($0, /[^[:space:]]/)
acc = $0
}
@ayosec
ayosec / playerctl-fast.sh
Created Oct 5, 2020
playerctl: skip metada to control music
View playerctl-fast.sh
#!/bin/bash
set -euo pipefail
case "${1:-}" in
next)
MEMBER=Next
;;
previous)
View WebCrypto-PBKDF2-AES-GCM.js
async function keysFromPassword(salt, password) {
let enc = new TextEncoder().encode(password);
let basekey = await crypto.subtle.importKey("raw", enc, "PBKDF2", false, ["deriveBits"]);
let keys = await crypto.subtle.deriveBits(
{
name: 'PBKDF2',
hash: 'SHA-512',
salt: salt,
iterations: 1e5
View code2html.rb
#!/usr/bin/env ruby
require "erb"
require "etc"
if ARGV.empty?
puts "Usage: #$0 files... > output.html"
exit 1
end
View bluez-headsets.sh
#!/bin/bash
MAC=01_23_45_67_89_AB
FILTER=$(paste -sd, <<FILTER
type='signal'
sender='org.bluez'
interface='org.freedesktop.DBus.Properties'
path='/org/bluez/hci0/dev_$MAC'
member='PropertiesChanged'