The popular open-source contract for web designers and developers by Stuff & Nonsense
- Originally published: 23rd December 2008
- Revised date: October 8th 2015
- Original post
$ python xlogd.py sample.log | |
parsed: {'appname': 'test.app', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '68898', 'priority': '132', 'message': 'bla bla bla warn'} | |
parsed: {'appname': 'test.app', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '68902', 'priority': '131', 'message': 'bla bla bla error'} | |
parsed: {'appname': 'Dock', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '154', 'priority': '11', 'message': 'CGSReleaseWindowList: called with 5 invalid window(s)'} | |
parsed: {'appname': 'WindowServer', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '79', 'priority': '11', 'message': 'CGXSetWindowListAlpha: Invalid window 0'} |
# wait for incoming data to consume with a for loop | |
def consume(): | |
while True: | |
data = yield | |
consumer = data # Aliase the data variable to ensure the generator stays "charged" | |
for i in consumer: # consume the data and return back to the while loop | |
print i | |
# Just a basic generator object for proof of concept | |
def in_gen(x): |
import time | |
file_name = './food.txt' | |
def coroutine(func): | |
'''A decorator that advances | |
the execution to the first 'yield' | |
in a generator so that this generator |
<?php | |
class SecureSessionHandler extends SessionHandler { | |
protected $key, $name, $cookie; | |
public function __construct($key, $name = 'MY_SESSION', $cookie = []) | |
{ | |
$this->key = $key; | |
$this->name = $name; |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include "mylib.h" | |
#include "rbt.h" | |
#define IS_BLACK(x) ((NULL == (x)) || (BLACK == (x)->colour)) | |
#define IS_RED(x) ((NULL != (x)) && (RED == (x)->colour)) |
# to generate your dhparam.pem file, run in the terminal | |
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
#!/usr/bin/env python | |
## Tiny Syslog Server in Python. | |
## | |
## This is a tiny syslog server that is able to receive UDP based syslog | |
## entries on a specified port and save them to a file. | |
## That's it... it does nothing else... | |
## There are a few configuration parameters. | |
LOG_FILE = 'youlogfile.log' |
Linus Torvalds in an interview talked about the idea of good taste in code or what I like to call elegance. As one might expect from two slides meant to make a point during a talk, he omits a lot of details to keep it short and simple. This post digs into the specifics of his example (deleting an element from a list) and adds another example (inserting an element in a list) including working code.
This is an example of removing an element from a singly-linked list. It's one of the first data structures you learn about when you start learning about computer science and programming. The reason it doesn't show particularly good taste is because we have that condition at the end where we take a different action depending on whether the element we want to remove is at the beginning of the list or somewhere in the middle.
![Bad taste](http://
npm WARN deprecated [email protected]: Use uuid module instead | |
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/bin/firebase | |
> [email protected] install /usr/local/lib/node_modules/firebase-tools/node_modules/grpc | |
> node-pre-gyp install --fallback-to-build --library=static_library | |
node-pre-gyp ERR! Tried to download(undefined): https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v1.4.1/node-v59-linux-x64.tar.gz | |
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v59 ABI) (falling back to source compile with node-gyp) | |
gyp ERR! configure error | |
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/build' |