Skip to content

Instantly share code, notes, and snippets.

@tasiot
tasiot / AppExtension.php
Last active January 5, 2024 16:56
Twig pluralize filter
<?php
namespace App\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class AppExtension extends AbstractExtension
{
public function getFilters(): array
@x0nu11byt3
x0nu11byt3 / elf_format_cheatsheet.md
Created February 27, 2021 05:26
ELF Format Cheatsheet

ELF Format Cheatsheet

Introduction

Executable and Linkable Format (ELF), is the default binary format on Linux-based systems.

ELF

Compilation

@Pierstoval
Pierstoval / _PHP is_a() vs is_subclass_of().md
Last active June 26, 2024 17:03
`is_a()` vs `is_subclass_of()`

PHP is_a() vs is_subclass_of()

To compute the results, just use Melody and run the script:

melody run https://gist.github.com/Pierstoval/ed387a09d4a5e76108e60e8a7585ac2d
@kenji4569
kenji4569 / ulid_converter.sql
Last active June 3, 2024 06:02
ULID (26 characters in Crockford's base32) conversion for MySQL function
# Define ULID_DECODE and ULID_ENCODE which convert a ulid string to a binary and vice versa.
delimiter //
DROP FUNCTION IF EXISTS ULID_DECODE//
CREATE FUNCTION ULID_DECODE (s CHAR(26)) RETURNS BINARY(16) DETERMINISTIC
BEGIN
DECLARE s_base32 CHAR(26);
SET s_base32 = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(UPPER(s), 'J', 'I'), 'K', 'J'), 'M', 'K'), 'N', 'L'), 'P', 'M'), 'Q', 'N'), 'R', 'O'), 'S', 'P'), 'T', 'Q'), 'V', 'R'), 'W', 'S'), 'X', 'T'), 'Y', 'U'), 'Z', 'V');
RETURN UNHEX(CONCAT(LPAD(CONV(SUBSTRING(s_base32, 1, 2), 32, 16), 2, '0'), LPAD(CONV(SUBSTRING(s_base32, 3, 12), 32, 16), 15, '0'), LPAD(CONV(SUBSTRING(s_base32, 15, 12), 32, 16), 15, '0')));
END//
@egmontkob
egmontkob / Hyperlinks_in_Terminal_Emulators.md
Last active June 25, 2024 20:13
Hyperlinks in Terminal Emulators
@bkrepo
bkrepo / boot.ini.xen
Last active January 17, 2017 06:34
boot.ini for Xen for ODROID-C2
ODROIDC2-UBOOT-CONFIG
# Possible screen resolutions
# Uncomment only a single Line! The line with setenv written.
# At least one mode must be selected.
# 480 Lines (720x480)
# setenv m "480i60hz" # Interlaced 60Hz
# setenv m "480i_rpt" # Interlaced for Rear Projection Televisions 60Hz
# setenv m "480p60hz" # 480 Progressive 60Hz
@paragonie-scott
paragonie-scott / crypto-wrong-answers.md
Last active April 21, 2024 23:48
An Open Letter to Developers Everywhere (About Cryptography)
@philipz
philipz / gist:04a9a165f8ce561f7ddd
Created March 9, 2015 03:17
Debian ARM64 (Aarch64) image for QEMU
QEMU version: 2.2.0
HDD init: qemu-img create -f qcow debian8-arm64.img 10G

Netinstall initrd: http://ftp.ru.debian.org/debian/dists/jessie/main/installer-arm64/20150107/images/netboot/debian-installer/arm64/initrd.gz
Netinstall kernel: wget http://ftp.ru.debian.org/debian/dists/jessie/main/installer-arm64/20150107/images/netboot/debian-installer/arm64/linux

Netinstall start:
 qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic -smp 1 -m 512 -kernel linux -initrd initrd.gz -append "root=/dev/ram console=ttyAMA0" -global virtio-blk-device.scsi=off -device virtio-scsi-device,id=scsi -drive file=debian8-arm64.img,id=rootimg,cache=unsafe,if=none -device scsi-hd,drive=rootimg -netdev user,id=unet -device virtio-net-device,netdev=unet -net user
@salmenbej
salmenbej / ssm-checkMode.js
Last active August 29, 2015 14:08
Check the Portrait / Landscape mode on mobile device with ssm.js ( http://www.simplestatemanager.com/ )
ssm.addConfigOption({name:"orientation", test: function(){
//landscape mode
if(this.state.orientation === "landscape" && window.innerWidth >= window.innerHeight){
console.log('landscape');
return true;
}
//portrait mode
else if (this.state.orientation === "portrait" && window.innerWidth <= window.innerHeight){
console.log('portrait');
return true;
@pburtchaell
pburtchaell / styles.css
Last active February 25, 2024 12:24
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/