Skip to content

Instantly share code, notes, and snippets.

View sobstel's full-sized avatar
💎

sobstel

💎
  • 12:19 (UTC +01:00)
View GitHub Profile
@sobstel
sobstel / ErrorLevelActivationStrategy.php
Last active March 21, 2016 09:43
Symfony2: exclude 4xx client errors from logging
<?php
namespace MyBundle\Handler\FingersCrossed;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy as BaseErrorLevelActivationStrategy;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Activation strategy that ignores client errors (4xx)
*/
class ErrorLevelActivationStrategy extends BaseErrorLevelActivationStrategy
@sobstel
sobstel / lib.amd.js
Created February 25, 2016 11:23
AMD loading code
var LibName = (function () {
function LibName() {
// ...
}
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
// AMD. Register as an anonymous module.
define(function() {
'use strict';
@sobstel
sobstel / PaymentHandler.php
Last active February 25, 2016 10:31
Component\AdyenCreditCard
<?php
namespace Component\AdyenCreditCard;
use Component\AdyenCreditCard\DataService\ResponseLogDataService;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
class PaymentHandler
{
/**
@sobstel
sobstel / local.httpdfwd.plist
Last active October 15, 2015 12:01
OS X: forward port 80 to 8080
<!--
sudo vim /Library/LaunchDaemons/local.httpdfwd.plist
sudo launchctl load -Fw /Library/LaunchDaemons/local.httpdfwd.plist
https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"\>
<plist version="1.0">
@sobstel
sobstel / ssh_tunnel.sh
Created February 24, 2015 18:38
Connecting to remote server local services via SSH tunnel
# SSH tunnel, so it's possible to connect to remote server services via SSH
# argument: local_port, dest_port, host
ssh_tunnel () {
lsof -i:$1 > /dev/null 2>&1 || ssh -fNg -L $1:127.0.0.1:$2 $3
}
# sample: mysql
ssh_tunnel 3307 3306 HOST
@sobstel
sobstel / td-agent.conf
Last active November 17, 2015 07:47
Forwarding fluentd internal tag to loggly automatically
#
# install https://github.com/tagomoris/fluent-plugin-forest
#
# test
<source>
type tail
format /^(?<log>.*)$/
tag test
path /tmp/test.log
@sobstel
sobstel / nginx-php-fpm.conf
Last active August 29, 2015 14:05
Nginx PHP common configuration
location / {
try_files $uri /app.php$is_args$args;
}
location ~ ^.+\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
@sobstel
sobstel / convert_csv_to_sql.php
Created June 24, 2014 14:57
Convert CSV to SQL INSERT statements
<?php
$file = $argv[1];
$table = $argv[2];
$ls = file($file);
$out = "";
foreach ($ls as $l) {
$d = str_getcsv(trim($l));
@sobstel
sobstel / conv_base16_to_base36.sql
Last active November 11, 2023 09:14
MySQL: Converting from base-16 to base-36 number (with 128bit precision)
-- convert from base-16 to base-36 (128bit precision)
CREATE FUNCTION conv(_hex TEXT)
RETURNS TEXT
BEGIN
DECLARE _hex_len TINYINT;
DECLARE _dec DECIMAL(65);
DECLARE _chars CHAR(36);
DECLARE _base36 TEXT;
DECLARE _mod TINYINT;
@sobstel
sobstel / auth-vhost.conf
Created March 21, 2014 12:46
Passing HTTP AUTH BASIC/DIGEST headers from Apache to PHP-FPM
<VirtualHost *>
ServerName auth.dev
DocumentRoot "/var/www/auth"
ProxyPassMatch ^(/.*\.php)$ fcgi://127.0.0.1:9000/var/www/auth
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</VirtualHost>