Skip to content

Instantly share code, notes, and snippets.

View micronax's full-sized avatar

Fabian Golle micronax

View GitHub Profile
@micronax
micronax / gist:4278405
Created December 13, 2012 18:11
Shorthand convert char to binary in python
binary = ''.join(['%08d'%int(bin(ord(s))[2:]) for s in ascii_input])
productToPush = {
'name': self.getName(article),
'active': True,
'tax': 19,
'laststock': self.lastStock,
'supplier': self.getManufacturerById(article[self.cols.index('lieferantnr')]),
'categories': [{'id': categoryId} for categoryId in self.getCategoryMapping(article)],
'variants': [
{
'isMain': isMain,
@micronax
micronax / index.php
Last active December 6, 2020 19:06
Render XML-Data using Twig-Template within the SILEX-Microframework
<?php
// Add to use-statements
use Symfony\Component\HttpFoundation\Response;
// [...] Your application code
// Action to return XML from Twig-Template
$app->get(
'/sitemap.xml',
function () use ($app) {
@micronax
micronax / decorate-requiered.js
Created August 19, 2013 10:52
Small jQuery hack to decorate input fields with required="required" attribute with an (red) asterisk
/** Decorate required fields **/
$('input[required="required"]').each(function(){
$(this).prev('label').after(' <span class="required">*</span>');
});
@micronax
micronax / highlight-link.js
Last active December 21, 2015 06:59
Small jQuery hack to add "active" class to <li> of current navigation link based on href-attribute and window.location
@micronax
micronax / gist:6319186
Last active September 27, 2017 14:22
Alle Shopware-Artikel aus der Datenbank entfernen + Media-DB für Artikel leeren. Achtung: Artikelbilder müssen noch manuell vom Server entfernt werden /media/img/
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_article_configurator_sets;
TRUNCATE TABLE s_article_configurator_set_group_relations;
@micronax
micronax / index.html
Last active December 23, 2015 08:59
Einen Gutschein-Code nach einer bestimmten Zeit in einem Online-Shop einblenden. (Bspw.: Shopware, Magento, ...) Support und Hilfe unter: www.fabian-golle.de/kontakt ---- Displaying a coupon code after a specific amount of time. Perfect for usage in online shops like Magento...
<!-- Include CSS -->
<link href="livecoupon.css" rel="stylesheet">
<!-- Include Javascript -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>
<script src="livecoupon.js"></script>
<!-- LiveCoupon begin -->
<div id="liveCoupon">
<a href="#your_coupon_link"><img src="example_coupon_image.png" alt="Couponcode XYZ" /></a>
@micronax
micronax / bitlyAutoShorten.js
Created September 23, 2013 21:27
Eine URL in einem HTML-Input bei Änderung automatisch in ein Bit.ly Kurzlink umwandeln. Dieses Snippet nutzt jQuery. Support unter: http://www.fabian-golle.de----Transform a url in a given html-input into a bit.ly shortlink using jQuery.
/**
* Auto Shorten URLs in a given text-input
* @author Fabian Golle <me@fabian-golle.de>
**/
jQuery(document).ready(function() {
var yourInput = $('#yourInputField');
var yourApiLogin = '__INSERT_YOUR_LOGIN_HERE'; // Get your API Credentials here:
var yourApiKey = '_INSERT_YOUR_API_KEY_HERE'; // https://bitly.com/a/settings/advanced
yourInput.change(function() {
@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')
@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
{