Skip to content

Instantly share code, notes, and snippets.

View pjendrusik's full-sized avatar
🐿️

Paweł Jendrusik pjendrusik

🐿️
View GitHub Profile
<?php
/**
* Remove any non-ASCII characters and convert known non-ASCII characters
* to their ASCII equivalents, if possible.
*
* @param string $string
* @return string $string
* @author Jay Williams <myd3.com>
* @license MIT License
* @link http://gist.github.com/119517
@pjendrusik
pjendrusik / gist:5488117
Created April 30, 2013 11:23 — forked from futuremill-ltd/gist:2318876
Debian 4 gitlab install
# From a fresh install of squeeze
apt-get install ruby rubygems # Need ruby to use fpm
gem1.8 install fpm --no-ri --no-rdoc
apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -zxvf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125
rm -rf /tmp/ruby193
# Configuration file for runtime kernel parameters.
# See sysctl.conf(5) for more information.
# Protection from SYN flood attack.
net.ipv4.tcp_syncookies = 1
# See evil packets in your logs.
#net.ipv4.conf.all.log_martians = 1
# Disable packet forwarding.
@pjendrusik
pjendrusik / gist:7010006
Created October 16, 2013 15:46
loop for each day between dates
$begin = new DateTime( '2010-05-01' );
$end = new DateTime( '2010-05-10' );
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
foreach ( $period as $dt ){
echo $dt->format( "l Y-m-d H:i:s\n" );
}
@pjendrusik
pjendrusik / gist:7233134
Created October 30, 2013 13:59
recover mysql root password
# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
@pjendrusik
pjendrusik / gist:6b7db53bafc340ea56a8
Created May 20, 2014 08:51
Enable SSH Connection Sharing and Persistence
// add to ~/.ssh/config
ControlMaster auto
ControlPath /tmp/%r@%h:%p
ControlPersist yes
@pjendrusik
pjendrusik / recover all privileges
Created August 26, 2014 14:40
recover all privileges
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
FLUSH PRIVILEGES;
@pjendrusik
pjendrusik / gist:b9bad97a5055ba2446d0
Created September 2, 2014 07:30
encrypt/decrypt text file
# encrypt
openssl rsautl -encrypt -pubin -inkey pawel.jendrusik.id_rsa.pem.pub -ssl -in myMessage.txt -out myEncryptedMessage.txt
# decrypt
openssl rsautl -decrypt -inkey ~/.ssh/id_rsa -in passwords_pawel_jendrusik_encrypted.txt -out li_de_new_pass.txt
@pjendrusik
pjendrusik / gist:bd75f3345391af0d4618
Created September 2, 2014 09:21
#nginx: redirect subdomain to url
server {
server_name blog.example.com;
rewrite ^(.*) http://magazyn.example.com permanent;
}
Compiling TeX:
tex test1.tex : converts a TeX file to DVI (probably you don't need that, if you mean LaTeX)
pdftex test1.tex : converts a TeX file to PDF (probably you don't need that either)
latex test1.tex : converts a LaTeX file to DVI
pdflatex test1.tex : converts a LaTeX file to PDF
Converting:
dvips test1.dvi : converts a DVI file to PostScript
ps2pdf test1.ps : converts a PostScript file to PDF
dvipdfmx xtest1.dvi : converts a DVI file to PDF (similar: dvipdf, dvipdfm)