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
@amcsi
amcsi / pthreads.php
Created April 8, 2014 21:46
Pthreads sleep() experiment
<?php
class MyThread extends Thread
{
public function run()
{
sleep(1);
echo "ran\n";
}
}
@amcsi
amcsi / vimrc
Created April 9, 2014 16:09
vim-submode next/prev method
" ]m -> mmmm (next method) MMMM (prev method)
call submode#enter_with('nextMethod', 'n', '', ']m', ']m')
call submode#leave_with('nextMethod', 'n', '', '<Esc>')
call submode#map('nextMethod', 'n', '', 'm', ']m')
call submode#map('nextMethod', 'n', '', 'M', '[m')
" [m -> mmmm (prev method) MMMM (next method)
call submode#enter_with('prevMethod', 'n', '', '[m', ']m')
call submode#leave_with('prevMethod', 'n', '', '<Esc>')
call submode#map('prevMethod', 'n', '', 'm', '[m')
@amcsi
amcsi / .tmux.conf
Created April 17, 2014 11:05
My .tmux.conf
# http://www.doknowevil.net/2010/10/18/sorry-screen-tmux-is-better-but-here-are-some-screen-lik-hotkeys/
unbind C-b
set -g prefix C-a
bind-key a send-prefix
# other ^A
unbind ^A
bind ^A last-window
@amcsi
amcsi / Person.php
Last active August 29, 2015 13:59
Immutable value object
<?php
namespace MyProject;
class Person
{
private $data;
/**
*
* [
@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`
#!/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 / 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(
@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 / 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) {
# 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