Skip to content

Instantly share code, notes, and snippets.

View mikaelz's full-sized avatar

Michal Zuber mikaelz

View GitHub Profile
@mikaelz
mikaelz / notify.sh
Created February 11, 2014 05:48 — forked from jehiah/notify.sh
#!/bin/bash
#
# *************************************************
# chkconfig: 2345 99 99
# description: notify email address on system boot.
# *************************************************
# Installing:
# 1) save as /etc/rc.d/init.d/notify
# 2) set the desired email address in "MAILADD" variable
# 3) chmod a+w /etc/rc.d/init.d/notify
@mikaelz
mikaelz / smtp-telnet.sh
Last active August 29, 2015 13:57
Test SMTP server
$ telnet mail2.hostmaster.sk 25
$ openssl s_client -crlf -connect mail2.hostmaster.sk:465
@mikaelz
mikaelz / mirror.sh
Created March 18, 2014 18:48
mirror web site
#!/bin/bash
wget -e robots=off -np -m $1
@mikaelz
mikaelz / delete-temp-files.php
Created May 7, 2015 15:41
Remove expired, outdated files by checking inode change time https://php.net/manual/en/directoryiterator.getctime.php
if (is_dir(TEMP_PATH)) {
foreach (new DirectoryIterator(TEMP_PATH) as $fileInfo) {
if ($fileInfo->isDot()) {
continue;
}
if (time() - $fileInfo->getCTime() >= HOUR_IN_SECONDS) {
unlink($fileInfo->getRealPath());
}
}
}
#!/bin/bash
export DISPLAY=":0.0"
dbus-send --session --type=method_call --print-reply --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
@mikaelz
mikaelz / spotifynext.sh
Last active August 29, 2015 14:21
Control Spotify Linux from command line
#!/bin/bash
export DISPLAY=":0.0"
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
@mikaelz
mikaelz / invite_all.js
Created May 13, 2015 15:43
Send invite to Like Facebook page to all friends. Click link 'Invite friends to like this Page' then scroll to bottom to list all friends. Open console and insert the following javascript code and hit enter.
var nodes = document.querySelectorAll('._1sm');
for (var i=0; i<nodes.length; i++)
nodes[i].click();
@mikaelz
mikaelz / parse_pohoda_categories_xml.php
Last active August 29, 2015 14:24
Parse Pohoda categories XML. The XML contains nested namespaces. Reused code from https://webtrh.cz/120959-parsovani-vnorenych-zaznamu-xml?p=616757#post616757 Alternative parsing can be found at https://gist.github.com/lynt-smitka/6a50bdf97bb32a64e34b
$xml = file_get_contents($_FILES['xml']['tmp_name']);
$xml = simplexml_load_string($xml);
$ns = $xml->getNameSpaces(true);
foreach ($xml->xpath('//lst:categoryDetail') as $categories) {
$ctg = $categories->children($ns['ctg']);
foreach ($ctg->category as $category) {
insert_page($category->id, $category->name, 0);
if (isset($category->subCategories)) {
insertSubcategory($category);
@mikaelz
mikaelz / get_attachments_for_parent.php
Created September 5, 2015 11:36
WordPress - get all post attachments excluding (without) the featured image. Codex page https://codex.wordpress.org/Template_Tags/get_posts
$attachments = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_status' => 'any',
'post_parent' => get_the_ID(),
'exclude' => get_post_thumbnail_id(),
) );
@mikaelz
mikaelz / javascript_loader.js
Last active September 27, 2015 15:19 — forked from hagenburger/javascript_loader.js
Dynamically load JavaScript files with callback when finished
// Example:
Loader.load("/script/main.js");
Loader.load(base_url + '/include/fancybox2/jquery.fancybox.pack.js', function() {
$('.fancybox').fancybox();
});
var Loader = {
load: function(src, callback) {
var script = document.createElement('script'),