Skip to content

Instantly share code, notes, and snippets.

View jinie's full-sized avatar

Jimmy Selgen Nielsen jinie

View GitHub Profile
@jinie
jinie / .vimrc
Created August 15, 2013 18:54
.vimrc
set nocompatible " be iMproved
filetype on "Avoid errors on close
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Bundles {{{-
" let Vundle manage Vundle
" required!
@jinie
jinie / gist:712d397cfa37bcb836b5
Created July 17, 2015 12:12
EdgeOS GeoIP blocking
#!/usr/bin/env python
import os
import urllib2
countries={'DK':'denmark'}
os.system("/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper begin")
for country in countries.keys():
@jinie
jinie / gist:7cbc7035508d32f00b52
Last active October 8, 2022 15:29
Pushover.net notifications with MQTT
#!/usr/bin/env python3
import paho.mqtt.client as paho
import http.client, urllib
import argparse
import logging
import json
import sys
def parse_message(self, message):
@jinie
jinie / read.py
Created July 5, 2011 18:25
Read binary file in python and print hex output
#!/usr/bin/python
import sys,getopt
filename = None
blocksize = 1024
opts,args = getopt.getopt(sys.argv[1:],'f:b:')
for o,a in opts:
if o == '-f':
@jinie
jinie / ghost2hugo
Created September 20, 2017 08:56
Convert a Ghost v1.x JSON export file to Hugo posts.
# coding: utf-8
import json
import re
import argparse
import sys
import os
def read_file(filename):
with open(filename, 'rt') as f:
@jinie
jinie / sa2pyrrd.py
Created August 14, 2017 09:16
RRD Graph from sar data.
""" import needed classes from rrd libraries"""
from pyrrd.rrd import RRD, RRA, DS
from pyrrd.graph import DEF, CDEF, VDEF
from pyrrd.graph import LINE, AREA, GPRINT
from pyrrd.graph import ColorAttributes, Graph
""" import subprocess to launch external commands like sar"""
import subprocess
""" import os.path to test if files exist"""
import os.path
""" import sys to handle error exits"""
@jinie
jinie / archive_lj.py
Created August 8, 2019 10:09
Script to archive all electronic issues of Linux Journal
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import requests
import re
account_no = '000000' #LJ Account number, zero prefixed
baseurl = 'https://secure2.linuxjournal.com'
def get_filename_from_cd(cd):
"""
#!/usr/bin/env python
import os
import logging
import hashlib
def prune(dic):
return {key:value for key, value in dic.iteritems() if len(value) > 1}
import twitter
api = twitter.Api(consumer_key=consumer_key,
consumer_secret=consumer_secret,
access_token_key=access_token,
access_token_secret=access_secret)
u1 = api.GetFollowerIDs(screen_name='foosel')
u2=api.GetFollowerIDs(screen_name='OctoPrint3D')
print("@foosel follower count : {0}".format(len(u1)))
@jinie
jinie / gist:285100f999d26498e434079a2a7b2466
Created March 17, 2017 12:00
octoprint clean upgrade
Updating, please wait.
+++++++++++++++++++++++++++++++
Now updating OctoPrint to 1.3.2
+++++++++++++++++++++++++++++++
/home/pi/oprint/bin/python "/home/pi/oprint/lib/python2.7/site-packages/OctoPrint-1.3.1-py2.7.egg/octoprint/plugins/softwareupdate/scripts/update-octoprint.py" --branch= --force=false "/home/pi/OctoPrint" 1.3.2
'build/scripts-2.7' does not exist -- can't clean it
Python executable: '/home/pi/oprint/bin/python'
>>> Running: git diff --shortstat
> git diff --shortstat