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:6aaba9ebe5d070d5da4a
Last active August 29, 2015 14:03
Elance Auth fail OpenID
object(Auth_OpenID_FailureResponse)#95 (6) {
["status"]=> string(7) "failure"
["endpoint"]=> NULL
["identity_url"]=> NULL
["message"]=> string(34) "Server denied check_authentication"
["contact"]=> NULL
["reference"]=> NULL
}
NOT authenticated
@rolandinsh
rolandinsh / gist:4b6cbfcb817de1dcc78c
Last active August 29, 2015 14:13
block visitors referred from semalt.com and buttons-for-website.com
# block visitors referred from semalt.com and buttons-for-website.com
RewriteEngine on
RewriteCond %{HTTP_REFERER} semalt\.com [NC]
RewriteRule .* - [F]
RewriteCond %{HTTP_REFERER} buttons\-for\-website\.com
RewriteRule ^.* - [F,L]
RewriteCond %{HTTP_REFERER} buttons\-for\-your\-website\.com
RewriteRule ^.* - [F,L]
@rolandinsh
rolandinsh / gist:f60d36895cb947022f43
Last active August 29, 2015 14:16
recursively give directories/files read&execute privileges
To recursively give directories read&execute privileges:
find /path/to/base/dir -type d -exec chmod 755 {} +
To recursively give files read privileges:
find /path/to/base/dir -type f -exec chmod 644 {} +
Or, if there are many objects to process:
@rolandinsh
rolandinsh / gist:2cd41b671f1ac845f309
Last active August 29, 2015 14:16
Matching an HTML (or XML) tag with a certain attribute value (e.g. class or tag) by Mike Malone (https://twitter.com/mjmalone)
function get_tag( $attr, $value, $xml, $tag=null ) {
if( is_null($tag) )
$tag = '\\w+';
else
$tag = preg_quote($tag);
$attr = preg_quote($attr);
$value = preg_quote($value);
$tag_regex = "/<(".$tag.")[^>]*$attr\\s*=\\s*".
@rolandinsh
rolandinsh / gist:52197d4d4feb37dffe9b
Last active August 29, 2015 14:19
block spam referers in NGINX. Can be used as global block for all sites; (used on my production server(s))
# Block semalt.com buttons-for-website.com buttons-for-your-website.com best-seo-offer.com 100dollars-seo.com semaltmedia.com as referral spam
# (c) 2015 Rolands Umbrovskis, http://umbrovskis.com
# if code above do not work:
if ($http_referer ~ "(semaltmedia\.com|100dollars-seo\.com|semalt\.com|buttons-for-website.com|buttons-for-your-website\.com|best-seo-offer\.com)") {
set $prohibited "1";
}
if ($prohibited) {
return 403;
@rolandinsh
rolandinsh / gist:93cb9a5f08f52d7065b4
Created June 20, 2015 01:07
spammers in .sh file (by @lolwhoami)
#!/bin/sh
# Author: https://github.com/lolwhoami/referrer-spam-blacklist/commit/b25bb159d95c0fc82ea731750f0461bd85b72a91
# use this inside 'server { ... }'
#
# include spammers.nginx.conf;
# if($bad_referer) {
# return 444;
# }
conf='./spammers.nginx.conf'
@rolandinsh
rolandinsh / google-plus-feed.php
Created June 25, 2012 13:28 — forked from ocean90/google-plus-feed.php
WordPress Page Template to build a feed of your Google+ stream
<?php
/**
* Template Name: Google+ Feed
*/
/**
* A WordPress page template for a Google+ feed.
*
* @author Dominik Schilling
@rolandinsh
rolandinsh / fbcbfwss.php
Created June 30, 2012 02:46 — forked from ocean90/fbcbfwss.php
Filename-based cache busting for WordPress scripts/styles.
<?php
/**
* Filename-based cache busting for WordPress scripts/styles.
*
* Extend your .htaccess file with these lines:
*
* <IfModule mod_rewrite.c>
* RewriteEngine On
* RewriteBase /
*
@rolandinsh
rolandinsh / smc_is_login_page
Created July 11, 2012 09:09
WordPress is login or register page
<?php
/**
* Is login or register page
* @author umbrovskis
* @authorlink http://umbrovskis.com
*/
function smc_is_login_page() {
return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
}
// hope some day WordPress will make is_login_page() or is_register_page() or similar
@rolandinsh
rolandinsh / endpoints.php
Created July 12, 2012 06:52 — forked from joncave/endpoints.php
WP_Rewrite endpoints demo
<?php
/*
Plugin Name: WP_Rewrite endpoints demo
Description: A plugin giving example usage of the WP_Rewrite endpoint API
Plugin URI: http://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/
Author: Jon Cave
Author URI: http://joncave.co.uk/
*/
function makeplugins_endpoints_add_endpoint() {