Skip to content

Instantly share code, notes, and snippets.

View sulincix's full-sized avatar
🇹🇷

​​ sulincix

🇹🇷
View GitHub Profile
@sulincix
sulincix / versus.md
Last active April 23, 2024 21:58
C vs C++

C vs C++

Write Hello World

C++ version

#include <iostream>
int main(){
    std::cout << "Hello World" << std::endl;
}
@sulincix
sulincix / genlib.sh
Created November 15, 2023 11:33
dummy generator
#!/bin/bash
# Note: This is experimental script.
rm -f *.c *.so*
genlib(){
file="$1"
nm --dynamic $file | grep -v " U " | grep -v " w " | cut -f3 -d" " | sed "s/.*/void* &(){}/g" > "$(basename $file.c)"
gcc -o $(basename $file) "$(basename $file.c)" -shared -nostdlib
}
#genlib /usr/lib/libKUserFeedbackCore.so.1
@sulincix
sulincix / wait_for_x11.c
Last active September 14, 2023 20:36
Wait for X11 until ready
/* Compile:
gcc -o wait_for_x11 wait_for_x11.c -lX11
Run:
./wait_for_x11 :0
*/
#include <X11/Xlib.h>
#include <unistd.h>
int main(int argc, char *argv[]){
Display *dpy;
@sulincix
sulincix / helloworld_without_libc.c
Last active October 16, 2023 07:03
Hello World without libc
// Compile with:
// gcc -o main main.c -nostdlib -O0
int print(char* msg, int len){
/*
rax = 1 (write)
rdi = 1 (stdout)
rsi = message
rdx = length
syscall
@sulincix
sulincix / bondingup.sh
Last active August 30, 2023 06:52
bond 2 eth cards
modprobe bonding
ip link set eth0 down
ip link set eth1 down
ip link add bond0 type bond mode 802.3ad
ip link set eth0 master bond0
ip link set eth1 master bond0
ip link set bond0 up
ip addr add 42.42.42.5/24 dev bond0
ip route add default via 42.42.42.1 dev bond0
@sulincix
sulincix / boot.sh
Created August 26, 2023 12:49
emulate rpi on qemu
qemu-system-aarch64 \
-m 1024 \
-M raspi3b \
-kernel kernel8.img \
-dtb bcm2710-rpi-3-b-plus.dtb \
-sd devuan.img \
-append "console=ttyAMA0 root=/dev/mmcblk0p2 rw rootwait rootfstype=ext4" \
-device usb-net,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
-usb -device usb-mouse -device usb-kbd \
@sulincix
sulincix / main.py
Created June 2, 2023 12:53
statusicon-test
#!/usr/bin/python3
import gi
gi.require_version("Gtk","3.0")
from gi.repository import Gtk
icon = Gtk.StatusIcon.new_from_icon_name("gtk-yes")
Gtk.main()
@sulincix
sulincix / convert.sh
Last active May 26, 2023 08:34
alpine-converter
# create rootfs directory
set -ex
mkdir /rootfs
cd /rootfs
# download rootfs
repo="https://dl-cdn.alpinelinux.org/alpine/edge/releases/$(uname -m)/"
archive=$(wget -O - $repo | grep "minirootfs" | grep "tar.gz<" | sort -V | tail -n1 | cut -f 2 -d "\"")
wget -O alpine-rootfs.tar.gz $repo/$archive
# extract rootfs
tar -xf alpine-rootfs.tar.gz
@sulincix
sulincix / check.sh
Last active January 15, 2024 13:27
Check ymp latests from arch
#!/bin/bash
set +e
f=$(mktemp)
red="\033[31;1m"
yellow="\033[33;1m"
reset="\033[;0m"
check_out_of_date(){
link=$(curl https://archlinux.org/packages/?q=$1 | grep -v unstable | grep ">$1<" | grep "<td><a href=" | head -n1 | cut -f2 -d"\"")
if [[ $link == "" ]] ; then
return
@sulincix
sulincix / main.vala
Last active February 17, 2023 18:21
dpi bulucu
// valac --pkg gtk+-3.0 main.vala -o main
int main(string[] args){
double constant_screen = 50.95481424;
Gtk.init(ref args);
var display = Gdk.Display.get_default();
for (var i = 0; i < display.get_n_monitors (); i++){
var monitor = display.get_monitor(i);
var width_milimeter = monitor.get_width_mm();
var height_milimeter = monitor.get_height_mm();
var width_pixel = monitor.get_geometry().width;