Skip to content

Instantly share code, notes, and snippets.

View wakumaku's full-sized avatar
🔷
breaking (bad) things

wakumaku wakumaku

🔷
breaking (bad) things
View GitHub Profile
@wakumaku
wakumaku / dockertags.sh
Created October 4, 2017 15:58
Lists all tags of the given image
#!/bin/bash
# Credits: https://stackoverflow.com/questions/28320134/how-to-list-all-tags-for-a-docker-image-on-a-remote-registry
if [ $# -lt 1 ]
then
cat << HELP
dockertags -- list all tags for a Docker image on a remote registry.
EXAMPLE:
- list all tags for ubuntu:
@wakumaku
wakumaku / Dockerfile
Created July 10, 2017 13:32
Dockerfile for an openssh server
FROM ubuntu:16.04
RUN apt-get update && apt-get upgrade -y && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:YOUR_PASSWORD' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
@wakumaku
wakumaku / deleteOldFiles.sh
Created July 4, 2017 09:37
Script to delete old files in a directory by a pattern
#!/bin/bash
# set -x
BASE_DIR=/backups
TOTAL_KEEP=10
FIND_EXPRESSION="[0-9].+\_backup\.tar\.gz"
TOTAL_BACKUPS=`ls $BASE_DIR| egrep "$FIND_EXPRESSION" | wc -l`
@wakumaku
wakumaku / docker_remove_containers_images.sh
Last active September 27, 2017 14:36
delete all docker containers and images
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# docker rm $(docker ps --filter=status=exited --filter=status=created -q)
# Delete all images
docker rmi $(docker images -q)
# Delete untagged images
# docker rmi $(docker images -f "dangling=true" -q)
# Delete all volumes
docker volume rm $(docker volume ls -f dangling=true -q)
<?php
$fileContents = file_get_contents($filePath);
$fileContents = implode('', explode("\0", $fileContents));
@wakumaku
wakumaku / getElementPosition.js
Created January 26, 2016 14:26
Returns the relative position of an element in the page
// http://stackoverflow.com/questions/288699/get-the-position-of-a-div-span-tag
function getPos(el) {
// yay readability
for (var lx=0, ly=0;
el != null;
lx += el.offsetLeft, ly += el.offsetTop, el = el.offsetParent);
return {x: lx,y: ly};
}
@wakumaku
wakumaku / nginxCORS.conf
Created October 31, 2015 13:41
nginx CORS config - Cross-Origin Resource Sharing
# Source & Credits: https://michielkalkman.com/snippets/nginx-cors-open-configuration.html
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
# Om nom nom cookies
#
@wakumaku
wakumaku / install.sh
Last active October 31, 2015 13:57
Use firefox in headless mode to run with selenium into a server
sudo apt-get install firefox
sudo apt-get install xvfb
@wakumaku
wakumaku / createUserAllPrivileges.sql
Created September 16, 2015 12:59
[mysql] Create a new user and grant all privileges
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'user'@'localhost';
FLUSH PRIVILEGES;
@wakumaku
wakumaku / cleanboot.sh
Created September 15, 2015 23:21
Linux, clean boot partition script
#!/bin/bash
sudo apt-get remove `dpkg --list 'linux-image*' |grep ^ii | awk '{print $2}'\ | grep -v \`uname -r\``