Skip to content

Instantly share code, notes, and snippets.

View cnicodeme's full-sized avatar

Cyril Nicodème cnicodeme

View GitHub Profile
@cnicodeme
cnicodeme / aol-reader-ad-remover.js
Last active December 29, 2015 15:48
Remove the ads in the Aol Reader web application :)
// Just copy/paste this script in the developer console
// (or use the bookmarklet in the comments)
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '#reader-ad-container{display: none} #reader-container{margin-right: 0} .feed-header{right: 0}';
document.getElementsByTagName('head')[0].appendChild(style);
@cnicodeme
cnicodeme / update-alternatives-java.sh
Created December 3, 2013 11:11
Simple script that add Java support in update-alternative. Takes the latest folder in /opt/java as the reference.
#!/bin/bash
# First of all, we check if the user is root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
update-alternatives --install /usr/bin/java java /opt/java/$(ls -tr | tail -1)/bin/java 1
update-alternatives --install /usr/bin/javac javac /opt/java/$(ls -tr | tail -1)/bin/javac 1
@cnicodeme
cnicodeme / create-user.sql
Last active April 25, 2024 15:09
Create a new Mysql user with restricted access
# Difference unicode/general : http://stackoverflow.com/a/367725/330867
CREATE DATABASE dbname CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'dbpass';
GRANT USAGE ON * . * TO 'dbuser'@'localhost' IDENTIFIED BY 'dbpass' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT SELECT , INSERT , UPDATE , DELETE , CREATE , DROP , INDEX , ALTER , REFERENCES, LOCK TABLES ON `dbname` . * TO 'dbuser'@'localhost';
FLUSH PRIVILEGES;
# To dump the database with the master relay details:
@cnicodeme
cnicodeme / fedora.sh
Last active August 29, 2015 14:07
Fedora 20 refresh installation
yum -y remove cheese evolution libreoffice-calc libreoffice-core libreoffice-draw libreoffice-graphicfilter libreoffice-impress libreoffice-opensymbol-fonts libreoffice-pdfimport libreoffice-ure libreoffice-writer shotwell empathy
yum -y install --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
yum -y install --nogpgcheck http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
yum -y install --nogpgcheck http://rpms.famillecollet.com/remi-release-20.rpm
printf "[google-chrome]\nname=google-chrome - 64-bit\nbaseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64\nenabled=1\ngpgcheck=1\ngpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub" > /etc/yum.repos.d/google-chrome.repo
@cnicodeme
cnicodeme / twilio_sms.php
Created November 6, 2014 09:46
Send SMS to Twilio without the sdk (simplified version)
/**
* You need to know it's better to use the always up-to-date sdk from Twilio
* This is just a snippet that demonstrate how to send an sms to Twilio using curl.
* It works well though ;)
*/
function twilio($to, $message) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, str_replace('{auth_key}', TWILIO_KEY, 'https://api.twilio.com/2010-04-01/Accounts/{auth_key}/Messages.json'));
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
@cnicodeme
cnicodeme / VN_SEARCH_EMAIL.gs
Last active August 29, 2015 14:17
Function to search email inside a Google Spreadsheet
/**
* Search existing emails based on the full name and the website.
*
* @param {string} token : The API token bought at https://voilanorbert.com
* @param {string} fullname : The name of the person to search
* @param {string} domain : The domain to search against.
*
* @return The list of emails or an error code (starting with "ERR-{code}")
*
* @customfunction
@cnicodeme
cnicodeme / twilio.py
Created June 11, 2015 09:17
Twilio quick snippet in Python
# -*- coding:utf-8 -*-
from flask import current_app
from urllib import urlencode
import httplib2
def twilio(phone, message):
params = {
'From': current_app.config['TWILIO_FROM'],
@cnicodeme
cnicodeme / VN_VERIFY_EMAIL.gs
Last active August 29, 2015 14:25
Function to verify if an email exists inside a Google Spreadsheet
/**
* Verify that the provided email is well recognized by the MX server.
*
* @param {string} token : The API token bought at https://voilanorbert.com
* @param {string} email : The email to verify
*
* @return Boolean as 1/0 if it exists or an error code (starting with "ERR-{code}")
*
* @customfunction
*/
@cnicodeme
cnicodeme / ovh-sys.js
Created October 15, 2015 09:36
Check the availability of a specific server at OVH, and once it's available, alert the user (via "alert" to freeze the browser) and refresh the page
// https://eu.soyoustart.com/fr/commande/soYouStart.xml?reference=143sys10&quantity=1
function find(reference) {
jQuery.ajax({
'url': 'https://ws.ovh.com/dedicated/r2/ws.dispatcher/getAvailability2'
}).done(function (data) {
for (var i = 0; i < data.answer.availability.length; i++) {
if (data.answer.availability[i].reference !== reference) continue;
for (var y=0; y < data.answer.availability[i].zones.length; y++) {
@cnicodeme
cnicodeme / LinkExtractor.php
Created June 24, 2016 14:43
Crawler written in PHP
<?php
namespace Crawler\Extractors;
class LinkExtractor {
private static $excludes = array(
'.png', '.gif', '.jpg', '.jpeg', '.svg', '.mp3', '.mp4', '.avi', '.mpeg', '.ps', '.swf', '.webm', '.ogg', '.pdf',
'.3gp', '.apk', '.bmp', '.flac', '.gz', '.gzip', '.jpe', '.kml', '.kmz', '.m4a', '.mov', '.mpg', '.odp', '.oga', '.ogv', '.pps', '.pptx', '.qt', '.tar', '.tif', '.wav', '.wmv', '.zip',
// Removed '.js', '.coffee', '.css', '.less', '.csv', '.xsl', '.xsd', '.xml', '.html', '.html', '.php', '.txt', '.atom', '.rss'