Skip to content

Instantly share code, notes, and snippets.

@Bonno
Bonno / collection_values.php
Last active September 15, 2016 09:36
Simple and light way to build an array with the values of an collection withoud loading the complete objects in Magento
/** @var array $_productSkus */
protected $_productSkus;
/**
* Return the sku for a given productId
*
* @param $productId
* @return bool
*/
public function getProductSku($productId)
# http://localhost:8983
# Information for any lucene index through https://wiki.apache.org/solr/LukeRequestHandler
/solr/admin/luke?numTerms=0
# Wildcard query
/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on
# Query for text
/solr/select?omitHeader=false&fl=*&sort=position_category_+asc&start=0&q=THIS_IS_THE_SEARCH_TEXT&json.nl=flat&qt=magento_nl&wt=xml&rows=100
@Bonno
Bonno / ubuntu-rsyslog-hack.sh
Last active April 20, 2016 12:32 — forked from dragolabs/ubunru-rsyslog-hack.sh
Hack to repair 100% CPU load by rsyslog on ubuntu 12.04 in openvz
#!/bin/sh
service rsyslog stop
sed -i -e 's/^\$ModLoad imklog/#\$ModLoad imklog/g' /etc/rsyslog.conf
service rsyslog start
@Bonno
Bonno / icy_backup.sh
Created January 18, 2016 23:58
Backup and restore settings from and to your ICY E-thermostaat
# inlog gegevens zelf invullen:
user=
passwd=
# BACK UP
token=`curl -s --request POST "https://portal.icy.nl/login"; --data "username=$user&password=$passwd" | awk -F":" '{print $12}' | awk -F'"' '{print $2}'`
rm et.bup
echo -n `curl -s -H "Session-token:$token" --request GET "https://portal.icy.nl/data" ; | awk -F":" '{print $13}' | awk -F'"' '{print $1}' | sed s/"\["/"\,"/ | sed s/"],"// | sed s/\,/"\&week-clock[]="/g` >> et.bup
echo -n `curl -s -H "Session-token:$token" --request GET "https://portal.icy.nl/data" ; | awk -F":" '{print $14}' | awk -F'"' '{print $1}' | sed s/"\["/"\,"/ | sed s/"],"// | sed s/\,/"\&configuration[]="/g` >> et.bup
@Bonno
Bonno / GPL v2 file header
Created January 10, 2016 13:14
GPL v2 file header
one line to give the program's name and an idea of what it doe.s
Copyright (C) yyyy name of author
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@Bonno
Bonno / PHP-Curl verbose logging
Last active November 9, 2015 13:08
PHP-Curl verbose logging
CURLOPT_VERBOSE => TRUE, // TRUE to output verbose information. Writes output to STDERR, or the file specified using CURLOPT_STDERR.
CURLOPT_STDERR => $verbose = fopen('php://temp', 'rw+'),
$url = "http://stackoverflow.com/questions/tagged/java";
$handle = curl_init($url);
curl_setopt_array($handle, $curlDefault);
$html = curl_exec($handle);
$urlEndpoint = curl_getinfo($handle, CURLINFO_EFFECTIVE_URL);
echo "Verbose information:\n<pre>", !rewind($verbose), htmlspecialchars(stream_get_contents($verbose)), "</pre>\n";
curl_close($handle);
@Bonno
Bonno / Regex
Created September 4, 2015 11:34
Streetname/house numbers: \A(.*?)\s+(\d+[a-zA-Z]{0,1}\s{0,1}[-]{1}\s{0,1}\d*|\d+\d*)\s*([a-zA-Z]{0,1})
cadans, buitenblad, stuurbreedte, cassette, col, tax, verzet, dichtrijden, bolle renner, klimmen, vals plat, etappe, aanzetten, afdaling, lossen, er doorheen zitten, plakken, poten, stampen, bidon, kopje van bloemendaal, knieën
@Bonno
Bonno / create-ssl-cert
Created July 6, 2015 08:33
generate x509 SHA256 hash self-signed certificate using OpenSSL
openssl req -x509 -nodes -sha256 -days 365 -newkey rsa:2048 -keyout example.com.crt -out example.com.crt
# Check cerificate
openssl x509 -noout -text -in example.com.crt
@Bonno
Bonno / format-xml
Created June 10, 2015 07:13
Pretty format XML
tidy -xml -i your-file.xml > output.xml
@see http://stackoverflow.com/a/26327336