Skip to content

Instantly share code, notes, and snippets.

@brahimmachkouri
brahimmachkouri / default
Last active November 30, 2017 17:31
nginx userdir + php-fpm
server {
listen 80;
server_name localhost;
# ... other default site stuff, document root, etc. ...
location ~ ^/~(?<userdir_user>.+?)(?<userdir_uri>/.*)?$ {
alias /home/chroot/home/$userdir_user/public_html$userdir_uri;
index index.html index.htm index.php;
autoindex on;
<script type="text/javascript">
var myJson = new Array();
$(document).ready(function() {
// Pas en asynchrone pour le dev (debug)
/*$.ajaxSetup({
async: false
});
*/
@brahimmachkouri
brahimmachkouri / form.php
Last active August 29, 2015 14:06
Simple form example with Silex
$app->register(new Silex\Provider\TranslationServiceProvider(), array(
'locale_fallbacks' => array('en'),
));
$app->register(new Silex\Provider\FormServiceProvider());
$form = $app['form.factory']->createBuilder('form')
->add('name')
->add('email')
->add('gender', 'choice', array(
'choices' => array(1 => 'male', 2 => 'female'),
@brahimmachkouri
brahimmachkouri / interfaces
Created November 11, 2014 14:31
raspbian : wifi settings
#paste these lines in /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
wpa-ssid your-ssid-here
@brahimmachkouri
brahimmachkouri / interfaces
Created November 11, 2014 16:44
muliple ssids
# put the following content in /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
@brahimmachkouri
brahimmachkouri / webmin.py
Last active June 2, 2016 08:11
Webmin install in Debian : wget --no-check-certificate http://j.mp/webmindebianinstaller
#!/usr/bin/python
# Brahim MACHKOURI
import subprocess
import re
import urllib2
# recupere la page web de webmin dediee a debian
response = urllib2.urlopen('http://www.webmin.com/deb.html')
html = response.read()
@brahimmachkouri
brahimmachkouri / keyservers.sh
Created December 2, 2014 17:22
Adjust keyservers settings in puphpet file configurations
#!/bin/bash
server1="keyserver.ubuntu.com"
server2="keyserver.debian.com"
server3="keys.gnupg.net"
function replacehkp {
sedserver=`echo $1 | awk -F '.' '{ print $1 "\\\." $2 "\\\." $3 }'`
grep -ri "'$server" * | awk -F ':' '{ print $1 }' | xargs sed -i "s/'$sedserver/'hkp:\/\/$sedserver:80/g"
}
@brahimmachkouri
brahimmachkouri / .bashps1
Created January 10, 2015 14:21
Bash Prompt
export PS1="\[\e[00;33m\]\A\[\e[0m\]\[\e[00;37m\] \[\e[0m\]\[\e[00;34m\]\u\[\e[0m\]\[\e[00;37m\] [\H] \[\e[0m\]\[\e[00;31m\]\w\[\e[0m\]\[\e[00;37m\]\n\[\e[0m\]\[\e[00;32m\]\\$\[\e[0m\]\[\e[00;37m\] \[\e[0m\]"
#!/usr/bin/env python
# encoding: utf-8
import tweepy #https://github.com/tweepy/tweepy
import csv
#Twitter API credentials
consumer_key = ""
consumer_secret = ""
access_key = ""
@brahimmachkouri
brahimmachkouri / cdp.py
Created November 7, 2015 03:35 — forked from trhura/cdp.py
A small python script for cdp device discovery
#! /usr/bin/env python
# A small script for cdp devices discovery
import sys
import pcapy
import socket
from dpkt import ethernet
from dpkt import cdp
from docopt import docopt