Skip to content

Instantly share code, notes, and snippets.

View marten-cz's full-sized avatar

Martin Malek marten-cz

View GitHub Profile
@marten-cz
marten-cz / selenium-hub.sh
Created November 6, 2012 13:30
Init scripts for linux to start Selenium Grid
#!/bin/bash
DESC="Selenium Grid Server"
RUN_AS="selenium"
JAVA_BIN="/usr/bin/java"
SELENIUM_DIR="/opt/selenium"
PID_FILE="$SELENIUM_DIR/selenium-grid.pid"
JAR_FILE="$SELENIUM_DIR/selenium-server.jar"
LOG_DIR="/var/log/selenium"
@marten-cz
marten-cz / proc_open.php
Created November 14, 2012 09:10
PHP Proc open
<?php
namespace NetteLab\Console;
class Exec
{
public static function call($cmd, $input='')
{
$proc = proc_open($cmd, array(0=>array('pipe', 'r'), 1=>array('pipe', 'w'), 2=>array('pipe', 'w')), $pipes);
fwrite($pipes[0], $input);
fclose($pipes[0]);
@marten-cz
marten-cz / githook-postreceive-jenkins.sh
Created April 4, 2013 19:39
Git hook - build jenkins
#!/bin/bash
REPO="My-Job-Name"
TOKEN="token from jenkins"
JENKINSURL="http://login:password@jenkins.localhost/"
declare -A branches
while read oldrev newrew ref; do
if [ -z $ref ]; then
@marten-cz
marten-cz / createContainer.sh
Created June 29, 2013 18:01
Create new OpenVZ container and setup Puppet
#!/bin/bash
ID=$1
NAME=$2
if [ $# -ne 2 ]
then
echo "Usage: `basename $0` <id> <name>"
exit 65
fi

Welcome!

For feedback or suggestions, please send a tweet (@dideler). Gist comments don't notify me. Pull requests aren't possible with gists (yet), so I don't recommend forking because then I can't easily get the change.

Starring this gist will give me an idea of how many people consider this list useful.


Contents

@marten-cz
marten-cz / nette_ci.make
Created March 4, 2014 21:48
Simple PHP analysis makefile Continuous integration. Useful for projects based on Nette framework.
#!/usr/bin/make
all: analyze
# no more commands
mo:
find ./app/locale/ -name '*.po' -exec bash -c 'msgfmt -cv -o $${0/\.po/\.mo} $$0' {} \;
# Delete last build artifacts
cleanbuild:
@marten-cz
marten-cz / nette_ci.xml
Created March 4, 2014 21:56
Ant script for PHP analysis
<!--
This file is for Continuous Integration server
Please don't edit this file if you are not sure what you are doing.
For any change please consult it with appropriate person.
Author: Martin Malek <martin.malek@pagewiser.cz>
-->
<project name="project" default="" basedir=".">
<!-- Define for use with windows -->
@marten-cz
marten-cz / gist:ad1f65e1bd4c0de7f9bf
Created July 12, 2014 09:59
Convert images into PDF with resize and optimization

Solution requires ImageMagick

Convert files into JPG and rotate for file in *.bmp; do convert -resize 50% -rotate 90 "$file" rot/"$file".jpg; done

Convert images and optimize them as text pages for img in *.bmp; do mogrify -normalize -level 10%,90% -sharpen 0x1 -rotate 90 $img rot/"$img".jpg; done

Convert with better filename handling for file in *.bmp; do filet=basename $file .bmp; convert -rotate 90 -resize 50% "$file" rot/"printf %04d $filet".jpg; done

@marten-cz
marten-cz / centos.md
Last active August 29, 2015 14:03
Centos - problem connecting from Apache

Apache/PHP cannot connect to Sphinx or other service

# setsebool -P httpd_can_network_connect 1

Apache/PHP cannot connect to remote MySQL server

# setsebool -P httpd_can_network_connect_db 1

Cannot connect to SSH with key

@marten-cz
marten-cz / install_sentry.md
Created August 3, 2014 15:13
Installing Sentry

To install sentry from git, we can still use pip. Before installing, we will need some libraries

apt-get install libxml2-dev libxslt-dev

After that, we can install sentry from git

pip install --allow-unverified sentry sentry==dev