Skip to content

Instantly share code, notes, and snippets.

View arabcoders's full-sized avatar

Abdulmohsen arabcoders

View GitHub Profile
@arabcoders
arabcoders / inArrayBind.php
Created May 12, 2015 15:46
This function is usefel if you want to use bind elements in PDO for IN clause for example: ( select * from table where id IN ( element, element) ... )
<?php
/**
* Create Binds for Array Elements.
*
* @param array $ids
*
* @return array
* @throws \InvalidArgumentException
*/
function inArrayBind( array $ids )
@arabcoders
arabcoders / post-receive.sh
Created September 30, 2015 19:31 — forked from ryansechrest/post-receive.sh
Git post-receive hook to deploy WordPress and plugins as submodules. It can also install Node.js modules with npm and vendor packages with Composer.
#!/bin/bash
# Created on 7/17/13 by Ryan Sechrest
# Deploys pushed branch from the origin repository to the web directory
if [[ (-n $1) && (-n $2) && (-n $3) ]]; then
# Set path to project directory
project_path="/var/www/domains/$2/$3"
@arabcoders
arabcoders / converter.php
Created April 15, 2016 17:15 — forked from ShNURoK42/converter.php
Converter bbCode to markdown
protected function bbcode($bbcode)
{
$bbcode = str_replace("\n", " \n", $bbcode);
$bbcode = str_replace("[b]", "**", $bbcode);
$bbcode = str_replace("[/b]", "**", $bbcode);
$bbcode = str_replace("[i]", "*", $bbcode);
$bbcode = str_replace("[/i]", "*", $bbcode);
@arabcoders
arabcoders / vpn.sh
Created October 6, 2016 12:15
generate ovpn file
#!/bin/bash
#Dir where easy-rsa is placed
EASY_RSA_DIR="/etc/openvpn/easy-rsa"
KEYS_DIR="$EASY_RSA_DIR/keys"
# Path to tls auth file.
TLS_AUTH_PATH="/etc/openvpn/ta.key"
# Dir where profiles will be placed
OVPN_PATH="/root/ovpn"
@arabcoders
arabcoders / README.md
Created December 2, 2016 08:09 — forked from nikcub/README.md
Facebook PHP Source Code from August 2007
@arabcoders
arabcoders / post-mortem.md
Created April 12, 2017 17:28 — forked from joewiz/post-mortem.md
Recovery from nginx "Too many open files" error on Amazon AWS Linux

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files) 2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

    • Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depending on your system.)
  1. Added fs.file-max = 70000 to /etc/sysctl.conf
  2. Added `nginx soft nofile 1
@arabcoders
arabcoders / tar.gz with gpg-encryption on the fly
Created June 10, 2017 19:01 — forked from revnode/tar.gz with gpg-encryption on the fly
Create a encrypted tar.gz file from a directory on the fly. The encryption is done by GPG with a public key. The resulting filename is tagged with the date of creation. Very usefull for encrypted snapshots of folders.
tar -cvz /<path>/ | gpg --encrypt --recipient <keyID> > /<backup-path>/backup_`date +%d_%m_%Y`.tar.gz.gpg
@arabcoders
arabcoders / blur_detector
Created May 31, 2020 03:47 — forked from pceres/blur_detector
blurry photos detection
#! /bin/bash
#
# Author: Pasquale Ceres ([email protected])
# License: GPL ver. 3
#
# Script originally developed for the
# "San Lorenzo Martire Caposele Church Records Digitalization Project"
#
# http://www.facebook.com/group.php?gid=188973755117&v=photos
@arabcoders
arabcoders / (3.2.1 [0542c25]) sabnzbd newswrapper.patch
Last active April 26, 2021 22:15
Patch sabnzbd to use same hostip for downloads/outgoing connections., do note that the WebUI will still report host default IP connection. this only affect the outgoing NNTP connections., also this may not work well on IPv6 NTP servers, i only tested it on ipv4 servers. taken from https://forums.sabnzbd.org/viewtopic.php?p=96582#p96582 please re…
--- newswrapper.py 2021-02-28 23:35:56.627867710 +0300
+++ newswrapper.py.ori 2021-02-28 23:50:04.462036861 +0300
@@ -305,6 +305,14 @@
# Use a regular wrapper, no certificate validation
self.sock = ssl.wrap_socket(socket.socket(af, socktype, proto))
+ #bind outgoing to same interface.
+ try:
+ self.sock.bind((sabnzbd.cfg.cherryhost(), 0))
+ logging.info('bind to %s worked OK', sabnzbd.cfg.cherryhost() )
@arabcoders
arabcoders / FIX_PLEX.md
Created January 13, 2023 22:10
Fix Plex localmedia Legacy agent

Plex Legacy Localmedia agent.

There is a a bug in Plex old localmedia agent for python based agents, it will not search for any subtitles if the season folder is year based, for more information please take look at this plex bug report.

To fix the issue at least for linuxserver/plex containers. do the following, this has to happen everytime the container restarts as plex somehow redownload everytime the container restarts.

first gain shell access to your docker container by doing docker exec -ti container_name bash change container_name to whatever you named your container to be. Then execute the following commands.

$ sed -i 's/int(s) &lt; 1900/int(s) &lt; 3000/g' /usr/lib/plexmediaserver/Resources/Plug-ins-*/LocalMedia.bundle/Contents/Code/__init__.py