Skip to content

Instantly share code, notes, and snippets.

/* Test IBAN values:
HR 15 2340 0093 2109 5545 7
HR 5023400093102278840
*/
#include <iostream>
#include <string>
#include <algorithm> // needed for remove_if
using namespace std;
<?php
/**
* Using PHP syntax, partition the array A into two arrays B and C in a way that that the difference between the
* sum of elements in B and the sum of elements in C is minimized.
*
* @author Stjepan Udovičić ([email protected])
*/
/** Predefined array */
$A = array(
@udovicic
udovicic / sendmail.php
Created January 12, 2015 12:10
Fake sendmail - write content to file
#!/usr/bin/php
<?php
/**
* Fake mail sending: log content to file
*
* Instructions:
* 1. Save as /usr/sbin/sendmail
* 2. Make it executable
*/
@udovicic
udovicic / nginx.conf
Created January 15, 2015 08:57
nginx configuration for Sendy
upstream sendybackend {
server unix:/var/run/php-fcgi-sendy.sock;
}
server{
listen {server_ip}:80;
server_name sendy.{domain};
autoindex off;
@udovicic
udovicic / update.php
Created January 21, 2015 10:06
Script for triggering module updates and cache refresh for Magento EE
<?php
/**
* Upgrade script based on https://gist.github.com/colinmollenhour/2715268
* Set global/skip_process_modules_updates to '1' in app/etc/local.xml
*
* Execute script to trigger upgrades and cache refresh
*/
require_once 'abstract.php';
@udovicic
udovicic / table_cleaning.sql
Created September 27, 2015 10:50
Magento extra table flush
SET foreign_key_checks = 0;
TRUNCATE `core_cache_option`;
TRUNCATE `core_cache_tag`;
TRUNCATE `core_session`;
TRUNCATE `dataflow_batch_export`;
TRUNCATE `dataflow_batch_import`;
TRUNCATE `enterprise_logging_event`;
TRUNCATE `enterprise_logging_event_changes`;
TRUNCATE `enterprise_support_backup`;
TRUNCATE `enterprise_support_backup_item`;
@udovicic
udovicic / InventoryUpdate.php
Created October 31, 2015 11:17
SOAP v2 Inventory update example
<?php
/**
* Magento catalogInventoryStockItemUpdate API example Using SOAPv2
*
* Local measurements:
* Login time: 1.3139259815216s
* Total execution time: 34.751662969589s
*/
/**

Preparing local environment for Magento development

This guide is based on Linux mint, Ubuntu based linux distribution. You can download it from here. It will help you setup apache environment in your home folder.

Packgae installation

You will need to install several things. First of them is Apache itself. From terminal run:

sudo apt-get install apache2
@udovicic
udovicic / checker.php
Created June 16, 2016 08:46
SSL checker
<?php
/**
* Code is taken from: https://raw.githubusercontent.com/zencart/zencart/v160/extras/curltester.php
* Just put it in the web root and execute. Evertything must be marked as 'GOOD', otherwise you will have problems...
*
*
* Standalone Diagnostics/Debug tool for testing CURL communications to common 3rd party services such as USPS and PayPal and Authorize.net and more.
* Accepted parameters:
* d=1 or details=1 -- show CURL connection details -- useful for determining cause of communications problems
* r=1 -- show Response obtained from destination server -- this may contain an error message, but usually means communication was okay
@udovicic
udovicic / temperature.py
Last active September 5, 2016 18:48
DHT22 sensors readings using Adafruit Python DHT Sensor Library
#!/usr/bin/python
# Requires Adafruit Python DHT Sensor Library
# https://github.com/adafruit/Adafruit_Python_DHT
# [email protected]:adafruit/Adafruit_Python_DHT.git
# Measures temperature 5 times, and sends average to thingspeak.
# First measurement is discarded.
# It is intended to be executed by cron in background