Skip to content

Instantly share code, notes, and snippets.

View jroquejr's full-sized avatar

Roque Junior jroquejr

View GitHub Profile
@jroquejr
jroquejr / gist:a57da3114ae8f254a838
Last active August 29, 2015 14:25 — forked from thomasgriffin/gist:4733283
Map subdomains to URLs in nginx with WordPress.
server {
listen 80;
listen 443 ssl;
server_name ~^(?<user>[a-zA-Z0-9-]+)\.example\.com$;
location / {
resolver 8.8.8.8;
rewrite ^([^.]*[^/])$ $1/ permanent;
proxy_pass_header Set-Cookie;
proxy_pass $scheme://example.com/user/$user$request_uri;
@jroquejr
jroquejr / force_in_footer.php
Created May 29, 2015 18:30
Force scripts to footer
from scrapy.spider import BaseSpider
# Requires this patch:
# https://github.com/joehillen/scrapy/commit/6301adcfe9933b91b3918a93387e669165a215c9
from scrapy.selector import PyQuerySelector
class DmozSpiderPyQuery(BaseSpider):
name = "pyquery"
allowed_domains = ["dmoz.org"]
start_urls = [
<?php
/*
Plugin Name: Remote Login
Description: Log into the site with creds that work on remote site (as defined in plugin). The remote site must have XML-RPC enabled.
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
THIS IS NOT COMPLETE - DO NOT USE IN PRODUCTION
The remote site (defined below in $server) is the "master" site.
import simplejson
import json
def put(data, filename):
try:
jsondata = simplejson.dumps(data, indent=4, skipkeys=True, sort_keys=True)
fd = open(filename, 'w')
fd.write(jsondata)
fd.close()
except:
@jroquejr
jroquejr / gist:9875621
Last active April 9, 2019 02:12
WordPress - Remover acentos dos nomes de imagens no upload
<?php
// remove_accents: https://codex.wordpress.org/Function_Reference/remove_accents
add_filter('sanitize_file_name', 'sa_sanitize_spanish_chars', 10);
function sa_sanitize_spanish_chars ($filename) {
return remove_accents( $filename );
}
@jroquejr
jroquejr / lock.css
Created March 28, 2014 19:49 — forked from visnup/lock.css
/* if portrait mode is detected, rotate the entire site -90 degrees to hint rotating to landscape */
@media (orientation: portrait) {
body {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
transform: rotate(-90deg);
}
}
@jroquejr
jroquejr / limita_caracteres.php
Created January 30, 2014 13:41
Limitador de caracteres para o editor do WordPress
<?php add_action( 'admin_init', function(){ add_action( 'dbx_post_sidebar', function(){ ?>
<style type="text/css">
.char-limit.over-limit{
color: red;
}
.char-limit.over-limit:after{
content: ' LIMITE DE CARACTERS ATINGIDO. POR FAVOR REVISE O SEU TEXTO';
color: red;
@jroquejr
jroquejr / Varnish WordPress multidevice
Created October 3, 2013 17:45
Varnish VCL to Wordpress multidevice site with allowed purge from localhost
backend default {
.host = "127.0.0.1";
.port = "81";
}
acl purge {
"localhost";
}
# Rutine to try and identify device
@jroquejr
jroquejr / seo__url.xml
Created August 31, 2013 13:13
Opencart Seo Url
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>SEO - Custom url - adaptado de http://www.davidchc.com.br/tutoriais/opencart-tutoriais/transformando-as-outras-url-do-opencart-em-amigaveis/</id>
<version>1.0</version>
<vqmver>2.2.1</vqmver>
<author>jroqueweb</author>
<file name="catalog/controller/common/seo_url.php">
<operation>
<search position="before" index="1"><![CDATA[public function index() {]]></search>
<add><![CDATA[