Skip to content

Instantly share code, notes, and snippets.

View standa's full-sized avatar

Standa standa

  • Standa
  • Prague, Czech Republic, Europe
View GitHub Profile
@standa
standa / check_digit_besr.php
Created July 28, 2014 13:19
Swiss BESR Invoice Check Digit
// -----------------------------------------------------------------------------
// @author standa | 2014-04-30 | Swiss Rechnung (BESR)
// not guaranteed 100% but seems to work for us
public function calculateCheckDigit($number)
{
$matrix = array(
0 => array(0,9,4,6,8,2,7,1,3,5),
1 => array(9,4,6,8,2,7,1,3,5,0),
@standa
standa / nginx.conf
Created August 21, 2014 09:15 — forked from leon/nginx.conf
server {
listen 80;
server_name localhost;
root /home/website/web;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
try_files $uri @rewriteapp;
location @rewriteapp {
@standa
standa / tailf-magento-nginx.sh
Created February 24, 2015 15:56
magento-nginx-tailf
#!/bin/bash
tail -f /var/log/nginx/error.log -f /www/var/log/exception.log -f /www/var/log/system.log
@standa
standa / post-commit
Last active August 29, 2015 14:16
Git post-commit php email hook
#!/usr/bin/env php
<?php
// Upload as .git/hooks/post-commit
mail(
'standa@example.com',.
implode(' ', array('[GIT]', trim(`hostname`), ' ', trim(`git log -n 1 --oneline`))),
`git log -n 1`,
implode(' ', array('From:', trim(`hostname`), 'git <standa@example.com>'))
@standa
standa / oauth2-client.php
Created March 9, 2015 09:45
PHP League oauth2-client implementation
<?php
ini_set('session.cookie_lifetime', 86400);
ini_set('session.gc_maxlifetime', 86400);
session_set_cookie_params(86400, dirname($_SERVER['REQUEST_URI']));
session_start();
require 'vendor/autoload.php';
@standa
standa / designer.html
Created April 14, 2015 22:14
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@standa
standa / gist:fdfc87af4008b8f367f0
Created April 30, 2015 10:02
magento_category_attribute.php
<?php
/**
* This script creates a custom category attribute 'H1 Test'
*
* @link http://fabrizioballiano.net/2012/02/08/create-a-custom-category-attribute-in-magento/
*
* @author Standa
* @version 2015-02-12
*/
@standa
standa / google_breadcrumbs.php
Created May 19, 2015 11:44
Google breadcrumbs
<?php
/**
* This generates breadcrumbs according to google specification
* @link https://developers.google.com/structured-data/testing-tool/
* Featuring:
* - nested category trail
* - multiple category trails
* - starting with Home bit
* - without the last bit (the actual product or the current category)
@standa
standa / HelloNamePage.html.twig
Last active August 29, 2015 14:21
Symfony Assetic config for minification via uglifyjs and uglifycss
{% extends '@YourWhateverNameYouUseBundle/layout.html.twig' %}
{% block body %}
<button class="btn">Hello {{ name }}!</button>
{# example: use for regular assets somewhere deep in your javascripts #}
{# assets:install --env=... has to be run beforehand #}
<script type="text/javascript" src="{{ asset('bundles/yourwhatevernameyouusebundle/js/ckeditor/ckeditor.js') }}"></script>
{% endblock body %}
@standa
standa / directions.txt
Created June 26, 2015 08:18
Calculate distance between two cities using google maps API
{
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 4.3561,
"lng" : 1.01389
},
"southwest" : {
"lat" : 9.293703,