Skip to content

Instantly share code, notes, and snippets.

View gadelkareem's full-sized avatar
🎯
Focusing

Gadelkareem gadelkareem

🎯
Focusing
View GitHub Profile
@gadelkareem
gadelkareem / rds-postgres.yml
Last active April 27, 2018 01:16
Properly setup postgreSQL RDS using Ansible #updated here https://gadelkareem.com/2018/04/10/setup-postgresql-rds-using-ansible/
- set_fact:
env: staging
postgresql_admin_user: "pgadmin"
postgresql_admin_password: "some_pass"
postgresql_databases:
- owner: some_user
name: some_db
postgresql_users:
- name: some_user
<?php
function solution(int $n) {
$final = [];
$nArr = str_split($n);
$i = 0;
while (true) {
$el = pickGreatest($nArr);
$final[$i] = $nArr[$el];
@gadelkareem
gadelkareem / Hash.go
Created March 9, 2018 06:37
Hash model values to enable partial update for the ORM
package main
import (
"strings"
"reflect"
"github.com/mitchellh/hashstructure"
"fmt"
)
type Hash struct {
@gadelkareem
gadelkareem / io.copy.go
Last active March 14, 2019 00:05
io.copy hangs on hijacked connection
package main
import (
"context"
"fmt"
"github.com/gadelkareem/go-helpers"
"io"
"net"
"net/http"
"sync"
Run this command to install MG-CLI:
sudo su
apt-get update && \
apt-get install ocl-icd-libopencl1 -y && \
wget https://minergate.com/download/xfast-ubuntu-cli-amd && \
dpkg -i xfast-ubuntu-cli-amd
to start miner (4 cores for BCN) use this command:
minergate-cli -user <YOUR@EMAIL.KAPPA> -bcn 4
#!/bin/bash
set -e
sudo apt-get install libnss3 libappindicator1 fonts-liberation -y
sudo apt --fix-broken install -y
cd /tmp/
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
@gadelkareem
gadelkareem / concurrent-php.sh
Last active June 11, 2019 13:11
Launch multiple PHP processes with a bash script
#!/usr/bin/env bash
OFFSET=0
LIMIT=200000
TOTAL=1000000000000000
MAX_PROCESS=10
echo "" > nohup.log
tail -f nohup.log &
TAIL_PID=$!
@gadelkareem
gadelkareem / openssl_examples.md
Last active June 11, 2019 13:13
OpenSSL encrypt-decrypt examples

###Encrypt

php -r "echo openssl_encrypt('Hello OpenSSL', 'AES-256-CBC', 'SecretPass', 0, '6299868101947302');"

TLHG68yaaVtSsV3zOYtn2Q==

printf "Hello OpenSSL" | openssl enc -a -e -aes-256-cbc -K $(printf "SecretPass" | od -A n -t x1 | tr -d '\040\011\012\015') -iv $(printf "6299868101947302" | od -A n -t x1 | tr -d '\040\011\012\015')

TLHG68yaaVtSsV3zOYtn2Q==

@gadelkareem
gadelkareem / gitlab.sh
Created June 11, 2019 13:24
Gitlab crontab deploy script
#!/usr/bin/env bash
set -euo pipefail
cd `dirname $0`
#Project ID
PROJECT=827639846934
#https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html
PRIVATE_TOKEN=-BDlsq86JKHsndiwhD24
#!/usr/bin/env bash
set -euo pipefail
# lock it
PIDFILE="/tmp/$(basename "${BASH_SOURCE[0]%.*}.pid")"
exec 200>${PIDFILE}
flock -n 200 || ( echo "${BASH_SOURCE[0]} script is already running. Aborting . ." && exit 1 )
PID=$$
echo ${PID} 1>&200