Skip to content

Instantly share code, notes, and snippets.

View jinie's full-sized avatar

Jimmy Selgen Nielsen jinie

View GitHub Profile
@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):
"""
@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"""
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
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
#!/usr/bin/env python3
import json
import sys
import datetime
import os.path
with open(sys.argv[1]) as f:
data = json.load(f)
#!/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}
@jinie
jinie / hue_automation.py
Created November 13, 2015 13:05
Automating Hue lights at dusk/dawn, or scheduled
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import time
import astral
import logging
import datetime
from dateutil import parser
from threading import Thread
@jinie
jinie / .vimrc
Created October 28, 2015 13:28
vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Let Vundle manage Vundle
Bundle 'gmarik/vundle'
" My Bundles