Skip to content

Instantly share code, notes, and snippets.

View amcsi's full-sized avatar
🏠
Working from home

Attila Szeremi amcsi

🏠
Working from home
View GitHub Profile
<?php
declare(strict_types=1);
/**
* Walks nested array structures to retrieve values.
*/
class ArrayWalkerReference
{
/**
@amcsi
amcsi / createElement.vue
Created April 17, 2017 16:17
Vue file showing createElement() method references not working in IntelliJ plugin
<template>
<div>
<button type="button" @click="createElement()">Create element</button>
<button type="button" @click="prependRow()">+</button>
</div>
</template>
<script>
export default {
methods: {
@amcsi
amcsi / memleak.php
Created July 10, 2016 17:22
PHP memory leak
<?php
function printMemoryUsage() {
gc_collect_cycles();
printf("Memory used: %.4fMB\n", memory_get_usage() / 1024 / 1024);
}
gc_enable();
$batchCount = 1000;
$iterations = 10000;
@amcsi
amcsi / elm-package.json
Created May 10, 2016 19:59
failing elm-package.json
{
"version": "1.0.0",
"summary": "Tic Tac Toe practice project",
"repository": "https://github.com/amcsi/elm-tic-tac-toe.git",
"license": "MIT",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
# deb cdrom:[Ubuntu 14.04.1 LTS _Trusty Tahr_ - Release amd64 (20140722.2)]/ trusty main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://gb.archive.ubuntu.com/ubuntu/ utopic main restricted
deb-src http://gb.archive.ubuntu.com/ubuntu/ utopic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://gb.archive.ubuntu.com/ubuntu/ utopic-updates main restricted
@amcsi
amcsi / str_replace.c
Created May 19, 2015 10:03
My str_replace() implementation in C
/**
* @author amcsi / Szerémi Attila
**/
#include <stdio.h>
/**
* Returns the length of a string
**/
int strlen(char* str) {
@amcsi
amcsi / protected.php
Created March 29, 2015 00:29
Access protected methods and properties easily without reflection with the new anonymous classes feature
<?php
class A {
protected $protectedProperty = 'default';
public function get()
{
return $this->protectedProperty;
}
}
@amcsi
amcsi / routes.php
Created October 22, 2014 15:52
ZF2 routes - merging route names
<?php
return array(
'router' => array(
'router_class' => 'Zend\Mvc\Router\Http\TranslatorAwareTreeRouteStack',
'routes' => array(
'base' => array(
'type' => 'Literal',
'options' => array(
'route' => '/base',
'defaults' => array(
#!/bin/sh
#
# This is a script to run syntax check (via `sh -n $filename`) but it
# supports recursive checking and --quiet
QUIET=0
while [ "$1" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
case $PARAM in
@amcsi
amcsi / .bashvimrc.sh
Last active August 29, 2015 14:01
Keeping track of Vim nesting
# This file is loaded by vim when calling :sh
# The purpose of this file is to set up PS1 to show that you are in a shell
# opened by vim.
source ~/.bashrc
export VIMEXTRA=''
if [[ -z "$VIMSHELL" ]]; then
export VIMSHELL=1
else
export VIMSHELL=`expr $VIMSHELL + 1`