Skip to content

Instantly share code, notes, and snippets.

View skorotkiewicz's full-sized avatar
💻
Programming

Sebastian Korotkiewicz skorotkiewicz

💻
Programming
View GitHub Profile
@skorotkiewicz
skorotkiewicz / FriendlyURL.php
Created December 8, 2016 15:15
Friendly URL
<?php
function url_slug($str, $options = array()) {
// Make sure string is in UTF-8 and strip invalid UTF-8 characters
$str = mb_convert_encoding((string)$str, 'UTF-8', mb_list_encodings());
$defaults = array(
'delimiter' => '-',
'limit' => null,
'lowercase' => false,
'replacements' => array(),
@skorotkiewicz
skorotkiewicz / generator-htpasswd.php
Created December 8, 2016 15:16
.htpasswd generator webpage in php
Use this form to generate your encrypted htaccess password.
<form method="post" action="">
<p><input type="text" name="login" placeholder="Login" /></p>
<p><input type="text" name="password" placeholder="Password" /></p>
<p><input type="submit" value="Get" /></p>
</form>
<?PHP
// demo: http://tmp.itunix.eu/aLog.php
@skorotkiewicz
skorotkiewicz / Parallax.js
Created December 8, 2016 15:17
Copy “Make item scroll slower than window (Parallax)
$(window).scroll(function () {
$('#object').css({
'bottom' : -($(this).scrollTop()/10)+"px" // increase # to make even slower
});
});
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .----- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,we$
# | | | | |
# * * * * * command to be executed
# m h dom mon dow command
10 4 * * * vnstati -vs -i venet0 -o /var/vnstati/`date +"%F"`.png
10 4 * * * ln -s /var/vnstati/`date +"%F"`.png /var/vnstati/latest.png
@skorotkiewicz
skorotkiewicz / gist:4a59967e5d2eb8ba8ed45e0df52c5077
Created December 8, 2016 15:18
SSH Tunel to your Proxy Webbrowser
$ ssh -4 -N -D 1025 [email protected]
1025 is a proxy port (localhost:1025)
it work with socks v5!
// http://www.sebastian.korotkiewicz.eu/2013/03/30/ssh-tunel-to-your-proxy-webbrowser/
Copy the file "foobar.txt" from a remote host to the local host
$ scp [email protected]:foobar.txt /some/local/directory
Copy the file "foobar.txt" from the local host to a remote host
$ scp foobar.txt [email protected]:/some/remote/directory
Copy the directory "foo" from the local host to a remote host's directory "bar"
$ scp -r foo [email protected]:/some/remote/directory/bar
Copy the file "foobar.txt" from remote host "rh1.edu" to remote host "rh2.edu"
@skorotkiewicz
skorotkiewicz / gist:5bb7c5796062622166ccd12f20ea5fd1
Created December 8, 2016 15:19
Block all SSH Access except one IP
#create access for specific IP:
iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED --source x.x.x.x -p tcp --dport 22 -j ACCEPT
#block all others
iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED -p tcp --dport 22 -j DROP
@skorotkiewicz
skorotkiewicz / askfmbot.php
Created December 8, 2016 15:20
Ask.fm ask question bot
<?PHP
/*
* Ask.fm ask question bot, ver 0.1
* Bot can automatically login to your account and ask questions
* required: Questions e.g. from mysql and nicks to ask
* */
define('SETUSERAGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)');
@skorotkiewicz
skorotkiewicz / CtrlS.js
Created December 8, 2016 15:21
jQuery Ctrl + S for save
// jQuery Ctrl + S for save
$(document).keydown(function(e) {
if(e.ctrlKey && e.altKey && e.which === 83) {
save();
return false;
}
});
@skorotkiewicz
skorotkiewicz / kernel.php
Created December 8, 2016 15:22
Notification of the new linux kernel on your Android in PHP
<?PHP
/*
how to use? very simple!
$ crontab -e
add line
* 7 * * * php /home/mod/notification.php>/dev/null 2>&1
and save
now script will be run from cron every day at 7:00 am and notify you of a new kernel!
my blog: http://www.sebastian.korotkiewicz.eu/2013/02/02/notification-of-the-new-linux-kernel-on-your-android-in-php/