Skip to content

Instantly share code, notes, and snippets.

View wouterds's full-sized avatar
:octocat:
Hello world!

Wouter De Schuyter wouterds

:octocat:
Hello world!
View GitHub Profile
@wouterds
wouterds / setup.sh
Created February 9, 2020 10:23
Droplet setup essentials
# login
ssh root@server
# install updates
sudo apt-get update && sudo apt-get upgrade -y
# install some utils
sudo apt-get install -y git zsh wget curl htop
# firewall
@wouterds
wouterds / Dockerfile
Created August 3, 2019 20:14
Phantomjs support for Nodejs Alpine Docker container
ENV PHANTOMJS_VERSION 2.1.1
RUN apk add --update --no-cache curl && \
curl -Ls https://github.com/dustinblackman/phantomized/releases/download/${PHANTOMJS_VERSION}/dockerized-phantomjs.tar.gz | tar xz -C / && \
curl -k -Ls https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2 | tar -jxvf - -C . && \
cp phantomjs-${PHANTOMJS_VERSION}-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs && \
rm -fR phantomjs-${PHANTOMJS_VERSION}-linux-x86_64 && \
apk del curl
@wouterds
wouterds / samples.sql
Last active July 17, 2019 08:12
I want to select data between day x and day y returned as z amount of rows (scaled down data set).
CREATE TABLE IF NOT EXISTS `samples` (
`id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`value` float(8,2) NOT NULL,
`createdAt` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `samples_created_at` (`createdAt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `samples` (`id`, `value`, `createdAt`)
VALUES
CREATE USER 'user'@'host' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON `db`.* TO 'user'@'host' IDENTIFIED BY 'pass';
FLUSH PRIVILEGES;
import Hashids from 'hashids';
const hashids = new Hashids(
process.env.HASHIDS_SALT,
4,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
);
export const encode = (id: number): string => hashids.encode(id);
export const decode = (id: string): number | null => {
SELECT
sensors.type,
samples.value,
DATE_FORMAT(
CONVERT_TZ(
samples.createdAt,
'+00:00',
'+01:00'
),
'%Y-%m-%d %h:%i %p'
#include <Wire.h>
#include <ESP8266WebServer.h>
#include <TSL2561.h>
const char *ssid = "Wouter's Place";
const char *password = "";
ESP8266WebServer server(80);
TSL2561 tsl2561(TSL2561_ADDR_FLOAT);
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#define LED D1
const char *ssid = "Wouter's Place";
const char *password = "";
const axios = require('axios');
const chalk = require('chalk');
const sleep = require('await-sleep');
const checkCode = async (code) => {
const codes = [code];
const response = await axios.post('https://winadrone.kelloggs.com/api/nl_BE/redemption/validate-codes', { codes });
const { data } = response;