Skip to content

Instantly share code, notes, and snippets.

View micronax's full-sized avatar

Fabian Golle micronax

View GitHub Profile
@micronax
micronax / repack.sh
Created June 9, 2016 12:41
Repack jar-files with updated manifest file
#!/bin/bash
src_dir=`pwd`
mkdir "done"
for f in *.jar
do
mkdir -p "${f}_extracted"
unzip $f -d "${f}_extracted"
@micronax
micronax / unzip.php
Created December 28, 2015 19:09
Small PHP-Script with GUI to unzip files in current directory
<?php
echo '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">';
echo '<div class="container" style="margin-top:50px;">';
if (!class_exists('ZipArchive')) {
die("<h1>ZipArchive is not installed. Pleas echeck php.ini</h1>");
}
@micronax
micronax / taxrates.csv
Created November 3, 2015 15:27
Some european tax rates for csv import into Woocommerce.
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 10 columns, instead of 9. in line 2.
Ländercode,Bundesstaaten-Code,PLZ (Postleitzahl),Stadt,Steuersatz %,Steuername,Priorität,Zusammengesetzt,Versand,Steuerklasse
DE,*,*,*,19.0000,Mwst.,1,0,1,
AT,*,*,*,20.0000, Mwst.,1,0,1
BE,*,*,*,21.0000, Mwst.,1,0,1
BG,*,*,*,20.0000, Mwst.,1,0,1
HR,*,*,*,25.0000, Mwst.,1,0,1
CY,*,*,*,19.0000, Mwst.,1,0,1
CZ,*,*,*,21.0000, Mwst.,1,0,1
DK,*,*,*,25.0000, Mwst.,1,0,1
EE,*,*,*,20.0000, Mwst.,1,0,1
@micronax
micronax / YourController.php
Created August 27, 2015 14:06
Symfony 2 flash best-practice template for Twitter Bootstrap based Layouts
<?
// Usage in Controller Actions:
$this->addFlash('success', 'Your registration was successful!');
$this->addFlash('warning', 'This email addres is already registered!');
$this->addFlash('danger', 'Your account is currentl locked!');
@micronax
micronax / truncate_shopware_db.sql
Last active August 29, 2015 14:22
Alle Shopware-Produkte aus der Datenbank entfernen. Dabei bleiben Kategorien, Configurator-Sets, Konfiguration usw. unangetastet.
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `s_articles`;
TRUNCATE TABLE `s_articles_attributes`;
TRUNCATE TABLE `s_articles_categories`;
TRUNCATE TABLE `s_articles_categories_ro`;
TRUNCATE TABLE `s_articles_details`;
TRUNCATE TABLE `s_articles_img`;
TRUNCATE TABLE `s_articles_prices`;
TRUNCATE TABLE `s_articles_similar_shown_ro`;
TRUNCATE TABLE `s_articles_top_seller_ro`;
@micronax
micronax / MinChoices.php
Created April 27, 2015 08:50
Symfony2 Choice Form Validator for constraining a minimum selection of choices without using an entity
<?php
namespace AppBundle\Validator;
use Symfony\Component\Validator\Constraint;
class MinChoices extends Constraint
{
const TOO_FEW_ERROR = 2;
const TOO_MANY_ERROR = 3;
@micronax
micronax / remove.sh
Created January 6, 2015 13:11
Remove useless OSX cache files
#!/bin/bash
if [ "$CODA_SITE_LOCAL_PATH" != "" ]; then
cd "$CODA_SITE_LOCAL_PATH"
# http://www.westwind.com/reference/os-x/invisibles.html
find . -name 'Thumbs.db' -exec rm -rf {} \; # Windows
find . -name '.DS_Store' -exec rm -rf {} \; # Mac OSX
find . -name '._*' -exec rm -rf {} \; # Mac OSX resource forks
find . -name '_notes' -exec rm -rf {} \; # Dreamweaver
@micronax
micronax / SecurityTagLib.groovy
Created July 21, 2014 20:31
Updated version of SecurityTagLib.groovy to allow getting the current UserObject of Spring Security Plugin in any view in grails. Usage: ${sec.getUserObject()}
/* Copyright 2006-2014 SpringSource.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@micronax
micronax / AppWebTestCase.php
Created April 7, 2014 18:34
A simple and modular way to use Doctrines Data-Fixtures in Symfony2 Unit-Tests.
<?php
namespace Acme\CoreBundle\Tests;
use Doctrine\ORM\Tools\SchemaTool;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Doctrine\Common\DataFixtures\FixtureInterface;
class AppWebTestCase extends WebTestCase
{
@micronax
micronax / remove-duplicates-from-lines.rb
Created November 11, 2013 10:50
This small ruby-script removes all duplicates from the lines in a given file while the fields are separated by a given separator. Example: a;b;c;d;e;f;d;e;g;j;k;l gets cleaned into a;b;c;d;e;f;g;j;k;l
#!/usr/bin/env ruby
require 'csv'
/* SETTINGS */
inputFile = './input.csv'
outputFile = './output.csv'
separator = ";"
/* DONT CHANGE BELOW */
output = File.open(outputFile, 'w')