Skip to content

Instantly share code, notes, and snippets.

View raphaelchaib's full-sized avatar

Raphael Chaib raphaelchaib

View GitHub Profile
@raphaelchaib
raphaelchaib / git_sub_add.sh
Created June 29, 2023 14:35
Git Submodules: Read the .gitmodules file and add them to the index, following path rules
#!/bin/sh
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key local_path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $local_path
@raphaelchaib
raphaelchaib / README.md
Last active February 22, 2022 17:04
Sync cookies and session through WKWebviews

WKWebview: Sync Cookies and ProcessPool

After a long time researching and trying to figure out how to sync sessions and cookies through many webviews this was the best final working aproach that I came with

How to use it

... (wip)

TODO

@raphaelchaib
raphaelchaib / stringToBytes.js
Created January 30, 2019 21:34
Javascript: String to Bytes array
stringToBytes('this is a test');
function stringToBytes(str) {
var ch, st, re = [];
for (var i = 0; i < str.length; i++ ) {
ch = str.charCodeAt(i); // get char
st = []; // set up "stack"
do {
st.push( ch & 0xFF ); // push byte to stack
ch = ch >> 8; // shift value down by 1 byte
function dc_trace_cmd() {
local parent=`docker inspect -f '{{ .Parent }}' $1` 2>/dev/null
declare -i level=$2
echo ${level}: `docker inspect -f '{{ .ContainerConfig.Cmd }}' $1 2>/dev/null`
level= level + 1
if [ "${parent}" != "" ]; then
echo ${level}: $parent
dc_trace_cmd $parent $level
fi
}
function dc_trace_cmd() {
local parent=`docker inspect -f '{{ .Parent }}' $1` 2>/dev/null
declare -i level=$2
echo ${level}: `docker inspect -f '{{ .ContainerConfig.Cmd }}' $1 2>/dev/null`
level=level+1
if [ "${parent}" != "" ]; then
echo ${level}: $parent
dc_trace_cmd $parent $level
fi
}
@raphaelchaib
raphaelchaib / java-and-related.md
Created March 1, 2018 20:48
Linux: Softwares
@raphaelchaib
raphaelchaib / helpful-docker-commands.sh
Created January 22, 2018 17:25 — forked from garystafford/helpful-docker-commands.sh
My list of helpful docker commands
###############################################################################
# Helpful Docker commands and code snippets
###############################################################################
### CONTAINERS ###
docker stop $(docker ps -a -q) #stop ALL containers
docker rm -f $(docker ps -a -q) # remove ALL containers
docker rm -f $(sudo docker ps --before="container_id_here" -q) # can also filter
# helps with error: 'unexpected end of JSON input'
@raphaelchaib
raphaelchaib / docker.md
Last active May 23, 2020 21:50
Docker commands and nice tricks!

Docker commands

Build docker image

docker build -t <image-name:tag> <path|.>

Remove all running containers

docker rm $(docker ps -a -q)
@raphaelchaib
raphaelchaib / script.js
Created October 20, 2016 19:39
JavaScript: Reload frame
function reloadFrame(iframe) {
iframe.parentNode.replaceChild(iframe.cloneNode(), iFrame);
}
@raphaelchaib
raphaelchaib / Default (OSX).sublime-mousemap
Created August 24, 2016 21:08 — forked from adzenith/Default (OSX).sublime-mousemap
Sublime Text 2 better mouse handling
[
// Basic drag select
{
"button": "button1", "count": 1,
"press_command": "drag_select_callback"
},
{
// Select between selection and click location
"button": "button1", "modifiers": ["shift"],
"press_command": "drag_select_callback",