Skip to content

Instantly share code, notes, and snippets.

🦄
Supreme

Queensferry queensferryme

🦄
Supreme
Block or report user

Report or block queensferryme

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@queensferryme
queensferryme / producer-consumer.c
Created Oct 28, 2019
Multithreading producer-consumer model implemented with pthread library
View producer-consumer.c
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int buffer[BUFSIZ], head = 0, tail = 0;
pthread_t producer, consumer;
pthread_cond_t notempty, notfull;
pthread_mutex_t lock;
@queensferryme
queensferryme / egestream.h
Last active Jun 3, 2019
Input stream implementation for Easy Graphics Engine (https://xege.org)
View egestream.h
#pragma once
#include <functional>
#include <graphics.h>
#include <sstream>
#include <string.h>
#include <string>
namespace ege {
@queensferryme
queensferryme / abstract_factory.py
Last active Feb 25, 2019
A simple implementation of Factory Pattern in language python
View abstract_factory.py
#!/usr/bin/env python
class UIFactory:
def __init__(self, **builders):
self.builders = builders
def createMenu(self):
return self.builders['menu']()
def createText(self):
@queensferryme
queensferryme / charts.py
Last active Feb 15, 2019
Crawling, analyzing & visualizing #WanderingEarth comments on movie.douban.com
View charts.py
#!/usr/bin/env python
import json
import os
from collections import Counter, defaultdict
import jieba.analyse
from pyecharts import Bar, Line, WordCloud
@queensferryme
queensferryme / pubsub.py
Last active May 14, 2019
A simple implementation of Pub/Sub Pattern in language python
View pubsub.py
#!/usr/bin/env python
from collections import defaultdict
class Intermedia:
channels = defaultdict(dict)
@classmethod
def broadcast(cls, channel, msg):
'''broadcast a message to specific subscribers'''
for name, callback in cls.channels[channel].items():
@queensferryme
queensferryme / mail.py
Last active Feb 8, 2019
Email automatic templating & sending implemented with Python
View mail.py
#!/usr/bin/env python
from csv import DictReader
from email.encoders import encode_base64
from email.header import Header
from email.mime.base import MIMEBase
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from os.path import split, splitext
You can’t perform that action at this time.