Skip to content

Instantly share code, notes, and snippets.

View drhanlau's full-sized avatar
💭
Working on AI projects

Dr. Lau Cher Han drhanlau

💭
Working on AI projects
View GitHub Profile
@drhanlau
drhanlau / textbox-template.html
Created March 11, 2022 23:12
A template for single row textbox with a button
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text field input with button template</title>
</head>
<body>
<div class="fixed bottom-0 pb-5 text-center text-gray-500 text-sm w-full">
x = 1
while (x < 100):
if x % 2 == 0:
print(x)
x += 1 
from PIL import Image, ImageDraw, ImageFont
img = Image.open('mutton.jpg')
font = ImageFont.truetype('/Library/Fonts/Impact.ttf', 100)
draw = ImageDraw.Draw(img)
def draw_text(x, y, text):
draw.text((x-2, y-2), text,(0,0,0),font=font)
draw.text((x+2, y-2), text,(0,0,0),font=font)
@drhanlau
drhanlau / news_to_db.py
Created January 26, 2020 01:40
Port news from API to DB
import urllib.request, json
with urllib.request.urlopen("https://us-central1-newsproject-41eb3.cloudfunctions.net/getLatestCoronaNews") as url:
data = json.loads(url.read().decode())
news = data['data'][0]['data']
query = "INSERT INTO news (url, title, description, content, published, imageUrl) VALUES (%s, %s, %s, %s, %s, %s)"
for n in news:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
var series= [{
name: 'Bayan Lepas',
data: [4.3, 5.1, 4.3, 5.2, 5.4, 4.7, 3.5, 4.1, 5.6, 7.4, 6.9, 7.1,
7.9, 7.9, 7.5, 6.7, 7.7, 7.7, 7.4, 7.0, 7.1, 5.8, 5.9, 7.4,
8.2, 8.5, 9.4, 8.1, 10.9, 10.4, 10.9, 12.4, 12.1, 9.5, 7.5,
7.1, 7.5, 8.1, 6.8, 3.4, 2.1, 1.9, 2.8, 2.9, 1.3, 4.4, 4.2,
3.0, 3.0]
}, {
name: 'GeorgeTown',
data: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.3, 0.0,
series: [{
name: 'USA',
data: [null, null, null, null, null, 6, 11, 32, 110, 235, 369, 640,
1005, 1436, 2063, 3057, 4618, 6444, 9822, 15468, 20434, 24126,
27387, 29459, 31056, 31982, 32040, 31233, 29224, 27342, 26662,
26956, 27912, 28999, 28965, 27826, 25579, 25722, 24826, 24605,
24304, 23464, 23708, 24099, 24357, 24237, 24401, 24344, 23586,
22380, 21004, 17287, 14747, 13076, 12555, 12144, 11009, 10950,
10871, 10824, 10577, 10527, 10475, 10421, 10358, 10295, 10104]
}, {
series: [{
name: 'Nasdaq',
color: '#4572A7',
data: [ [ Date.UTC(2012, 4, 11, 9, 30), 2606.01 ], [ Date.UTC(2012, 4, 11, 10), 2622.08 ],
[ Date.UTC(2012, 4, 11, 10, 30), 2636.03 ],
[ Date.UTC(2012, 4, 11, 11), 2637.78 ], [ Date.UTC(2012, 4, 11, 11, 30), 2639.15 ],
[ Date.UTC(2012, 4, 11, 12), 2637.09 ], [ Date.UTC(2012, 4, 11, 12, 30), 2633.38 ],
[ Date.UTC(2012, 4, 11, 13), 2632.23 ], [ Date.UTC(2012, 4, 11, 13, 30), 2632.33 ],
[ Date.UTC(2012, 4, 11, 14), 2632.59 ], [ Date.UTC(2012, 4, 11, 14, 30), 2630.34 ],
[ Date.UTC(2012, 4, 11, 15), 2626.89 ], [ Date.UTC(2012, 4, 11, 15, 30), 2624.59 ], [ Date.UTC(2012, 4, 11, 16), 2615.98 ] ]
options = {
chart: {
type: 'line',
height: 250,
},
title: {
text: 'Market Data: Nasdaq 100'
},
subtitle: {
text: 'May 11, 2016'
options = {
chart: {
renderTo: 'container',
type: 'spline',
plotBorderWidth: 1,
plotBorderColor: '#3F4044',
borderColor: '#a1a1a1',
borderWidth: 2,
borderRadius: 3
},