Skip to content

Instantly share code, notes, and snippets.

@guychouk
guychouk / fts.c
Last active May 7, 2024 17:52
🔍 Full Text Search text files using SQLite, written in C
#ifdef __APPLE__
#ifndef st_mtime
#define st_mtime st_mtimespec.tv_sec
#endif
#endif
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
@guychouk
guychouk / main.c
Created September 28, 2022 00:13
Ncurses and popen example
/* install ncurses and compile in the following manner: */
/* gcc -std=c99 -Wpedantic -Wall -lncurses main.c */
#include <ncurses.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int height, width, ch;
@guychouk
guychouk / lemp.sh
Last active May 7, 2024 17:49
LEMP Installation with PHP8
#!/bin/bash
apt update
apt upgrade
apt install gnupg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
apt update
apt install -y \
@guychouk
guychouk / finances.R
Last active May 7, 2024 17:50
💸 Analyzing my finances CSV with R
# function that reverses a string by characters
reverse_chars <- function(string)
{
# split string by characters
string_split = strsplit(string, split = "")
# reverse order
rev_order = nchar(string):1
# reversed characters
reversed_chars = string_split[[1]][rev_order]
# collapse reversed characters
@guychouk
guychouk / README.md
Last active January 21, 2024 05:12
Simple code deployment via a Github Action that uses git and rsync.

Simple Deployment 🚀

  • Install nginx and rsync on the server (using Debian as an example):
apt install -y nginx rsync 
  • Add the github user:
adduser --disabled-password --gecos "" --home /home/github github
@guychouk
guychouk / config
Created March 2, 2021 22:48
🔒 A sane base config for SSH.
ForwardAgent true
# Necessary for not breaking ssh on linux
IgnoreUnknown UseKeychain
# Use Keychain on macos - ignored on linux
UseKeychain yes
Host *
# This will look for private keys under the `~/.ssh/keys`
@guychouk
guychouk / zetz
Last active May 9, 2023 23:25
⚡️ Zetz: simple note taking
#!/usr/bin/env bash
#
# _______| |_ ____
# |_ / _ \ __|_ /
# / / __/ |_ / /
# /___\___|\__/___|
#
# A note taking app for the terminal.
#
@guychouk
guychouk / macros.ahk
Last active March 15, 2021 11:36
🤖 macros.ahk - My macros AutoHotkey script.
; Config ;
#SingleInstance force ; Force a single instance of this script
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Menu, Tray, icon, macros.ico ; Set system tray icon to robot arm
SetCapsLockState, AlwaysOff ; Set caps lock state to always be off
; Remappings ;
@guychouk
guychouk / msn-to-sqlite.py
Last active September 19, 2022 05:08
Insert MSN messenger chats XMLs to a SQLite DB.
'''
This script checks for the existence of a directory called "chats"
in the current working directory and looks for XML files to read.
Once the parsing is done, it creates an SQLite DB file, and a table
for storing the date, from, to, text and style attributes of the messages.
'''
import os
import sys
@guychouk
guychouk / scrape.php
Last active January 26, 2021 13:41
Example of using PHP's simple_html_dom package to scrape the EFA's website.
<?php
require 'simple_html_dom.php';
$baseUrl = "https://www.europeanfilmacademy.org/Presentation.presentation.0.html?&no_cache=1&uid=";
for ($i = 1866; $i <= 4500; $i++) {
$html = new simple_html_dom();
try {
$html->load_file($baseUrl . $i);
} catch (Exception $ex) {