Skip to content

Instantly share code, notes, and snippets.

View cacharle's full-sized avatar

Charles Cabergs cacharle

View GitHub Profile
@cacharle
cacharle / split.c
Created December 22, 2023 18:04
Split function in C
static size_t count_segment(char const *s, char c)
{
size_t counter = 0;
int i = 0;
while (s[i])
{
if (s[i] == c)
{
i++;
continue;
@cacharle
cacharle / cgit_nginx_conf
Created September 6, 2023 19:53
cgit configuration files
server {
listen 80 default_server;
listen [::]:80 default_server;
root /usr/share/cgit;
try_files $uri @cgit;
location ~ /.+/(info/refs|git-upload-pack) {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
#!/usr/bin/awk -f
# Markov chain exercice from chapter 3 (design) of the book The practice of programming.
BEGIN {
PREFIX_LEN = 2
# need space to detect is the end since other words can't have spaces in them
SUFFIX_END = "< END >"
# maximum number of words in the output
MAX_WORDS = 1000
@cacharle
cacharle / scrape_avatar_comics.py
Created August 15, 2020 09:42
Scrape some website for the avatar comics
#!/usr/bin/python3
import os
import sys
import itertools
import requests
from bs4 import BeautifulSoup
url_fmt = "https://www.omgbeaupeep.com/comics/Avatar_The_Last_Airbender/{:03}/{}/"
dir_name = "avatar_comics"
@cacharle
cacharle / change_remote_ssh.sh
Created July 23, 2020 17:58
Change github.com remote to use ssh
#!/bin/sh
[ $# -eq 0 ] && echo "Usage $0 REPOSITORY ..." && exit 1
for repo in $@; do
if [ ! -d $repo ] || [ ! -d $repo/.git ]; then
echo "$repo: Is not a repository"
continue
fi
@cacharle
cacharle / create_repository.sh
Created July 23, 2020 17:57
Create a repository on my server
#/bin/sh
[ $# -eq 0 ] && echo "Usage: $0 name" && exit 1
repo="/var/www/git/$1.git"
ssh git@cacharle.xyz <<EOF
mkdir $repo &&
cd $repo &&
git init --bare
@cacharle
cacharle / change_remote.sh
Created July 20, 2020 04:28
Change remote url of repository for username change
#!/bin/sh
[ $# -eq 0 ] && echo "Usage $0 REPOSITORY ..." && exit 1
for repo in $@; do
if [ ! -d $repo ] || [ ! -d $repo/.git ]; then
echo "$repo: Is not a repository"
continue
fi
import os
import requests
from bs4 import BeautifulSoup
url_base = "http://tldp.org/HOWTO/NCURSES-Programming-HOWTO"
dir_name = "ncurses_howto"
respond = requests.get("http://tldp.org/HOWTO/NCURSES-Programming-HOWTO")
if respond.status_code != 200:
raise IOError
@cacharle
cacharle / kernel.cl
Created May 15, 2020 16:43
opencl test
__kernel void function(__global char *data)
{
data[0] = 'H';
data[1] = 'e';
data[2] = 'l';
data[3] = 'l';
data[4] = 'o';
data[5] = '\n';
data[6] = '\0';
}
@cacharle
cacharle / main.cpp
Created April 23, 2020 14:49
code from the OpenGL serie of the Cherno
#include <cassert>
#include <iostream>
#include <string>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
static
unsigned int compileShader(unsigned int type, const std::string& source)
{
unsigned int id = glCreateShader(type);