Skip to content

Instantly share code, notes, and snippets.

View eliecharra's full-sized avatar

Elie CHARRA eliecharra

View GitHub Profile
just a placeholder
¢‿¢
©¿© o
ª{•̃̾_•̃̾}ª
¬_¬
¯\(º_o)/¯
¯\(º o)/¯
¯\_(⊙︿⊙)_/¯
¯\_(ツ)_/¯
°ω°
°Д°
/*
* Implement the dining philosopher’s problem with the following constraints/modifications.
*
* - There should be 5 philosophers sharing chopsticks, with one chopstick between each adjacent pair of philosophers.
* - Each philosopher should eat only 3 times
* - The philosophers pick up the chopsticks in any order, not lowest-numbered first.
* - In order to eat, a philosopher must get permission from a host which executes in its own goroutine.
* - The host allows no more than 2 philosophers to eat concurrently.
* - Each philosopher is numbered, 1 through 5.
#!/bin/sh
set -e
# Script to enable / disable ipv6 bridging on asuswrt
if [ "$2" == "connected" ]; then
echo "Adding rules to ebtables to bridge ipv6 traffic"
brctl addif br0 vlan2
ebtables -t broute -A BROUTING -i vlan2 -p ! ipv6 -j DROP
fi
@eliecharra
eliecharra / vpn-up.sh
Last active March 13, 2020 21:17
NetworkManager-dispatcher script to enable or disable wireguard on certain network based on gateway IP
#!/bin/sh
VPN_NAME="wg0"
interface=$1
status=$2
if [ "$status" == "up" ] && [ "$interface" != "$VPN_NAME" ]; then
if [ "$IP4_GATEWAY" == "10.0.100.1" ]; then
nmcli connection down $VPN_NAME
echo "Wireguard disabled for $CONNECTION_ID"
else

Keybase proof

I hereby claim:

  • I am eliecharra on github.
  • I am eliec (https://keybase.io/eliec) on keybase.
  • I have a public key ASC_cqVl1WJ4nBVyzBg-HBQFxUEgbvwGt5Mq6_Ir2KhBvgo

To claim this, I am signing this object:

@eliecharra
eliecharra / wait-msql.sh
Created March 9, 2017 15:07
little bash loop waits for mysql to be open
#!/bin/bash
until nc -z -v -w30 $MYSQL_HOST 3306
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 5
done
AWS_VAULT_PL_CHAR="☁️"
prompt_aws_vault() {
local vault_segment
vault_segment="`prompt_aws_vault_segment`"
[[ $vault_segment != '' ]] && echo -n "$fg[red]$vault_segment$reset_colors "
}
prompt_kube() {
[[ "$ZSH_KUBECTL_CONTEXT" != '' ]] && echo -n " kube:($fg[red]$ZSH_KUBECTL_CONTEXT$fg[blue])"
}
@eliecharra
eliecharra / CoverageContext.php
Last active September 28, 2018 14:00
Behat php code coverage context
<?php
use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
/**
* Created by PhpStorm.
* User: elie
* Date: 01/09/15
* Time: 11:29