Skip to content

Instantly share code, notes, and snippets.

View cacharle's full-sized avatar

Charles Cabergs cacharle

View GitHub Profile
@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);
@cacharle
cacharle / hi
Created January 23, 2020 18:32
hi
hi
@cacharle
cacharle / rubik.md
Last active March 21, 2024 10:41
rubik's cub OLL and PLL algorithms

OLL

Sune:

if one yellow facing up, put in on the front so that we see another yellow facing toward.

toward stikers right: R U R' U R U2 R'
toward stikers left : L' U' L U' L' U2 L (anti sune)

@cacharle
cacharle / craps.adb
Created December 3, 2019 07:55
tp craps openclassrooms ada course
with Ada.Numerics.Discrete_random;
with Ada.Text_io; use Ada.Text_io;
with Ada.Integer_Text_io; use Ada.Integer_Text_io;
procedure Craps is
subtype Interval is Integer range 1..6;
package IntRandom is new Ada.Numerics.Discrete_random(Interval);
use IntRandom;
gen: Generator;
@cacharle
cacharle / cdecl-cheatsheet.s
Created November 24, 2019 20:48
cheat sheet of c calling conventions
; Only need to save reg if we use them after
; caller rules:
; 1. save caller-saved reg r10, r11
; /!\ all param reg
; 2. pass param with regs rdi, rsi, rdx, rcx, r8, r9
; if there is more pass them onto the stack in reverse order
; 3. use call
; 4. restore stack state by removing passed on the stack param
; 5. return value of callee in rax
unsigned char rotate_left(unsigned char b)
{
unsigned char first = b & 0x80;
b <<= 1;
b |= first >> 7;
return b;
}
unsigned char rotate_right(unsigned char b)
{