Skip to content

Instantly share code, notes, and snippets.

Avatar
🏖️

Romain Norberg romainnorberg

🏖️
View GitHub Profile
@romainnorberg
romainnorberg / ClosureExtension.php
Created Oct 19, 2020
Symfony Twig Closure Extension
View ClosureExtension.php
<?php
declare(strict_types=1);
namespace AppBundle\Extension;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class ClosureExtension extends AbstractExtension
{
@romainnorberg
romainnorberg / python_mysql_avoid_injection.py
Last active Jul 14, 2020
(Python) Avoid SQL injection when using MySQLCursor.execute()
View python_mysql_avoid_injection.py
import mysql.connector as mdb
con = mdb.connect(
host='127.0.0.1',
port=3306,
user='root',
passwd='rootroot',
db='db', charset='utf8'
)
View tinkerwell-mailer
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
use Symfony\Component\Mime\Email;
// not work
/*
$mailer = new Mailer(
Transport::fromDsn(
View mongo-queries.md

count & sort by subdocuments

db.Visitor.aggregate([
    {
        $project: {
            "n": { $size: "$history" }
        }
    }
    ,
@romainnorberg
romainnorberg / pre-request-script
Last active Sep 4, 2019
Work with OVH-Api using Postman Pre-request scripts (Blog post: https://blog.romainnorberg.be/post/work-with-ovh-api-using-postman)
View pre-request-script
pm.sendRequest({
url: "https://api.ovh.com/1.0/auth/time",
method: "GET",
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
body: {}
},
function (err, res) {
View regex-vs-array.php
<?php
$excludeBotsRegex = '/(googlebot|Googlebot-Mobile|Googlebot-Image|Google favicon|Mediapartners-Google|bingbot|slurp|java|wget|curl|Commons-HttpClient|Python-urllib|libwww|httpunit|nutch|phpcrawl|msnbot|jyxobot|FAST-WebCrawler|FAST Enterprise Crawler|biglotron|teoma|convera|seekbot|gigablast|exabot|ngbot|ia_archiver|GingerCrawler|webmon |httrack|webcrawler|grub.org|UsineNouvelleCrawler|antibot|netresearchserver|speedy|fluffy|bibnum.bnf|findlink|msrbot|panscient|yacybot|AISearchBot|IOI|ips-agent|tagoobot|MJ12bot|dotbot|woriobot|yanga|buzzbot|mlbot|yandexbot|purebot|Linguee Bot|Voyager|CyberPatrol|voilabot|baiduspider|citeseerxbot|spbot|twengabot|postrank|turnitinbot|scribdbot|page2rss|sitebot|linkdex|Adidxbot|blekkobot|ezooms|dotbot|Mail.RU_Bot|discobot|heritrix|findthatfile|europarchive.org|NerdByNature.Bot|sistrix crawler|ahrefsbot|Aboundex|domaincrawler|wbsearchbot|summify|ccbot|edisterbot|seznambot|ec2linkfinder|gslfbot|aihitbot|intelium_bot|facebookexternalhit|yeti|RetrevoPageAnalyzer|lb-spider|sogo
@romainnorberg
romainnorberg / multiple_ssh_setting.md
Created Mar 29, 2018 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@romainnorberg
romainnorberg / vim-heroku.sh
Created Mar 26, 2018 — forked from dvdbng/vim-heroku.sh
Run vim in heroku updated 2017
View vim-heroku.sh
mkdir ~/vim
cd ~/vim
# Staically linked vim version compiled from https://github.com/ericpruitt/static-vim
# Compiled on Jul 20 2017
curl 'https://s3.amazonaws.com/bengoa/vim-static.tar.gz' | tar -xz
export VIMRUNTIME="$HOME/vim/runtime"
export PATH="$HOME/vim:$PATH"
cd -
@romainnorberg
romainnorberg / Command lines
Created Jan 8, 2018
Generate a multi domains certificate using config files
View Command lines
Steps (en ligne de commande - macosx):
- `cd Desktop/`
- `openssl genrsa -out mmw.key 2048`
- `openssl req -new -out server.csr -key server.key -config openssl.cnf`
- `openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server_autosign_test.crt -extensions v3_req -extfile openssl.cnf` _(autosigné, afin de vérifier la génération)_
You can’t perform that action at this time.