Skip to content

Instantly share code, notes, and snippets.

View mbn18's full-sized avatar

Michael Ben-Nes mbn18

View GitHub Profile
On host 1
nc -v -l 2222 > /dev/null
On host 2
dd if=/dev/zero bs=1024K count=30720 | nc -v 10.0.26.132 2222
@mbn18
mbn18 / gist:7ea2f627de4b2220dc18
Created October 10, 2014 11:57
unset does not effect the object which is outside the method context
<?php
/**
* Delete an entity from the global identity map and all other queues
* @param AbstractDomainEntity $entity
*/
static public function unRegister(AbstractDomainEntity $entity)
{
$instance = self::getInstance();
$instance->registerClean($entity);
unset($instance->all[$instance->globalKey($entity)]);
@mbn18
mbn18 / gist:d1b26269ff24947f6376
Created October 29, 2014 07:49
Quick start to Skype on Docker
https://registry.hub.docker.com/u/tomparys/skype/
# Create Skype container
# Insure .Skype exist in the home dir
sudo docker run --name skype -d -p 55555:22 -v /home/miki/.Skype:/home/docker/.Skype tomparys/skype
ssh-keygen -t rsa -C "Just for skype"
$ cat .ssh/config
@mbn18
mbn18 / gist:6782ec00afe8addfe480
Created December 15, 2014 14:23
How to pass label attributes
$this->add(array(
'name' => 'name',
'options' => [
'label' => 'Garden Name',
'attributes' => [
'class' => 'col-lg-2 col-sm-2 control-label',
],
],
'attributes' => [
'class' => 'form-control',
@mbn18
mbn18 / gist:9567af68d09e8597cc82
Last active August 29, 2015 14:18
Run skype in a docker
# Few steps to setup Skype as a docker
# Might be over complicated as I did it back at Oct 2014 when I just started with docker (but it still works well)
https://registry.hub.docker.com/u/tomparys/skype/
# Create Skype container
# Insure .Skype exist in the home dir
sudo docker run --name skype -d -p 55555:22 -v /home/miki/.Skype:/home/docker/.Skype tomparys/skype
@mbn18
mbn18 / test_perform_bug_on_unique_column.sql
Created August 20, 2015 17:09
Bug on PostgreSQL 9.4.4
DROP TABLE test;
SELECT * FROM test;
CREATE TABLE test (
id SERIAL,
name TEXT
);
INSERT INTO test (name) VALUES ('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h');
@mbn18
mbn18 / gist:fff2592ec38e5d9798d0
Last active February 9, 2016 19:46
Is PUT working well with ZF2 & multipart/form-data?
Note that that test[] is squashed
$ http --form -f PUT http://127.0.0.1/api/post/ZDqojJqaYumqxJKzXUvB7Y author='author' content='content' title='title' test[]='ffff' test[]='zzzz' file@~/Pictures/Screenshot\ from\ 2015-09-13\ 17-12-02.png
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
Date: Tue, 09 Feb 2016 19:42:48 GMT
Server: nginx/1.9.7
@mbn18
mbn18 / api-server.go
Created June 13, 2017 06:58
How to return google/jsonapi as JSON using echo
package main
import (
"github.com/google/jsonapi"
"github.com/labstack/echo"
"net/http"
)
type Album struct {
ID int `jsonapi:"primary,albums"`
@mbn18
mbn18 / file.go
Created September 15, 2017 09:00
Why the second range fail?
type list []*item
// Work
for g := range *list {
z := *list
println(z[g].Name)
}
// Fail
for g := range *list {
@mbn18
mbn18 / gist:0d6ff5cb217c36419661
Last active October 21, 2023 10:22
How to install nsenter on Ubuntu 14.04
# Ubuntu 14.04 don't have nsenter - the straight forward way required me to install build tools and etc.
# I preferred to keep the system clean and install nsenter in a container and then copy the command to the host
# Note - its also possible to run nsenter from a container (didn't tried) https://github.com/jpetazzo/nsenter
# start a container
docker run --name nsenter -it ubuntu:14.04 bash
## in the docker
apt-get update
apt-get install git build-essential libncurses5-dev libslang2-dev gettext zlib1g-dev libselinux1-dev debhelper lsb-release pkg-config po-debconf autoconf automake autopoint libtool