Skip to content

Instantly share code, notes, and snippets.

@adamjakab
adamjakab / ScriptHandler.php
Last active August 29, 2015 14:06 — forked from daFish/ScriptHandler.php
Execute Bower install/update on post composer stuff
namespace Fmdb\CoreBundle\Composer;
use Sensio\Bundle\DistributionBundle\Composer\ScriptHandler as BaseScriptHandler;
use Symfony\Component\ClassLoader\ClassCollectionLoader;
use Symfony\Component\Process\Process;
class ScriptHandler extends BaseScriptHandler
{
public static function installBowerAssets($event)
{
@adamjakab
adamjakab / l2chroot.sh
Last active February 6, 2024 21:34
Chroot - copy binaries and their shared dynamic libraries to chrooted envirnoment
#!/bin/bash
# Use this script to copy shared (libs) files to Apache/Lighttpd chrooted
# jail server.
# ----------------------------------------------------------------------------
# Written by nixCraft <http://www.cyberciti.biz/tips/>
# (c) 2006 nixCraft under GNU GPL v2.0+
# + Added ld-linux support
# + Added error checking support
# ------------------------------------------------------------------------------
# See url for usage:
@adamjakab
adamjakab / info.php
Last active August 29, 2015 14:07
PHP script to test chrooted environment - mainly: session, network, mail
<?php
/*
* Test PHP IN CHROOT
*/
$remoteUrl = "http://www.cyberciti.biz/files/lighttpd/l2chroot.txt";
$testMail = "yourmail@yourdomain.com";
$testHostname = "google.com";
ini_set("display_errors", 1);

Nginx FastCGI cache

Example /etc/nginx/nginx.conf using FastCGI (e.g. to PHP-FPM) with FastCGI cache enabled. This will capture returned data and persist it to a disk based cache store for a configurable amount of time, great for robust full page caching.

Will need to create a directory to hold cache files, for the example given here that would be:

$ sudo mkdir -p /var/cache/nginxfastcgi
$ chown www-data: /var/cache/nginxfastcgi
@adamjakab
adamjakab / AgentsHelperphp
Created November 6, 2014 08:21
Helper function to render agents
function getContactDataFor($id, $userType) {
$answer = array();
global $AZCOMP_CORE;
$db = $AZCOMP_CORE->get('_jdb');
$sql = 'SELECT res.*'
.' FROM #__dierre_agenti AS res'
.' WHERE res.id = ' . $id
.'';
$db->setQuery($sql);
$row = $db->loadObject();
@adamjakab
adamjakab / cpumon.sh
Created November 24, 2014 12:07
Main cpu monitoring script
#!/bin/bash
#
# Author: Adam Jakab
# Description: Monitors CPU load and executes external script on exceeded treshold.
#
# Log file
LOGFILE="/var/log/cpumon/cpumon.log"
# Define Threshold
@adamjakab
adamjakab / recoverSystem.sh
Created November 24, 2014 12:07
Recovery script
#!/bin/bash
#
# Author: Adam Jakab
# Description:
# 1) Shuts down critical services(httpd,mysql)
# 2) Attempts the recovery of damaged mysql database files
# 3) Restarts services
#
# Command to use to start/stop services
@adamjakab
adamjakab / cpumon
Created November 24, 2014 12:08
Centos cpumon service (chkconfig compatible)
#!/bin/bash
#
# Author: Adam Jakab
#
# chkconfig: - 90 12
# description: CPU monitoring service with custom script
# processname: cpumon.sh
# pidfile: /var/run/cpumon.pid
#
# Create a new Token
curl -u 'githubuser' -d '{"note":"Your Application"}' https://api.github.com/authorizations
# It is: "ebab4dc37e654bb230a9c69ebcd5f38e9a81e210"
#{
# "created_at": "2013-01-04T18:00:28Z",
# "app": {
# "url": "http://developer.github.com/v3/oauth/#oauth-authorizations-api",
#!/bin/bash
mkdir ~/outlook
#File selection
readpst -o ~/outlook -r `zenity --file-selection`
find ~/outlook -type d | tac | grep -v '^~/outlook$' | xargs -d '\n' -I{} mv {} {}.sbd