Skip to content

Instantly share code, notes, and snippets.

View lamcw's full-sized avatar
🐶

Thomas Lam lamcw

🐶
View GitHub Profile
@lamcw
lamcw / pool_total_duration.sql
Created March 6, 2024 03:37
EngFlow profile SQL queries
INCLUDE PERFETTO MODULE experimental.slices;
WITH arg_sets_0 AS (
SELECT DISTINCT arg_set_id
FROM args
WHERE key = 'args.action_pool'
AND display_value = 'default'
)
SELECT
SUM(dur) / 1000000000
FROM experimental_slice_with_thread_and_process_info
@lamcw
lamcw / lcd-toggle
Last active December 11, 2019 06:02
Sway display toggle
#!/bin/sh
is_active=$(swaymsg -t get_outputs | jq ".. | select(.name? == \"${1}\") | .active")
if [ $is_active = "false" ]
then
swaymsg "output ${1} enable"
else
swaymsg "output ${1} disable"
fi
@lamcw
lamcw / win
Created July 15, 2019 09:53
QEMU launch script for Windows 10
#!/bin/sh
# Wrapper script for launching a qemu instance for Windows 10.
#
# This script is used in a Dell XPS 13 host.
#
# Usage: win [custom_qemu_options]
#
# Example:
# Assigning host USB device to guest VM
main = putStrLn "Hello friends!"
@lamcw
lamcw / malloc_init.c
Last active February 3, 2018 04:43
malloc macro
/* method is documentented here https://tia.mat.br/posts/2015/05/01/initializing_a_heap_allocated_structure_in_c.html */
#define ALLOC_INIT(type, ...) \
(type *)memdup((type[]){ __VA_ARGS__ }, sizeof(type))
void *memdup(const void *src, size_t sz) {
void *mem = malloc(sz);
return mem ? memcpy(mem, src, sz) : NULL;
}
@lamcw
lamcw / run.sh
Created August 22, 2017 11:27
sorting algo stat
#!/bin/sh
echo "started test"
# args
N_RUN=$1
echo $N_RUN
START_SIZE=$2
echo $START_SIZE
END_SIZE=$3
@lamcw
lamcw / stat.sh
Last active August 22, 2017 11:35
#!/bin/sh
printf "Input\tInitial\tHas\tNumber\tAvgTime\tAvgTime\n"
printf "Size\tOrder\tDups\tof runs\tforusel\tforsort\n"
N_RUN=$1
START_SIZE=$2
END_SIZE=$3
STEP=$4
sortarg=( "-R" "-n" "-nr" )
@lamcw
lamcw / xps13-permusb-uefi.md
Last active June 20, 2017 06:45
Dell XPS 13 (9350) Arch Linux UEFI Installation on USB Storage Device

Installation Guide

The purpose of this gist is to install vanilla Arch Linux to an USB storage device for XPS 13 (9350). This also act as a "note-to-self" in case I accidentally nuke my system and need a reinstallation. Most of the configuration here can actually be used in any UEFI-enabled pc, but I have added some detail points to optimize settings for my lovely XPS 13. I wrote this from my memory so there might be something that I missed. I will update this gist once I remember it.

What you need

  • Dell XPS 13 (9350) ...well obviouly
  • An USB stick/HDD/SSD
  • A bootable drive containing a live arch linux image, which can be downloaded here
  • Internet connection