Skip to content

Instantly share code, notes, and snippets.

View rantoniuk's full-sized avatar
Enjoying espresso

Radek Antoniuk rantoniuk

Enjoying espresso
View GitHub Profile
@rantoniuk
rantoniuk / backup.rake
Created January 10, 2011 12:53
Rake task for backing up MySQL database in Rails projects
namespace :db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7"
task :backup => [:environment] do
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
base_path = Rails.root
base_path = File.join(base_path, ENV["DIR"] || "backups")
backup_base = File.join(base_path, 'db_backups')
backup_folder = File.join(backup_base, datestamp)
backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump.sql")
FileUtils.mkdir_p(backup_folder)
db_config = ActiveRecord::Base.configurations[RAILS_ENV]
@rantoniuk
rantoniuk / BackupMigrate
Created February 2, 2011 17:45
Backup before migration and migrate task.
namespace :project do desc "Backup before migration and migrate"
task :update => [:environment] do
Rake::Task["db:backup"].invoke
Rake::Task["db:migrate"].invoke
end
end
@rantoniuk
rantoniuk / check_jmx_params.pl
Created September 27, 2011 22:32
check_jmx_params - Nagios script for monitoring Tomcat PermGen OldGen and currentThreads through JNDI JMX
#!/usr/bin/perl
use strict;
use warnings;
use POSIX;
use Getopt::Std;
getopt('h');
##################################################################
# Monitoring JMX by Radek Antoniuk <radek.antoniuk@gmail.com> #
##################################################################
@rantoniuk
rantoniuk / XMLRPC.pm.diff
Last active December 13, 2015 22:29
This script is meant to run a NESSUS scan on selected target networks, defined in targets.txt, and send an email report when the scan is finished. This script is based on the pieces I have found on the Internet, customised to my needs and for CentOS 6. For CentOS6, the XMLRPC.pm library has to be patched to work properly with the attached diff. …
139d138
< $self->{_token} = undef;
353,363c352,355
<
< my $scanList = $xmls->{'contents'}->[0]->{'scans'}->[0]->{'scanList'};
<
< if(ref($scanList->[0])) {
<
< if(exists($scanList->[0]->{'scan'})) {
< foreach my $scan (@{$scanList->[0]->{'scan'}}) {
@rantoniuk
rantoniuk / gist:1c72afc41e63f3dc2511
Created September 17, 2014 14:50
Bamboo/Powershell integration - copying artifact to a dated/versioned directory
$TODAY=(Get-Date).ToString('yyyy-MM-dd')
$VERSION=(dir Product.exe).VersionInfo.ProductVersion
$DIR="X:\Deployment\Product\$VERSION-$TODAY-${bamboo.deploy.release}\"
Write-Host "Saving artifacts to $DIR"
New-Item -itemtype directory $DIR
Copy-Item * $DIR
### Keybase proof
I hereby claim:
* I am warden on github.
* I am radek (https://keybase.io/radek) on keybase.
* I have a public key whose fingerprint is EC0E E21F 7C06 E7A7 7AF8 5D7D 701F 4D48 17DB AA21
To claim this, I am signing this object:
@rantoniuk
rantoniuk / gist:1bb14afe27afd26b5727
Last active October 15, 2015 09:42
.bash_profile with docker aliases and nice prompt
# To install:
# curl -s https://gist.githubusercontent.com/warden/1bb14afe27afd26b5727/raw/gistfile1.txt > ~/.bash_profile_gist && grep -q -F 'bash_profile_gist' ~/.bashrc || sed -i '1s/^/. ~\/.bash_profile_gist \n/' ~/.bashrc
#
# For MAC users (as sed on MAC OS X is stupid ;) ):
# curl -s https://gist.githubusercontent.com/warden/1bb14afe27afd26b5727/raw/gistfile1.txt > ~/.bash_profile_gist && grep -q -F 'bash_profile_gist' ~/.bashrc || sed -i -e '~' '1s/^/. ~\/.bash_profile_gist\'$'\n/' ~/.bash_profile \'$'\n
alias update-bash-profile='curl -s https://gist.githubusercontent.com/warden/1bb14afe27afd26b5727/raw/gistfile1.txt > ~/.bash_profile_gist && grep -q -F "bash_profile_gist" ~/.bashrc || sed -i "1s/^/. ~\/.bash_profile_gist \n/" ~/.bashrc'
## SSH AGENT ##
echo "Downloading JDK..."
curl -L -b "oraclelicense=a" http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.tar.gz -O
echo "Downloading Tomcat..."
curl -L http://ftp.piotrkosoft.net/pub/mirrors/ftp.apache.org/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24.tar.gz -O
tar zxf jdk-8u51-linux-x64.tar.gz
tar zxf apache-tomcat-8.0.24.tar.gz
PWD=$(pwd)
@rantoniuk
rantoniuk / IFTTTDate.md
Created January 14, 2017 11:09 — forked from oscarmorrison/IFTTTDate.md
Make IFTTT Date Format play nice with Google Spreadsheets

##Date and Time

=TIMEVALUE(SUBSTITUTE("{{OccurredAt}}"," at ", " ")) + DATEVALUE(SUBSTITUTE("{{OccurredAt}}"," at ", " "))

##Date

=DATEVALUE(SUBSTITUTE("{{OccurredAt}}"," at ", " "))

##Time

@rantoniuk
rantoniuk / linux.md
Created February 13, 2017 13:20
Useful Linux Commands

apt-get user-friendly package list

apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "PROGRAM: $1 INSTALLED: $2 AVAILABLE: $3\n"}'