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 / php.ini
Created September 21, 2017 12:46
hhvm with proxygen
; DO NOT EDIT THIS FILE - put everything into server.ini
; AND CHECK tailf /var/log/hhvm/error.
; php options
session.save_handler = files
session.save_path = /var/lib/hhvm/sessions
session.gc_maxlifetime = 1440
; hhvm specific.
hhvm.log.level = Verbose
@standa
standa / unix_socket_xml_rpc_supervisor_getAllProcessInfo.php
Created September 5, 2017 10:00
Call XMLRPC method supervisor.getAllProcessInfo without php-xmlrpc installed via unix socket
<?php
function getSupervisorAllProcessInfo(): string
{
$xml = '"<?xml version="1.0" encoding="utf-8"?>' .
'<methodCall><methodName>supervisor.getAllProcessInfo</methodName><params/></methodCall>"';
$req = "POST /RPC2 HTTP/1.0\r\nContent-Type: text/xml\r\nContent-Length: " . strlen($xml) . "\r\n\r\n$xml";
$s = stream_socket_client('unix:///var/run/supervisor.sock', $errNo, $errStr);
@standa
standa / loop.sh
Created April 29, 2016 09:59
Infinite loop internet speed test
# download speedtest python script
# wget https://raw.githubusercontent.com/rsvp/speedtest-linux/master/speedtest
# wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
while true; do ./speedtest --log; sleep 900; done
@standa
standa / SupportDesk_FixAcl.php
Last active May 18, 2016 23:57 — forked from raybogman/SupportDesk_FixAcl.php
SupportDesk_FixAcl
<?php
/**
* Updated behaviour:
*
* - search also /controllers and /Controller folders
* - disregard adminhtml.xml setup, write 'return true' always - or comment it back in if you need it
* - write more verbose logs
* - only update controllers extending Mage_Adminhtml_Controller_Action
*
*
@standa
standa / replace-co-uk-with-domain.js
Created December 15, 2015 15:06
Replace ebay.co.uk with national ebay.nl, ebay.pl, etc. domains
/**
* This should replace .co.uk ebay links with the links based on the current hostname
*
* @author standa aardvark
* @version 2015-12-15
*
* Obfuscate via https://javascriptobfuscator.com/Javascript-Obfuscator.aspx
*/
(function () {
if (location.host.indexOf('.co.uk') == -1) {
@standa
standa / Observer.php
Created October 22, 2015 08:30
Magento observer add column to sales/order grid
<?php
class Aardvark_Modifications_Model_Observer
{
/**
* @see Ebizmarts_SagePaySuite_Model_Observer_Sales::addColumnToSalesOrderGrid()
*
* @param $observer
* @return mixed
@standa
standa / PostCodes.php
Created August 5, 2015 13:39
PostCodesValidator
<?php
/**
* Universal postcode checker helper class.
*
* This uses the most complete list of regexes we were able to find.
*
* @link http://stackoverflow.com/questions/578406/what-is-the-ultimate-postal-code-and-zip-regex
*
* @author Standa
* @version 2015-08-05
@standa
standa / create_20_mb_file.php
Created June 29, 2015 09:45
How to create a 20 MB file quickly in PHP
<?php
/** @link https://github.com/google/google-api-php-client/blob/master/examples/fileupload.php */
/************************************************
We'll setup an empty 20MB file to upload.
************************************************/
DEFINE("TESTFILE", 'testfile.txt');
if (!file_exists(TESTFILE)) {
$fh = fopen(TESTFILE, 'w');
fseek($fh, 1024*1024*20);
fwrite($fh, "!", 1);
@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,
@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 %}