Skip to content

Instantly share code, notes, and snippets.

View gadelkareem's full-sized avatar
🎯
Focusing

Gadelkareem gadelkareem

🎯
Focusing
View GitHub Profile
@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=$!
package main
import (
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"fmt"
"strconv"
"time"
"sync"
)
@gadelkareem
gadelkareem / FileCache.go
Created March 2, 2018 04:46
Simple Golang file cache
package utilities
import (
"path/filepath"
"os"
"sync"
"io/ioutil"
"time"
"github.com/vmihailenco/msgpack"
)
@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 {
package main
import (
"bufio"
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/logs"
"github.com/ulule/limiter"
"github.com/ulule/limiter/drivers/store/memory"
"net"
@gadelkareem
gadelkareem / postgres_solr.sql
Created April 5, 2018 00:40
Convert postgres timestamp to solr date format
SELECT to_char('2018-02-28 18:48:11.196+00'::timestamp, 'YYYY-MM-DD"T"HH24:MI:SSZ')
@gadelkareem
gadelkareem / vault.sh
Last active April 9, 2018 23:17
Ansible vault encrypt/decrypt shell script
#!/usr/bin/env bash
####Usage
# ./vault.sh encrypt
# ./vault.sh dencrypt
# ./vault.sh encrypt /full/path/to/file.yml
######
set -euo pipefail
@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
@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/*",
@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