Skip to content

Instantly share code, notes, and snippets.

@arkon
arkon / patch_boot.sh
Last active March 13, 2019 08:45
Bash scripts for patching boot.img/build.prop for Fate/Grand Order on LineageOS (https://goo.gl/YkHgjZ)
#!/usr/bin/env bash
#
# This script replaces "ro.debuggable=1" with "ro.debuggable=0" in the
# default.prop file in a ROM's boot.img and gives you the patched boot.img.
#
# Prerequisites:
# - A UNIX system (with `unzip`)
# - These tools added to your PATH:
# - Android dev tools (adb/fastboot)
# - Various tools in "bootimg_tools_7.8.13.zip" from https://goo.gl/48Sszu
@CalebFenton
CalebFenton / DexFileFingerprinter.java
Created September 28, 2017 17:27
Fingerprinting / Hashing Dalvik Executables
import gnu.trove.map.TObjectLongMap;
import gnu.trove.map.hash.TObjectLongHashMap;
import org.jf.dexlib2.Opcode;
import org.jf.dexlib2.iface.ClassDef;
import org.jf.dexlib2.iface.DexFile;
import org.jf.dexlib2.iface.Field;
import org.jf.dexlib2.iface.Method;
import org.jf.dexlib2.iface.MethodImplementation;
import org.jf.dexlib2.iface.instruction.Instruction;
@charveey
charveey / 51-noto-color-emoji.conf
Created October 1, 2017 01:14
Enabling Color Emoji in Chrome (Linux)
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!--
You need Noto Color Emoji installed in your machine.
Save this file in ~/.config/fontconfig/conf.d/ or /etc/fonts/conf.d/ (system-wide)
-->
<fontconfig>
<match target="scan">
<test name="family">
@dokato
dokato / orthogonalization.py
Created February 15, 2018 14:13
Find closest orthogonal matrix
import numpy as np
def find_closest_orthogonal_matrix(A):
'''
Find closest orthogonal matrix to *A* using iterative method.
Bases on the code from REMOVE_SOURCE_LEAKAGE function from OSL Matlab package.
Args:
A (numpy.array): array shaped k, n, where k is number of channels, n - data points
@douglasrizzo
douglasrizzo / inconsistent-authors-bib.ipynb
Last active June 27, 2022 00:19
Merging inconsistent author names in a bib file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@imAliAzhar
imAliAzhar / emoji-list
Last active January 15, 2023 17:59
Create an Emoji selector menu with Rofi
<span lang="face with tears of joy"> 😂 </span>
<span lang="grinning face with smiling eyes"> 😄 </span>
<span lang="grinning face with sweat"> 😅 </span>
<span lang="face with rolling eyes"> 🙄 </span>
<span lang="smirking face"> 😏 </span>
<span lang="smiling face with halo"> 😇 </span>
<span lang="grinning face"> 😀 </span>
<span lang="squinting face with tongue"> 😝 </span>
<span lang="grinning face with big eyes"> 😃 </span>
<span lang="unamused face"> 😒 </span>
@andrebrait
andrebrait / keychron_linux.md
Last active May 28, 2025 09:46
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Note: many newer Keychron keyboards use QMK as firmware and most tips here do not apply to them. Maybe the ones related to Bluetooth can be useful, but everything related to Apple's keyboard module (hid_apple) on Linux, won't work. As far as I know, all QMK-based boards use the hid_generic module instead. Examples of QMK-based boards are: Q, Q-Pro, V, K-Pro, etc.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work (NOT FOR QMK-BASED BOARDS)

Older Keychron keyboards (those not based on QMK) use the hid_apple driver on Linux, even in the Windows/Android mode, both in Bluetooth and Wired modes.

@V0XNIHILI
V0XNIHILI / Möller-Trumbore algorithm in Python.md
Last active October 25, 2024 12:16
Möller–Trumbore ray-triangle intersection algorithm (for ray tracing) in Python and Numpy, vectorized

On my 2014 MacBook Pro (2.5 GHz), this vectorized version is about 250 times faster when used for a large numbers of triangles compared to the original algorithm. You can also parallelize this code over multiple threads, but due to the large overhead of creating a thread pool, this is only really useful when you have a very large number of rays.

I also tried to vectorize the rays, instead of using a loop. I did this by using:

np.reshape(np.array(np.meshgrid(np.arange(0, len(ray_direction), 1), np.arange(0, len(triangles_vertices), 1))), (2, resulting_array_length))

to create all combinations of indices of the rays and the triangles. However, using this process, combined with using np.take() to actually create these combinations is about twice as slow as the code below.

@handymenny
handymenny / WireguardAutomatic.xml
Created October 23, 2022 13:01
Script to enable/disable wireguard tunnel when IPv4 default gateway changes
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2022-10-23T14:42:10.5827629</Date>
<Author>handymenny</Author>
<URI>\WireguardAutomatic</URI>
</RegistrationInfo>
<Triggers>
<EventTrigger>
<Enabled>true</Enabled>
@a-n-d-r-e-w-l
a-n-d-r-e-w-l / original.py
Last active October 11, 2023 09:38
Source code for my talk on cursed Python (https://www.youtube.com/watch?v=t863QfAOmlY).
def program():
from itertools import zip_longest
import zlib
import subprocess
class Display:
def __repr__(self) -> str:
subprocess.run([
"feh",
"-xYFqZ",