Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Ben-Nes mbn18

View GitHub Profile
@mbn18
mbn18 / file.go
Created Sep 15, 2017
Why the second range fail?
View file.go
type list []*item
// Work
for g := range *list {
z := *list
println(z[g].Name)
}
// Fail
for g := range *list {
@mbn18
mbn18 / api-server.go
Created Jun 13, 2017
How to return google/jsonapi as JSON using echo
View api-server.go
package main
import (
"github.com/google/jsonapi"
"github.com/labstack/echo"
"net/http"
)
type Album struct {
ID int `jsonapi:"primary,albums"`
@mbn18
mbn18 / gist:fff2592ec38e5d9798d0
Last active Feb 9, 2016
Is PUT working well with ZF2 & multipart/form-data?
View gist:fff2592ec38e5d9798d0
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
View test_perform_bug_on_unique_column.sql
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:9567af68d09e8597cc82
Last active Aug 29, 2015
Run skype in a docker
View gist:9567af68d09e8597cc82
# 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 / gist:6782ec00afe8addfe480
Created Dec 15, 2014
How to pass label attributes
View gist:6782ec00afe8addfe480
$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:d1b26269ff24947f6376
Created Oct 29, 2014
Quick start to Skype on Docker
View gist:d1b26269ff24947f6376
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:7ea2f627de4b2220dc18
Created Oct 10, 2014
unset does not effect the object which is outside the method context
View gist:7ea2f627de4b2220dc18
<?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:0d6ff5cb217c36419661
Last active Mar 11, 2022
How to install nsenter on Ubuntu 14.04
View gist:0d6ff5cb217c36419661
# 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
View gist:2da49be6534e1fdb16aa
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