Skip to content

Instantly share code, notes, and snippets.

View ercoppa's full-sized avatar

ercoppa ercoppa

View GitHub Profile
@ercoppa
ercoppa / sleep_critical_power.sh
Created December 3, 2022 11:52
sleep_critical_power.sh
#!/usr/bin/env bash
# Notifies the user if the battery is low.
# Executes some command (like hibernate) on critical battery.
# This script is supposed to be called from a cron job.
function notify-send() {
# Detect the name of the display in use
local display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)"
@ercoppa
ercoppa / sleep_if_inactive_on_battery.sh
Created December 3, 2022 11:50
sleep_if_inactive_on_battery.sh
#!/usr/bin/env bash
function notify-send() {
# Detect the name of the display in use
local display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)"
# Detect the user using such display
local user=$(who | grep '('$display')' | awk '{print $1}' | head -n 1)
# Detect the id of the user
@ercoppa
ercoppa / 80-keychron.rules
Last active February 25, 2023 18:30
K2 Keychron Ubuntu 18.04
SUBSYSTEMS=="input", ATTRS{name}=="Keychron K2", RUN+="/bin/sh -c 'echo 0 > /sys/module/hid_apple/parameters/fnmode'"
@ercoppa
ercoppa / angr-on-BIAR-1.6.5
Last active November 26, 2018 13:37
angr on BIAR-1.6.5
biar@pfp-VirtualBox:~$ python2 -m pip install --user pip
biar@pfp-VirtualBox:~$ python -m pip install --user angr
@ercoppa
ercoppa / Makefile
Last active December 18, 2017 07:49
angr issue #777
all:
gcc -o main-i386 main.c -m32
mips-linux-gnu-gcc -o main-mips main.c
clean:
-rm main-i386 main-mips
gen:
objdump -d main-i386 | grep '<avoid>' | cut -f1 -d' ' | head -n 1 > avoid-i386.txt
objdump -d main-mips | grep '<avoid>' | cut -f1 -d' ' | head -n 1 > avoid-mips.txt
@ercoppa
ercoppa / build.md
Last active October 23, 2017 09:59
GCC 5.5
  1. wget http://gcc.parentingamerica.com/releases/gcc-5.5.0/gcc-5.5.0.tar.xz
  2. untar and cd
  3. ./contrib/download_prerequisites
  4. cd .. && mkdir gcc-build && cd gcc-build && ../gcc-5.5.0/configure --prefix=pwd/inst --disable-multilib
  5. unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUDE
  6. make -j3
@ercoppa
ercoppa / build-KLEE-uclib.sh
Last active February 21, 2018 14:03
LLVM 3.4
```
export PATH=/home/ercoppa/Desktop/code/llvm-3.4-cmake/bin:$PATH
./configure --make-llvm-lib
make
```
@ercoppa
ercoppa / symbolic_code.s
Last active November 15, 2016 13:44
Example of symbolic code
.globl foo
.text
foo:
movl 4(%esp), %eax # load arg0 into eax
leal (foo_real), %ecx
jmp *%ecx
.data
@ercoppa
ercoppa / Apache Hadoop (local mode) without SSH
Last active August 3, 2023 13:18 — forked from anonymous/start-dfs.sh
Apache Hadoop (local mode) without SSH
cd ~/hadoop/sbin/
# save old scripts
mv start-dfs.sh start-dfs.sh.orig
mv start-yarn.sh start-yarn.sh.orig
mv stop-dfs.sh stop-dfs.sh.orig
mv stop-yarn.sh stop-yarn.sh.orig
touch start-dfs.sh && chmod +x start-dfs.sh
touch start-yarn.sh && chmod +x start-yarn.sh