Skip to content

Instantly share code, notes, and snippets.

View arth2o's full-sized avatar

ArtH2O arth2o

View GitHub Profile
@arth2o
arth2o / Load XML use PHP yield
Created November 20, 2015 11:37
Yield PHP load RSS (XML) data
<?php
$rssUrl = "http://arth2o.com/rss.xml";
/**
* Load xml use PHP yield Generator
**/
class GetRss
{
private $url;
@arth2o
arth2o / Phantomjs capture website screen
Created December 5, 2015 06:39
With PhantomJs you can capture website and save by png. e.g.: call: phantomjs capture.js url width height outputFileName
#! /usr/bin/phantomjs
var page = require('webpage').create();
var system = require('system');
var args = system.args;
if(args[1]==''){
console.log('Url parameter is missign!')
console.log('Important to call this file for four parameters.');
console.log('phantomjs url w h output file name');
@arth2o
arth2o / casper.userAgent
Created December 5, 2015 20:30
casper.userAgent
var casper = require('casper').create();
casper.userAgent('AdsBot-Google-Mobile (+http://www.google.com/mobile/adsbot.html) Mozilla (iPhone; U; CPU iPhone OS 3 0 like Mac OS X) AppleWebKit (KHTML, like Gecko) Mobile Safari');
casper.start("http://glimmering.eu/", function() {
this.echo(this.getTitle());
});
casper.run();
@arth2o
arth2o / Apache rewrite rule to redirect public per index.php
Created January 13, 2016 10:24
htaccess apache redirect public per index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /public/index.php [NC,L]
@arth2o
arth2o / chosen autocomplate from ajax source
Created February 17, 2016 17:01
That was the last time, when I use this plugin. I have to change to select2., javascript, chosen, ajax
<select class="chosen-select" id="hello_chosen">
<option name=""></option>
</select>
$(function(){
$("#hello_chosen").chosen({
width:"400px",
allow_single_deselect: true
@arth2o
arth2o / NEF to JPG
Created January 29, 2017 06:42
Batch convert raw NEF files to JPGs with exiftool from Linux command-line. 1, Exiftool have to be installed. Put this pieces of code to a file for example neftojpg.sh. chmod +x neftojppg.sh. Run: ./neftojpg.sh /directory/where/pictures/are/.
#!/bin/bash
DIR="$@"
for f in $DIR*.NEF
do
name=`echo "$f" | sed -e "s/.NEF$//g"`
exiftool -b -JpgFromRaw "$f" > "${name}.jpg"
done
@arth2o
arth2o / convert all mp3 file in a folder to mp4 with a cover image
Created March 24, 2017 10:37
BASH - ffmpeg mp3 + cover image to mp4
#! /bin/bash
i=0;
for file in *.mp3;
do
i=$((i+1));
ffmpeg -loop 1 -i cover.jpg -i $file -c:a copy -c:v libx264 -shortest $file.mp4
done
@arth2o
arth2o / synchronize audio and text
Created March 24, 2017 12:53
automagically synchronize audio and text with aeneas.
#! /bin/bash
for file in *.mp3;
do
# ext=${file##*.}
# fname=`basename $file .$ext`
# filename without extension
base=${file%.*}
# json
python -m aeneas.tools.execute_task ${base}.mp3 ${base}.txt "task_language=eng|os_task_file_format=json|is_text_type=plain" ${base}.json
@arth2o
arth2o / mod_pagespeed .htaccess
Created May 6, 2017 06:59 — forked from solancer/mod_pagespeed .htaccess
mod_pagespeed .htaccess configuration
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
*Step 1, Get the confirmation code:*
wget --save-cookies cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILE_ID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/Code: \1\n/p'
*Step 2, Get the file:*
wget --load-cookies cookies.txt 'https://docs.google.com/uc?export=download&confirm=CODE_HERE&id=FILE_ID'
----