Skip to content

Instantly share code, notes, and snippets.

Avatar

Jimmy Selgen Nielsen jinie

View GitHub Profile
@jinie
jinie / archive_lj.py
Created Aug 8, 2019
Script to archive all electronic issues of Linux Journal
View archive_lj.py
#!/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 Sep 20, 2017
Convert a Ghost v1.x JSON export file to Hugo posts.
View ghost2hugo
# 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 Aug 14, 2017
RRD Graph from sar data.
View sa2pyrrd.py
""" 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"""
View twitter_followers.py
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)))
View gist:285100f999d26498e434079a2a7b2466
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
View gist:54450b383c606b6f10797f632eb2be02
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
View ghost_to_hugo.py
#!/usr/bin/env python3
import json
import sys
import datetime
import os.path
with open(sys.argv[1]) as f:
data = json.load(f)
View find_duplicates.py
#!/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 Nov 13, 2015
Automating Hue lights at dusk/dawn, or scheduled
View hue_automation.py
#!/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
View .vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Let Vundle manage Vundle
Bundle 'gmarik/vundle'
" My Bundles