Skip to content

Instantly share code, notes, and snippets.

View raphaelfruneaux's full-sized avatar

Raphael Fruneaux raphaelfruneaux

View GitHub Profile
@raphaelfruneaux
raphaelfruneaux / gist:2742a530174d458cee3e
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;
@raphaelfruneaux
raphaelfruneaux / WearProtection.js
Last active August 28, 2015 14:50
This code runs beforeSend on $.ajaxSetup (MAGIC) check out REALPYTHON FOR MORE MAGIC
// This function gets cookie with a given name
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
@raphaelfruneaux
raphaelfruneaux / gist:be9fd2051b52cdbffcd6
Created December 26, 2015 04:21
Install Scrapy in a recently created Vagrant VM using the box precise32/precise64
sudo apt-get update
sudo apt-get install -y libffi-dev python-dev python-pip libxml2-dev libxslt-dev
sudo pip install Scrapy
@raphaelfruneaux
raphaelfruneaux / clear.sh
Last active April 5, 2016 17:42 — forked from wellingtonpgp/clear.sh
Shell script básico de limpeza
#!/bin/bash
# limpeza de arquivos inuteis no sistema
# Criado por Wellington P. Gonçalves (Wellington Geek)
# email: [email protected], [email protected]
# Para executar o script basta localizar a pasta e digitar chmod +x clear.sh
echo "Limpando a lixeira"
sudo rm -rf /home/$USER/.local/share/Trash/files/*
echo ""
@raphaelfruneaux
raphaelfruneaux / range.html
Created August 22, 2016 18:58
Angularjs range filter, n for n in [] | range:0:20
<select name="HH" data-ng-model="" style="width:auto;"
data-ng-options="n for n in [] | range:0:20" required>
<option value="">----</option>
</select>
@raphaelfruneaux
raphaelfruneaux / middlewares.py
Created September 21, 2016 02:15 — forked from seagatesoft/middlewares.py
An example of RotateUserAgentMiddleware
from random import choice
from scrapy import signals
from scrapy.exceptions import NotConfigured
class RotateUserAgentMiddleware(object):
"""Rotate user-agent for each request."""
def __init__(self, user_agents):
self.enabled = False
self.user_agents = user_agents
@raphaelfruneaux
raphaelfruneaux / fix-homebrew-npm.md
Created March 7, 2017 01:57 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

@raphaelfruneaux
raphaelfruneaux / settings.py
Created March 8, 2017 18:10 — forked from kogakure/settings.py
Python: Django Templates: settings.py, local_settings.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os.path
import sys
# Basic Settings
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
PROJECT_NAME = os.path.split(PROJECT_ROOT)[-1]
MEDIA_ROOT = '%s/media/' % PROJECT_ROOT
@raphaelfruneaux
raphaelfruneaux / paises-gentilicos-google-maps.json
Created March 28, 2017 13:00 — forked from jonasruth/paises-gentilicos-google-maps.json
JSON com lista de Países em pt-BR e seus respectivos Gentílicos, Siglas e Nome Internacional - Possui todos os países do Google Maps
[ { "gentilico" : "afegãne",
"nome_pais" : "Afeganistão",
"nome_pais_int" : "Afghanistan",
"sigla" : "AF"
},
{ "gentilico" : "sul-africana",
"nome_pais" : "África do Sul",
"nome_pais_int" : "South Africa",
"sigla" : "ZA"
},
@raphaelfruneaux
raphaelfruneaux / nginx.conf
Created March 28, 2017 13:59 — forked from thoop/nginx.conf
Official prerender.io nginx.conf for nginx
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;