Skip to content

Instantly share code, notes, and snippets.

View ohmrefresh's full-sized avatar
😀

Ohm ohmrefresh

😀
  • Bangkok, Thailand
View GitHub Profile
@iradul
iradul / docker_image_cleanup.sh
Last active August 22, 2024 10:00
Remove all Docker images filtered by `pattern` except latest `n`
#some grep pattern
pattern=192.168
# save latest n images
n=1
# check first (?):
# docker inspect -f '{{ .Created }} {{ .Id }} {{ .RepoTags }}' $(docker images | tail -n+2 | sed 's/^\([^ ]*\) *\([^ ]*\) *\([^ ]*\).*/ \1:\2 \3 /' | grep $pattern | cut -d' ' -f3) | sort -r | tail -n+$((n+1))
docker rmi $(docker inspect -f '{{ .Created }} {{ .Id }}' $(docker images | tail -n+2 | sed 's/^\([^ ]*\) *\([^ ]*\) *\([^ ]*\).*/ \1:\2 \3 /' | grep $pattern | cut -d' ' -f3) | sort -r | tail -n+$((n+1)) | cut -d' ' -f2 | cut -c8-)
@SHaTRO
SHaTRO / install-docker-compose
Last active December 27, 2018 07:21
Bash script to Install docker-compose on Linux
#!/bin/bash
# This may be out of date, check at https://github.com/docker/compose/releases
DOCKER_PROJECT_USER=docker
DOCKER_COMPOSE_REPO=compose
DOCKER_COMPOSE_APIURL=https://api.github.com/repos/${DOCKER_PROJECT_USER}/${DOCKER_COMPOSE_REPO}/releases/latest
DOWNLOAD_VERSION=`curl -is ${DOCKER_COMPOSE_APIURL} | tr '\n' ' ' | sed 's/.*tag_name" *: *"\([0-9.]*\).*/\1/'`
[[ ${DOWNLOAD_VERSION} =~ ^[0-9.][0-9.]*$ ]] || DOWNLOAD_VERSION=
echo $DOWNLOAD_VERSION
@Eduruiz
Eduruiz / .htaccess
Last active April 15, 2018 14:05
.htaccess sample for codeigniter with some seo improvements.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond $1 !^(index\.php|assets|google999621f70dbac9aa\.html|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
@opunbuds
opunbuds / install_docker_centos.sh
Created November 1, 2016 05:55 — forked from igez/install_docker_centos.sh
Install Docker & Docker Compose on Centos 7
#!/bin/bash
wget -qO- https://get.docker.com/ | sh
sudo usermod -aG docker $(whoami)
sudo systemctl enable docker.service
sudo systemctl start docker.service
sudo yum install -y epel-release
sudo yum install -y python-pip
sudo yum upgrade -y python*
sudo pip install docker-compose --force --upgrade
@svanoort
svanoort / gcsettings.sh
Last active December 20, 2023 02:27
Blessed GC settings for big servers
# Base settings and GC logging
-server -XX:+AlwaysPreTouch # First should be default, but we make it explicit, second pre-zeroes memory mapped pages on JVM startup -- improves runtime performance
# -Xloggc:gc-%t.log # CUSTOMIZE LOCATION HERE - $path/gc-%t.log -- the %t in the gc log file path is so we get a new file with each JVM restart
-XX:NumberOfGCLogFiles=5 -XX:+UseGCLogFileRotation -XX:GCLogFileSize=20m # Limits the number of files, logs to folder
-XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintHeapAtGC -XX:+PrintGCCause
-XX:+PrintTenuringDistribution -XX:+PrintReferenceGC -XX:+PrintAdaptiveSizePolicy # gather info on object age & reference GC time for further tuning if needed.
# G1 specific settings -- probably should be default for multi-core systems with >2 GB of heap (below that, default is probably fine)
-XX:+UseG1GC
-XX:+UseStringDeduplication
@topriddy
topriddy / README.md
Created September 10, 2016 11:44
Steps for Integrating Jacoco in IntelliJ IDEA
  1. Integrate the dependency and plugin sections to relevant parts in your pom.xml from the pom.xml_fragment file below.
  2. Run "mvn clean package" to generate the results
  3. In IntelliJ, Select "Analyse -> Show Coverage Data..." and pick your Jacoco output file. This should be the path specified in the plug-in config i.e: ${basedir}/target/coverage-reports/jacoco-unit.exec

Output should be displayed in the IDE and you should also have the classes overlayed with test coverage.

@JonCole
JonCole / Redis-BestPractices-General.md
Last active December 2, 2025 10:45
Redis Best Practices

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@santoshachari
santoshachari / Laravel PHP7 LEMP AWS.md
Last active March 21, 2025 14:46
Laravel 5.x on Ubuntu 16.x, PHP 7.x, Nginx 1.9.x

#Steps to install latest Laravel, LEMP on AWS Ubuntu 16.4 version. This tutorial is the improvised verision of this tutorial on Digitalocean based on my experience.

Install PHP 7 on Ubuntu

Run the following commands in sequence.

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active January 9, 2025 12:22
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@rafaeltuelho
rafaeltuelho / openshift-cheatsheet.md
Last active December 5, 2025 14:24
My Openshift Cheatsheet

My Openshift Cheatsheet

List all non openshift/kube namespaces

requires jq CLI

oc get namespaces -o json | jq '[.items[] | select((.metadata.name | startswith("openshift") | not) and (.metadata.name | startswith("kube-") | not) and .metadata.name != "default" and (true)) | .metadata.name ]'

Project Quotes, Limits and Templates