Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
Is this the new MSN Messenger

Lim Chee Aun cheeaun

🦄
Is this the new MSN Messenger
View GitHub Profile
View wishes.csv
We can't make this file beautiful and searchable because it's too large.
name,content,lng,lat
yy,Happy birthday Singapore!! Thank you Moments of Life team for creating this!,103.762,1.354
wj,Happy Birthday Singapore!,103.8,1.274
Cindy Lim Qiu Xia,Happy birthday to Singapore .,103.885,1.326
GJ,Happy Birthday Singapore!,103.873,1.368
Alexa,"Thanks for being there for my yesterdays, for growing with me into my today, and for giving me hope towards my tomorrow. Happy 55th and to more glorious years ahead! 😍 🇸🇬",103.806,1.443
GJ,Happy Birthday Singapore!!,103.873,1.368
Tanglin Boy,I love Singapore from the bottom of my heart! Happy National Day!,103.79851,1.2992
Tom,HBD Singapore!,103.80249,1.27221
z,"Happy Birthday, Singapore!",103.93579,1.36536
@cheeaun
cheeaun / median.js
Created Jun 14, 2020
Find median from array of numbers (mutable, due to .sort())
View median.js
function median(numbers) {
const middle = (numbers.length + 1) / 2;
const sorted = numbers.sort((a, b) => a - b);
const isEven = sorted.length % 2 === 0;
return isEven
? (sorted[middle - 1.5] + sorted[middle - 0.5]) / 2
: sorted[middle - 1];
}
@cheeaun
cheeaun / p-timeout.js
Created Apr 25, 2020
promisified setTimeout
View p-timeout.js
const pTimeout = (t) =>
new Promise((res, rej) => {
setTimeout(res, t);
});
@cheeaun
cheeaun / ImperativeText.js
Created Apr 24, 2020
React Native's Text component, but imperative instead for setting the text value
View ImperativeText.js
import React, { forwardRef, useState, useImperativeHandle } from 'react';
import { Text } from 'react-native';
export default forwardRef((props, ref) => {
const [text, setText] = useState('');
useImperativeHandle(ref, () => ({
setText: t => {
if (t) setText(t);
},
}));
@cheeaun
cheeaun / resize-nearest-neighbour.js
Created Mar 21, 2020
Resize (2D but flat) array of values with nearest neighbour algorithm
View resize-nearest-neighbour.js
const width = 300;
const height = 200;
const newWidth = width * 2;
const newHeight = height * 2;
const xRatio = width / newWidth;
const yRatio = height / newHeight;
const resizeValues = (id, values) => {
const newValues = new Array(newWidth * newHeight);
for (let i = 0; i < newHeight; i++) {
for (let j = 0; j < newWidth; j++) {
@cheeaun
cheeaun / durian.geojson
Last active May 1, 2019
Durio species GeoJSON, extracted from https://github.com/cheeaun/exploretrees-sg dataset
View durian.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cheeaun
cheeaun / singapore-boundary.geojson
Created Feb 12, 2019
Singapore land boundary GeoJSON (hi-res)
View singapore-boundary.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cheeaun
cheeaun / checkweathersg.sh
Last active Nov 18, 2018
One-liner command to grab rain radar snapshot in ASCII format from https://checkweather.sg
View checkweathersg.sh
node -e "require('https').get('https://api.checkweather.sg/now?ascii=1', res => res.on('data', d => process.stdout.write(d + '\n\n')))"
@cheeaun
cheeaun / .block
Last active Jan 28, 2018
Film Flowers, Full Starter Code
View .block
license: gpl-3.0
You can’t perform that action at this time.