This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE USER 'user'@'host' IDENTIFIED BY 'pass'; | |
GRANT ALL PRIVILEGES ON `db`.* TO 'user'@'host' IDENTIFIED BY 'pass'; | |
FLUSH PRIVILEGES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
sensors.type, | |
samples.value, | |
DATE_FORMAT( | |
CONVERT_TZ( | |
samples.createdAt, | |
'+00:00', | |
'+01:00' | |
), | |
'%Y-%m-%d %h:%i %p' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <ESP8266WiFi.h> | |
#include <WiFiClient.h> | |
#include <ESP8266WebServer.h> | |
#define LED D1 | |
const char *ssid = "Wouter's Place"; | |
const char *password = ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
pinMode(LED_BUILTIN, OUTPUT); | |
} | |
void loop() { | |
digitalWrite(LED_BUILTIN, HIGH); | |
delay(1000); | |
digitalWrite(LED_BUILTIN, LOW); | |
delay(1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |