Laur's blog
  • Home
  • About
  • Support my work
Sign in Subscribe
DRF: What is 'source' in Fields?
django

DRF: What is 'source' in Fields?

For a couple of days I've been trying to de-serialise a JSON to a model. My problem is the model and the JSON have different fields, mainly to keep the model pythonic and independent of a specific JSON source. So... I've been trying to use the
Sep 30, 2017 1 min read
Timestamp to DateTime Serializer Field for DRF
datetime

Timestamp to DateTime Serializer Field for DRF

I'm currently trying to deserialize JSON data to a Django model. This is quite straight forward for most numeric fields, but I have a `DateTime` field which is stored as a timestamp in the original JSON.
Sep 29, 2017 2 min read
Redis on Windows - Save RDB but Not Able to Persist
db

Redis on Windows - Save RDB but Not Able to Persist

TL;DR: My windows service wasn't installed properly. Change the config file to point the DB to an accessible directory and reinstall the service. When trying to build a perioduc Celery task, I got the following error with Redis on Windows (running as a windows service): redis.exceptions.
Sep 23, 2017 1 min read
Run Celery 4.1.0 on Windows 10
celery

Run Celery 4.1.0 on Windows 10

TL;DR: Use set FORKED_BY_MULTIPROCESSING=1 on the worker script/shell When running Celery on Windows 10, I got the following error: ValueError: not enough values to unpack (expected 3, got 0) This is quite unfortunate as Windows is supported on "best effort". A pull request
Sep 22, 2017 1 min read
Use Docker Behind Proxy on Windows 8
8

Use Docker Behind Proxy on Windows 8

The other day I had to install Docker at work, aka behind a corporate proxy (on Windows 8). While the docker installer is stand-alone and all is good, dealing with the VM is a different matter... The problem popped up when I tried to create a Django image and pip
Sep 21, 2017 1 min read
Vega 56 and ETH - Keep Your Cool
56

Vega 56 and ETH - Keep Your Cool

TL;DR: Keep your Vega cool if you want high hash rates! Recently, I've got a AMD Vega RX 56, to see for myself how good it is on mining. If you ignore the power consumption, it's quicker than my RX580 cards. I'm getting
Sep 18, 2017 2 min read
Check Computer Started without Admin Provileges
admin

Check Computer Started without Admin Provileges

TL;DR: open the Event viewer, select the Windows Logs > System and Filter Current Log to the desired interval. Or you can scroll to the earliest entry of the day you need (more irritating because the event window doesn't refresh when scrolling). The other day I needed
Sep 12, 2017 2 min read
Ethereum - Fix Slow Sync
ethereum

Ethereum - Fix Slow Sync

To fix the slow sync problem in the ethereum miner, you need to: 1. backup your account(s) and application data (from the eth wallet if you're using it) 2. remove the chaindata content via 1. delete the directory (easiest/quickest way) 2. use the geth removedb command
Sep 2, 2017 1 min read
Mining Rig Build Log - 1
aluminium

Mining Rig Build Log - 1

I've decided to join the recent trend of mining cryptocoins with GPUs. First, I got a GPU (an EVGA 1070) to complement my 970 and stuck it in my desktop. This is nowhere near profitable because I'd have to block an I7 machine to mine on
Sep 1, 2017 3 min read
Convert Timestamp to DateTime for Pandas DataFrame
dataframe

Convert Timestamp to DateTime for Pandas DataFrame

To convert a pandas data frame value from unix timestamp to python datetime you need to use: pd.to_datetime(df['timestamp'], unit='s') where: * timestamp is the column containing the timestamp value * unit='s' defines the unit of the timestamp (seconds in this
Aug 8, 2017 1 min read
Save Pandas DataFrame as Django Model
convert

Save Pandas DataFrame as Django Model

TL;DR: use bulk_upload coupled with a comprehension to speed up loading. Initially, I started to convert the data frame to a Model object row by row and save it. While easy, it's also arguably the slowest method to load records, because the save() call performs a
Aug 7, 2017 2 min read
Styling HTML to PDF with iText 2.1.7
css

Styling HTML to PDF with iText 2.1.7

There are various solutions for producing PDFs from a HTML file, some with excellent results (e.g. ones based on the chrome renderer). Unfortunately, they usually mean adding more dependencies to an existing system. To keep things in check, we've chosen to use iText to generate PDFs. Following
Jul 8, 2017 1 min read
HTML to PDF with iText 2.1.7
2.1.7

HTML to PDF with iText 2.1.7

Sometimes you need to use an older version of a product die to e.g. licensing changes. It's my case with iText. While the new version looks fantastic, their changes (and removal of e.g. RTF output) are deal breakers for the feature set we need to maintain.
Jul 7, 2017 1 min read
Load Templates with Pebble
django

Load Templates with Pebble

Pebble is a templating engine. It looks particularly familiar to me because I have been using Django. You have access to blocks, include/import features, loops etc. This post is a simple exercise in loading some templates. Prerequisites * I've been using Eclipse IDE, but you can use whatever
Jul 7, 2017 2 min read
Display a Function's Errors in Oracle
dbms

Display a Function's Errors in Oracle

TL;DR: Use the power of DBMS_OUTPUT.PUT_LINE, Luke! I've built a function along the lines of: CREATE OR REPLACE FUNCTION HAS_PANEL_FLAG_OK( P_USER_ID in USERS.USER_ID%TYPE, P_PANEL_ID in PANELS.PANEL_ID%TYPE, ) RETURN integer IS lv_count
Jun 30, 2017 1 min read
Call an Oracle Function from Spring with CallableStatement
call

Call an Oracle Function from Spring with CallableStatement

Following the previous post, I wondered if there's a more elegant way to call a function. It turns out there is and it's based on CallableStatement: int value = jdbcOperations.execute( new CallableStatementCreator() { // ... }, new CallableStatementCallback<Integer>() { // ... } ); The CallableStatementCreator sets up the statement and the CallableStatementCallback
Jun 29, 2017 1 min read
Call an Oracle Function from Spring
function

Call an Oracle Function from Spring

The easiest way to call a function from Spring is using SELECT. For example, having a function HAS_PANEL_FLAG_OK with two parameters and returning an integer, the function call looks like: SELECT panel_id, HAS_PANEL_FLAG_OK('17584', panel_id) AS flag FROM panels WHERE
Jun 29, 2017 1 min read
Easy Volumio Plugin Development
development

Easy Volumio Plugin Development

The past few days I've been struggling with building a volume controller plugin for volumio. My initial routine would be something like: * edit the source code on a PC * zip the code and some node_modules bundled from another plugin * load the plugin in volumio This presents several
Jun 28, 2017 2 min read
Letter from the Commune to Cut the Grass
house

Letter from the Commune to Cut the Grass

Today I got a letter from the Commune to cut the grass. The letter was in Flemish. I reproduced its translated content below. Not maintained plot + footpath for your plot Dear, The police have determined that your plot + the footpath for your plot, located on the street, are not maintained.
Jun 26, 2017 1 min read
Enable SSH on Boot on Raspberry Pi
ssh raspberry

Enable SSH on Boot on Raspberry Pi

Enabling SSH on boot is as simple as placing an empty file named ssh in /boot. This works on Raspbian (and Volumio!) HTH,
Jun 25, 2017
SoundMachine Build Log 02
build

SoundMachine Build Log 02

I've decided to put in a knob to control the volume directly on the box itself. It will be controlled by volumio itself via a plugin, much like the GPIO Buttons plugin. Since this is really a development kit approach, the hardware consists of: * A KY-040 rotary encoder
Jun 23, 2017 2 min read
SoundMachineBuild Log 01
build

SoundMachineBuild Log 01

A while ago I've decided to try my hand at replacing my Sonos system with a DIY version of a sound system. I have two reasons to do this: 1. I think it's going to be fun and 2. I have a bunch of FLAC files
Jun 15, 2017 1 min read
HifiBerry Pin Usage
berry

HifiBerry Pin Usage

The past few days I've been struggling with the unknown of how many pins from the GPIO interface are actually used by the HifiBerry sound card (or my clone). Fortunately, I've found the used pins: As you can see, there are quite a few pins left
Jun 13, 2017 1 min read
Applications for EPSO/AD/331/16 - Second Phase
2016

Applications for EPSO/AD/331/16 - Second Phase

The number of applications are: No. Section Places Candidates Ratio 1 Data Analysis and IT Service 30 88 ~3x 2 Digital Workplace, Office Automation and Mobile Computing 25 75 3x 3 Enterprise Resource Planning (ERP) 14 41 ~3x 4 ICT Security 49 147 3x 5 IT Infrastructure 38 112 ~3x
May 12, 2017
Change the File Extension in Typescript - Using Path
change

Change the File Extension in Typescript - Using Path

Following from my previous post, I've updated the function to use only the path module. Now, the code looks like: export function changeExtension(filepath: string, extension: string): string { let dir: string = path.dirname(filepath) let ext: string = path.extname(filepath) let root: string = path.basename(filepath, ext) ext
Apr 28, 2017 1 min read
← Newer Posts Page 13 of 26 Older Posts →
Laur's blog © 2026
  • Sign up
Powered by Ghost