Skip to content

Instantly share code, notes, and snippets.

View Jekis's full-sized avatar

Eugene Eroshkin Jekis

  • Russia, Novosibirsk
View GitHub Profile
@Jekis
Jekis / jscodematcher
Created January 19, 2020 16:08
Finds js code in the <script> tag.
<?php
/**
* This is a regex builder.
* Final regular expression finds the js code in the <script> tag.
* It is complex because any js code will be found.
*/
$jsCodeGroups = [];
@Jekis
Jekis / toggle_swap.sh
Last active August 17, 2024 01:06
Empty swap. Clear swap. Move swap to RAM. Ubuntu.
#!/bin/bash
function echo_mem_stat () {
mem_total="$(free | grep 'Mem:' | awk '{print $2}')"
free_mem="$(free | grep 'Mem:' | awk '{print $7}')"
mem_percentage=$(($free_mem * 100 / $mem_total))
swap_total="$(free | grep 'Swap:' | awk '{print $2}')"
used_swap="$(free | grep 'Swap:' | awk '{print $3}')"
swap_percentage=$(($used_swap * 100 / $swap_total))
@Jekis
Jekis / cleanup-docker.sh
Last active August 23, 2022 02:15 — forked from mlebkowski/cleanup-docker.sh
Cleanup docker disk space
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
docker volume ls -f dangling=true | awk '{ print $2 }' | xargs docker volume rm
@Jekis
Jekis / update-postman.sh
Last active March 5, 2019 07:43
Download and install the latest version of Postman for Ubuntu. Create .desktop file.
#!/bin/bash
INSTALL_DIR=/opt/postman
if [ "$(whoami)" != "root" ]
then
echo "Sorry, you are not root. Use sudo!"
exit 1
fi
@Jekis
Jekis / update-phpstorm.sh
Last active July 24, 2022 06:49 — forked from olivertappin/update-phpstorm.sh
Download and install the latest version of PhpStorm for Ubuntu. Create .desktop file and use custom vmoptions.
#!/bin/bash
#
# Based on https://gist.github.com/olivertappin/e5920e131db9a451c91aa6e2bc24dc40
#
INSTALL_DIR=/opt/phpstorm
if [ "$(whoami)" != "root" ]
then
@Jekis
Jekis / consumers.yml
Last active January 26, 2016 04:51
Tasks for Symofony2 project to start/stop/restart rabbitmq consumers
# config/consumers.yml
# {consumer_name}: {how many processes to start}
consumers:
my_consumer_1: 1
my_consumer_2: 1
@Jekis
Jekis / parameters.rake
Created January 18, 2016 09:52 — forked from carlcraig/parameters.rake
Capistrano Symfony Parameters
namespace :symfony do
namespace :parameters do
desc "Create parameters.yml file based on the parameters.yml.dist one. Ask for all parameters."
task :create do
on roles(:all) do
if not test("[ -f #{shared_path}/app/config/parameters.yml ]")
distParameters = YAML::load(capture("cat #{release_path}/app/config/parameters.yml.dist"))
parameters = { "parameters" => {} }
distParameters['parameters'].each do |k,v|