Skip to content

Instantly share code, notes, and snippets.

@gjuric
gjuric / nginx-proxy-geoip
Created May 7, 2015 15:26
nginx - pass GEOIP headers to proxy host
# http block
geoip_city /usr/local/share/GeoIP/GeoIPCity.dat;
geoip_country /usr/local/share/GeoIP/GeoIPCountry.dat;
# location block
proxy_set_header GEOIP_COUNTRY_CODE $geoip_country_code;
proxy_set_header GEOIP_COUNTRY_CODE3 $geoip_country_code3;
proxy_set_header GEOIP_COUNTRY_NAME $geoip_country_name;
docker run -d \
--name=deconz \
--net=host \
--restart=always \
-v /etc/localtime:/etc/localtime:ro \
-v /volume1/Media/Docker/deconz:/root/.local/share/dresden-elektronik/deCONZ \
--device=/dev/ttyACM0 \
-e DECONZ_DEVICE=/dev/ttyACM0 \
marthoc/deconz
@gjuric
gjuric / gist:e0c9e45efb3d15e3b949
Created December 11, 2014 14:13
PHP-FPM log to syslog
/etc/php5/fpm/php-fpm.conf
error_log = syslog
syslog.ident = php-fpm
This will log to syslog PHP-FPM stuff that usually gets logged to /var/log/php5-fpm.log and is not that interesting:
... php-fpm[3537]: [NOTICE] fpm is running, pid 3537
... php-fpm[3537]: [NOTICE] ready to handle connections
... php-fpm[3537]: [NOTICE] Finishing ...
@gjuric
gjuric / minimal-debian-jessie-x64-DO.txt
Created November 6, 2015 16:02
Minimal Debian Jessie x64 Digital Ocean
apt-get purge apt-listchanges apt-utils aptitude aptitude-common aptitude-doc-en arping bc bind9-host ca-certificates cloud-init cloud-initramfs-growroot cloud-utils console-setup console-setup-linux debian-faq dh-python dictionaries-common discover discover-data distro-info distro-info-data dnsutils doc-debian docutils-common docutils-doc eject emacsen-common euca2ools fontconfig fontconfig-config fonts-dejavu-core ftp geoip-database groff-base hicolor-icon-theme iamerican ibritish ienglish-common info install-info installation-report isc-dhcp-client isc-dhcp-common iso-codes ispell laptop-detect libalgorithm-c3-perl libarchive-extract-perl libassuan0:amd64 libatk1.0-0:amd64 libatk1.0-data libauthen-sasl-perl libavahi-client3:amd64 libavahi-common-data:amd64 libavahi-common3:amd64 libboost-iostreams1.55.0:amd64 libbind9-90 python python-apt python-apt-common python-boto python-cffi python-chardet python-cheetah python-configobj python-crypto python-cryptography python-debian python-debianbts python-def
@gjuric
gjuric / gist:7405c2ff23c2c19e0d65
Created December 5, 2014 12:56
COMODO PositiveSSL certificate order
cat exmaple.com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt > example.com.crt
If some browsers are complaining add "AddTrustExternalCARoot.crt" to the chain:
cat exmaple.com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt > example.com.crt
bundle install --path vendor/bundle
init with:
bundle exec cap install
@gjuric
gjuric / piwik-nginx.conf
Created January 9, 2015 17:55
Piwik nginx configuration
server {
listen 80 default;
server_name stats.example.com;
return 301 https://stats.example.com$request_uri;
}
upstream php-fpm {
server unix:/var/run/php5-fpm.sock;
@gjuric
gjuric / mail.php
Created July 1, 2016 11:53
Script to open sent mail in Apple Mail
#!/usr/bin/env php
<?php
# Save this script somewhere and set you sendmail path in php.ini like this:
# sendmail_path = sudo -u <your_system_username> <path_to_script>/mail.php
# create a filename for the emlx file
list($ms, $time) = explode(' ', microtime());
$filename = dirname(__FILE__).'/'.date('Y-m-d h.i.s,', $time).substr($ms,2,3).'.emlx';
# write the email contents to the file
@gjuric
gjuric / ip.php
Created May 13, 2016 18:09
IP adresa
<?php
include_once('vendor/autoload.php');
use Symfony\Component\HttpFoundation\Request;
$request = Request::createFromGlobals();
// Ako imaš proxy ispred, ovdje podesi njegov/njegove IP adrese
// $request->setTrustedProxies(['127.0.0.1']);
$ip = $request->getClientIp();
@gjuric
gjuric / appProdProjectContainer.php
Created February 2, 2016 14:16
Doctrine ORM Metadata Cache service
<?php
protected function getDoctrineCache_Providers_Doctrine_Orm_DefaultMetadataCacheService()
{
$this->services['doctrine_cache.providers.doctrine.orm.default_metadata_cache'] = $instance = new \Doctrine\Common\Cache\ApcCache();
$instance->setNamespace('sf2orm_default_32698a00875dac44b2e177de4a61e9b868a21112a04f360ad75713c94e99d59c');
return $instance;
}