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 / delay.js
Created November 11, 2016 18:41
A Promise-based function that behaves as a delay function.
'use strict'
const delay = (ms) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve({
ms: ms,
msg: 'finished timeout'
})
}, ms)
'use strict'
const sleep = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms))
}
module.exports = sleep
@raphaelfruneaux
raphaelfruneaux / uninstall-docker.sh
Created December 1, 2016 00:04
Uninstall docker
#!/bin/bash
# Uninstall Script
if [ "${USER}" != "root" ]; then
echo "$0 must be run as root!"
exit 2
fi
while true; do
@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.