Skip to content

Instantly share code, notes, and snippets.

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

Aleksandar Popovic alekpopovic

🏠
Working from home
View GitHub Profile
@alekpopovic
alekpopovic / gist:0122b640f0cb4beb66dd
Created February 12, 2016 10:17
Rolback bundle update
git checkout -- Gemfile.lock
@alekpopovic
alekpopovic / gist:c76ca20e809c7558cd9c
Created February 12, 2016 12:46
If you got following error during dnssd installation
If you got following error during dnssd installation
checking for dns_sd.h... no
unable to find dnssd header
*** extconf.rb failed ***
then you have to install few libraries:
sudo aptitude install libavahi-compat-libdnssd-dev
@alekpopovic
alekpopovic / curl.md
Created February 23, 2016 00:04 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@alekpopovic
alekpopovic / remove-docker-containers.md
Created March 1, 2016 09:46 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images
  1. Delete all containers

     $ docker ps -q -a | xargs docker rm
    

-q prints only the container IDs -a prints all containers

Notice that it uses xargs to issue a remove container command for each container ID

  1. Delete all untagged images
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
#!/bin/bash
# Delete all containers
@alekpopovic
alekpopovic / Sublime Text License Key
Created March 2, 2016 11:39
Sublime Text 2 License Key, Sublime Text 3 License Key, Sublime Text Full Version.
Tags: Sublime Text 2 License Key, Sublime Text 3 License Key, Sublime Text Full Version
Go to menu Help > Enter License.
----- BEGIN LICENSE -----
J2TeaM
2 User License
EA7E-940282
45CB0D8F 09100037 7D1056EB A1DDC1A2
web: sh -c 'cd ./directory/ && exec appname'
<?php
######################################
#
# Author: Aleksandar Popovic
#
# A recursive function to traverse a multi-dimensional array
# where the dimensions are not known
#
#######################################
$array = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
"1" => [
"key" => "value"
]
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]];
$array_obj = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
foreach($array_obj as $key => $value) {
echo $value;
}
<?php
function finder($array, $index) {
$arrayIt = new RecursiveArrayIterator($array);
$it = new RecursiveIteratorIterator(
$arrayIt, RecursiveIteratorIterator::SELF_FIRST
);
foreach ($it as $key => $value) {
if ($key == $index) {
return $value;