Skip to content

Instantly share code, notes, and snippets.

View nemesifier's full-sized avatar
🎯
Focusing

Federico Capoano nemesifier

🎯
Focusing
View GitHub Profile
@nemesifier
nemesifier / freeradius-rest-example.conf
Last active July 11, 2017 15:17
sample freeradius configuration showing how to delegate authorization and authentication to the rml_rest module
# /etc/freeradius/sites-enabled/default
# ... other sections omitted for brevity ...
authorize {
# enable rml_rest module
if (&User-Password) {
update control {
Auth-Type := 'rest'
}
}
@nemesifier
nemesifier / admin.py
Created April 28, 2017 09:58
possible bug in django admin extra_context
from django.contrib import admin
from .models import Config
class ConfigAdmin(admin.ModelAdmin):
def add_view(self, request, form_url='', extra_context={}):
if 'config' in self.model.__name__.lower():
extra_context.update({'CONFIG_SPECIFIC': True})
return super(ParentAdmin, self).add_view(request, form_url, extra_context)
@nemesifier
nemesifier / luci.lua
Created October 26, 2016 13:20
OpenWRT Luci notes
-- print table structure
require('luci.util')
require('luci.jsonc')
t = {'test'}
print(luci.util.dumptable(t))
print(luci.jsonc.stringify(t))
-- disable luci caching to make it easy to do live editing on a test router
@nemesifier
nemesifier / push-olsr-data.sh
Last active March 15, 2016 09:27
Push OLSR data to django-netjsongraph
#!/bin/sh
BASE_URL="http://ninux-graph.netjson.org"
# put your network topology id here
UUID="<uuid>"
# put your network topology key here
KEY="<key>"
# host where OLSR is running
OLSR_HOST="127.0.0.1"
# port on which OLSR is listening, change it according to your configuration
@nemesifier
nemesifier / olsrd2.networkgraph.json
Last active February 23, 2016 12:24
Example olsrd2 netjsoninfo specific NetworkGraph
{
"type": "NetworkGraph",
"protocol": "olsrv2",
"version": "0.1",
"revision": "e38e0a8",
"router_id": "10.27.253.2",
"metric": "ff_dat_metric",
"topology_id": "0",
"label": "ipv4",
"nodes": [
@nemesifier
nemesifier / openwisp-config-compilation.sh
Created February 21, 2016 13:20
openwisp-config jenkins script
BASE_DIR="/var/www/downloads.openwisp.org/$JOB_NAME"
REVISION=$(git describe --tags --always)
ARCHS="ar71xx ramips"
cd openwrt && git pull || (git clone git://git.openwrt.org/openwrt.git --depth=1 && cd openwrt)
cp feeds.conf.default feeds.conf
echo "src-link openwisp $WORKSPACE" >> feeds.conf
./scripts/feeds update packages luci targets openwisp
./scripts/feeds install packages luci targets openwisp
@nemesifier
nemesifier / ninux_whois.py
Last active December 29, 2015 16:18
Automatic Ninux WHOIS resolution signal for django-netjsongraph https://github.com/interop-dev/django-netjsongraph
import socket
from django.db.models.signals import pre_save
from django.dispatch import receiver
from django_netjsongraph.models import Node
def whois(query, hostname='chi.ninux.org'):
"""
# /etc/config/dhcp
# example config of how to use odchp instead of dnsmasq for ipv4
config odhcpd 'odhcpd'
# this tells openwrt to use odchpd instead of dnsmasq
option maindhcp '1'
# ensure the directory exists or the lease
# file won't be written and will fail silently
option leasefile '/tmp/odhcp-leases'
option leasetrigger '/usr/sbin/odhcpd-update'
@nemesifier
nemesifier / rome.olsr.september2015.netjson
Created September 27, 2015 21:50
Rome OLSRv1 NetJSON generated with netdiff 0.4.5
{
"type": "NetworkGraph",
"protocol": "OLSR",
"version": "0.8",
"revision": null,
"metric": "ETX",
"nodes": [
{
"id": "172.16.172.7"
},
@nemesifier
nemesifier / git-filter-reset-author.sh
Created August 25, 2015 09:05
Git: reset author to several commits
git filter-branch --env-filter 'if [ "$GIT_AUTHOR_EMAIL" = "[email protected]" ]; then
[email protected];
GIT_AUTHOR_NAME="Correct Name";
GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL;
GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME; fi' -- <COMMIT>..<BRANCH>