Skip to content

Instantly share code, notes, and snippets.

View jkanclerz's full-sized avatar
🎯
Focusing

Jakub Kanclerz jkanclerz

🎯
Focusing
View GitHub Profile
@jkanclerz
jkanclerz / log_rotate.sh
Last active May 9, 2023 11:22
Simple bash log rotate script
#!/bin/bash
checkSizeOver() {
typeset -i LFSB LFSM LOG_SIZE=10
LF=$1
LOG_SIZE=$2
LFSB=$(stat -c "%s" $LF)
# This is bytes - turn into MB, base 2}
LFSM=${LFSB}/1048576
# This is bytes - turn into MB, base 2
if [ $LFSM -gt $LOG_SIZE ]
@jkanclerz
jkanclerz / behat-reference.feature
Created August 10, 2016 13:18 — forked from mnapoli/behat-reference.feature
Behat Mink reference
# Given
Given I am on [the] homepage
Given I am on "url"
# When
When I go to [the] homepage
When I go to "url"
When I reload the page
@jkanclerz
jkanclerz / dbMonitor.sh
Created September 22, 2015 11:05
Bash db connection monitoe
#!/bin/bash
user='user'
pass='pass'
host='host'
cmd="mysql -u $user -p$pass -h $host -e 'SHOW GLOBAL STATUS;'"
remoteCall='uptime'
if ! /bin/bash -c "$cmd";
then
@jkanclerz
jkanclerz / installrabbitmq.md
Last active August 29, 2015 14:21
install rabbitmq
@jkanclerz
jkanclerz / gist:f8cd0adb5f01ae007fe0
Created April 28, 2015 15:13
Linux NFS Redundant Storage

Redundant storage with NFS & Heartbeat

Wymagane zależności

apt get install ntp drbd8-utils heartbeat

Zróbmy to!

class CallbackExecutor
{
protected $callback;
public function __call($method, $args)
{
if(is_callable(array($this, $method))) {
return call_user_func_array($this->$method, $args);
}
// else throw exception
@jkanclerz
jkanclerz / deploy.sh
Created March 10, 2015 16:35
Remote Command Execution by ssh
#!/bin/bash
echo "deploy Was started"
hostname -f;
uptime;
for package in $@
do
echo $package
if [ "$(rpm -qa | grep -E "^$package")" != "" ]
@jkanclerz
jkanclerz / PaymentHandler.php
Last active August 29, 2015 14:14
Redirect to dotpay - Pay Action
<?php
namespace Jkanclerz\DemoBundle\Payment;
use Symfony\Component\HttpFoundation\Request;
class PaymentHandler
{
const TRANSACTION_OK = 'OK';
const TRANSACTION_ERROR = 'ERROR';
@jkanclerz
jkanclerz / Kernel.php
Last active August 29, 2015 14:07
Vagrant Env SF2 - Kernel Mod
public function getCacheDir()
{
if ($this->isVagrantEnvironment()) {
return '/dev/shm/project/cache/'.$this->environment;
}
return parent::getCacheDir();
}
public function getLogDir()
create database databasename;
create user 'user' identified by 'password';
grant all privileges on databasename.* to 'user'@localhost identified by 'password';
grant all privileges on databasename.* to 'user'@host;
grant all privileges on databasename.* to 'user'@%;