Skip to content

Instantly share code, notes, and snippets.

View hayderimran7's full-sized avatar

Imran Hayder hayderimran7

View GitHub Profile
@hayderimran7
hayderimran7 / gist:d791c09997dc28eda3fb
Created February 13, 2015 22:41
How to get names of all jenkins plugins installed in your master
easiest way is by going through jenkins UI, but if you want to know from CLI, follow along:
1. cd to jenkins home directory i.e. 'cd /var/lib/jenkins'
2. cd to plugins folder
3. run command : ls -ld */ | awk '{print $9}'
e.g.
~/plugins$ ls -ld */ | awk '{print $9}'
4. this will show a list of plugins installed
@hayderimran7
hayderimran7 / gist:455edb0fc2de001f7820
Last active August 29, 2015 14:16
Fix docker devicemapper deletion.
So i was trying to completely uninstall docker , i did package uninstall successfully.
but removing a package doesnt remove the docker data that lives in `/var/lib/docker`.
well i did `rm -rf /var/lib/docker/*` i deleted all folders containing metadata and stuff ,
but there was one folder that was pain in neck .. and that was /var/lib/docker/devicemapper.
all it said `could not delete devicemapper: device or map busy` .
first of all, i should not be using devicemapper at all because docker uses aufs and it works pretty fine.
but since its hard to patch for kernel(well not hard, quite cumbersome) the aufs3 package,
so anyway if you are using devicemapper for docker, and trying to completely uninstall it , here is the howto:
## STEPS TO REMOVE DEVICEMAPPER FOLDER ###
* first try ` rm -rf /var/lib/docker`
@hayderimran7
hayderimran7 / gist:d1dea1d86c0d04f11b74
Created May 19, 2015 21:21
Awesome grep for .ini or .conf files
awesome grep for ini conf files
grep "^[^#;\[]"
grep -v '^#\|^\s*$'
What does this do?
The above grep will skip all empty lines in a file + skip all lines starting with '#' which usually mean the commented out part of config files..
its great when you are viewing those large never ending openstack oslo config files for like nova , tempest etc..
@hayderimran7
hayderimran7 / remove-non-hidden-only-nix
Created May 19, 2015 21:24
*nix: Remove everything in a folder except hidden files
The following is a nifty command to remove everything in a folder but the hidden files/folders .. Lets say you want to have hidden files , but remove all other data files , helpful when you wana keep info for like .git , .gitignore, .tox, .venv etc etc.. all these hidden files will not get deleted :)
rm -rf `ls -rth | xargs`

Background

This POS error with recently happened on a much worse POS system aka OpenSUSE. basically pip was error'ing out for any install i did .

Could not find any downloads that satisfy the requirement

Diagnosis

@hayderimran7
hayderimran7 / firefox-in-docker-container-sles-opensuse.md
Last active August 29, 2015 14:27
Run firefox in docker container based on opensuse /sles

quite an ordeal when working with OS like opensuse. The feeling is mutually shared by father/BDFL of Linux kernel "Linus Torvalds" as he rants about opensuse OS here: https://plus.google.com/+LinusTorvalds/posts/1vyfmNCYpi5

Now that i was trying to install firefox in a opensuse based container: zypper in MozillaFirefox

and also dont forget to install X11 for headless testing of selenium

zypper in xorg-x11-server

@hayderimran7
hayderimran7 / solve_docker_devicemapper_unknown_device.md
Last active November 4, 2015 18:33
How to solve docker driver devicemapper failed to create image rootfs Unknown device when doing a docker commit

How to solve docker driver devicemapper failed to create image rootfs Unknown device when doing a docker commit*

TL;DR:

so in short:

  1. do a docker ps to see which image was this container started from.
  2. do a docker pull of that image.
  3. docker commit of that container, it should work.

Let's say your Docker container exposes the port 8000 and you want access it from your other computers on your LAN. You can do it temporarily, using ssh:

Run following command (and keep it open) to use ssh to forward all accesses to your OSX/Windows box's port 8000 to the Boot2Docker virtual machine's port 8000:

$ boot2docker ssh -vnNTL *:8000:localhost:8000

source : https://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md

# create a tinycorelinux fs with custom .tcz packages
# prerequisites: apt-get install squashfs-tools, npm i nugget -g
# dl release + packages (add your packages here)
nugget http://tinycorelinux.net/6.x/x86_64/release/CorePure64-6.3.iso http://tinycorelinux.net/6.x/x86_64/tcz/{pkg-config,make,gcc,gcc_base-dev,gcc_libs-dev,gcc_libs,glibc_base-dev,linux-3.16.2_api_headers,fuse}.tcz -c
# to support compiling addons
unsquashfs -f pkg-config.tcz
unsquashfs -f make.tcz
unsquashfs -f gcc.tcz

Python mocking for non-existing modules

Mocking is great; it lets to overcome external dependency of your actual library, and perform our own app's internal functionality.

However sometimes we have an external dep, which is not installed , for instance:

# myapp.py
import external
print external.values
external.some_call()