Skip to content

Instantly share code, notes, and snippets.

View szepeshazi's full-sized avatar

András Szepesházi szepeshazi

View GitHub Profile
@szepeshazi
szepeshazi / parallel_test.php
Created January 3, 2012 20:37
Test script to show how Elgg 1.8+ handles asynchronous parallel metadata updates.
<?php
require_once (dirname(__FILE__)) . '/engine/start.php';
$options = array(
'type' => 'object',
'subtype' => 'paraleltest',
'limit' => 1
);
@szepeshazi
szepeshazi / group_module.php
Created March 11, 2012 09:28
Modifications to ELgg Group Administrator role to suppress "Upload a new file" link on group pages
<?php
/**
* Group file module
*/
$group = elgg_get_page_owner_entity();
if ($group->file_enable == "no") {
return true;
}
@szepeshazi
szepeshazi / HttpTestActivity.java
Created August 9, 2012 17:31
HttpUrlConnection disconnect issue on HTC (Froyo and below)
package org.wamped.playground;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
@szepeshazi
szepeshazi / gist:5582520
Created May 15, 2013 08:46
Friendly time / php
function get_friendly_time($time, $current_time = null) {
if (!$current_time) {
$current_time = time();
}
$diff = abs((int)$current_time - (int)$time);
$minute = 60;
$hour = $minute * 60;
@szepeshazi
szepeshazi / anagram.php
Last active March 31, 2017 09:46
Anagram test (PHP, multi-byte strings)
<?php
function isAnagram($string1, $string2) {
if (!is_string($string1) || !is_string($string2)) {
return false;
}
$map1 = [];
$map2 = [];
@szepeshazi
szepeshazi / tourparser.php
Last active March 31, 2017 11:30
XML Parser for TourRadar tours
<?php
require 'toursxml.php';
function xmlToCSV($text) {
$columns = ['Title', 'Code', 'Duration', 'Inclusions', 'MinPrice'];
$separator = '|';
$header = implode($separator, $columns);
@szepeshazi
szepeshazi / this.js
Last active April 14, 2017 20:42
JavaScript - the tricky parts
var myObj = {
a: 5,
b: function() {
console.log(this.a);
}
};
myObj.b(); // What will be the output of this call?
var myRef = myObj.b;
@szepeshazi
szepeshazi / string-set.js
Last active April 21, 2017 10:00
StringSet implementation
const StringSetBase = require("./string-set-base");
class StringSet extends StringSetBase {
constructor() {
super();
this.stringSet = new Set();
}
/**
@szepeshazi
szepeshazi / bunny.dart
Created June 7, 2017 08:01
Dart generic methods
abstract class Bunny {
String name;
void attack();
}
class Fluffy extends Bunny {
void attack() {
print('Licks hands violently');
}
}
@szepeshazi
szepeshazi / gtm.dart
Last active February 12, 2018 07:52
Adding variables from Dart to Google Tag Manager data layer
JsObject dataLayer = context['dataLayer'];
dataLayer ??= new JsObject(context['Array']);
Map<String, dynamic> productInfo = {
'name': '1 month subscription',
'price': 21000,
'currency': 'HUF'
};
dataLayer.callMethod('push', [new JsObject.jsify(productInfo)]);
context['dataLayer'] = dataLayer;