Skip to content

Instantly share code, notes, and snippets.

View gadelkareem's full-sized avatar
🎯
Focusing

Gadelkareem gadelkareem

🎯
Focusing
View GitHub Profile
#!/usr/bin/env bash
set -euo pipefail
cd `dirname $0`
# 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=$$
#!/usr/bin/env bash
set -euo pipefail
cd `dirname $0`
# 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=$$
@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
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 / 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"
registry:
restart: always
image: registry:latest
ports:
- 443:5000
environment:
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
REGISTRY_HTTP_TLS_KEY: /certs/domain.key
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_PATH: /var/lib/registry/passfile
<?php
function solution(int $n) {
$final = [];
$nArr = str_split($n);
$i = 0;
while (true) {
$el = pickGreatest($nArr);
$final[$i] = $nArr[$el];
@gadelkareem
gadelkareem / solr.service
Last active February 5, 2020 16:33 — forked from hammady/solr.service
systemd service file for Apache SOLR
# put this file in /etc/systemd/system/ as root
# below paths assume solr installed in /opt/solr, SOLR_PID_DIR is /data
# and that all configuration exists in /etc/default/solr.in.sh which is the case if previously installed as an init.d service
# change port in pid file if differs
# note that it is configured to auto restart solr if it fails (Restart=on-faliure) and that's the motivation indeed :)
# to switch from systemv (init.d) to systemd, do the following after creating this file:
# sudo systemctl daemon-reload
# sudo service solr stop # if already running
# sudo systemctl enable solr
# systemctl start solr
@gadelkareem
gadelkareem / bucket-policy.json
Last active December 21, 2023 11:38
Varnish with AWS S3 bucket as backend
{
"Version": "2012-10-17",
"Id": "S3PolicyId1",
"Statement": [
{
"Sid": "IPAllow",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example.bucket/*",