Skip to content

Instantly share code, notes, and snippets.

@0x0all
0x0all / split_pdf.py
Last active April 30, 2021 22:00
How split a pdf-file?
import copy, sys
from PyPDF2 import PdfFileWriter, PdfFileReader
pdfFileObj = open("in.pdf", 'rb')
input_ = PdfFileReader(pdfFileObj)
output_ = PdfFileWriter()
for i in range(input_.getNumPages()):
p = input_.getPage(i)
q = copy.copy(p)
@0x0all
0x0all / compare.cpp
Created April 26, 2021 16:26
compare.cpp
#include <iostream>
#include <type_traits>
template <class T> constexpr T absolute(T arg) {
return arg < 0 ? -arg : arg;
}
template <class T>
constexpr auto precision_threshold = T(0.00000000000000000001);
@0x0all
0x0all / far install
Created October 10, 2019 15:24
Fedya's advice
1) git clone https://github.com/elfmz/far2l
2) cd far2l
3) mkdir build
4) cd build
5) cmake -DUSEWX=no -DCMAKE_BUILD_TYPE=Release ..
6) make -j9
7) install/far2l
@0x0all
0x0all / fix linux mint 19.2 yakuake
Created September 6, 2019 15:23
fix linux mint 19.2 yakuake
sudo apt install libkf5globalaccel-bin
~/.config/yakuakerc
[Animation]
Frames=0
@0x0all
0x0all / install ubuntu without usb.txt
Last active September 4, 2019 19:22
install ubuntu without usb.txt
sudo apt-get install grml-rescueboot
copy *.iso to /boot/grml
sudo vim /etc/default/grub
GRUB_DEFAULT=0
# GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
@0x0all
0x0all / notepad.txt
Created August 9, 2019 16:02
notepad
# tab -> select languages
gsettings set org.gnome.desktop.input-sources xkb-options "['grp:caps_toggle']"
@0x0all
0x0all / experiment_1.py
Last active August 7, 2019 20:46
experiment
def fib(n, a1 = 1, a2 = 1):
print(a1)
if n - 1 > 0:
return fib(n - 1, a2, a1 + a2)
fib(20)
def fib2(n, a1 = 1, a2 = 1):
yield a1
if n - 1 > 0:
xrandr --newmode "1920x1080_58.00" 166.89 1920 2040 2248 2576 1080 1081 1084 1117 -HSync +Vsync
xrandr --addmode DVI-I-1 "1920x1080_58.00"
@0x0all
0x0all / tsp.png
Created December 9, 2018 16:10 — forked from phelrine/tsp.png
TSP
tsp.png
@0x0all
0x0all / gist:b78e5b7b36efe920830f0de455644565
Created August 27, 2018 11:05 — forked from andrewrk/gist:1883543
function to count trailing zeros

Given an unsigned integer, return the number of trailing zero bits

Test framework:

#include <stdio.h>
#include <assert.h>

unsigned trailing_zeros(unsigned n) {
    // fill in this function