Skip to content

Instantly share code, notes, and snippets.

View securetorobert's full-sized avatar

Robert John securetorobert

  • Nigeria
View GitHub Profile
@securetorobert
securetorobert / toggle.ino
Created June 18, 2022 06:37
code to toggle state and control an output pin on Arduino Nano RP2040 Connect
#include <Bounce2.h>
const int pin = 2;
const int button = 10;
bool led_state = false;
Bounce bouncer = Bounce();
// the setup function runs once when you press reset or power the board
void setup() {
pinMode(pin, OUTPUT);
@securetorobert
securetorobert / rpi_temperature_grove.py
Created April 5, 2022 22:40
A python file for reading temperature and humidity and displaying on an LCD screen using Grove connectors
#
# Weather Station. Requires Grove Shield, Temp Sensor, and LCD
import utime
from lcd1602 import LCD1602
from dht11 import *
from machine import Pin, I2C
from time import sleep
@securetorobert
securetorobert / blinky.py
Created November 22, 2021 01:02
Blinky in MicroPython
import utime
import machine
led_onboard = machine.Pin(25, machine.Pin.OUT)
while True:
led_onboard.value(1) #set the LED to on
utime.sleep(1) #wait 1 second
led_onboard.value(0) #sset the LED to off
utime.sleep(1)
@securetorobert
securetorobert / arduino_blinky.ino
Created November 22, 2021 01:01
Blinky in Arduino
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
@securetorobert
securetorobert / main.c
Created November 22, 2021 01:01
Hello World in C
#include <stdio.h>
void main() {
// Write C code here
printf("Hello world");
}
@securetorobert
securetorobert / export_to_gcs.sql
Created March 24, 2021 16:20
Export bicycle hires to GCS
EXPORT DATA
OPTIONS (format=CSV,
header=TRUE,
uri="gs://bucket/path/rides_*.csv") AS
SELECT
*
FROM
`bigquery-public-data.london_bicycles.cycle_hire`
WHERE
DATE_TRUNC(DATE(end_date), month) >= '2015-08-01'
@securetorobert
securetorobert / hires_aug_2015_to_dec_2016.sql
Created March 24, 2021 15:39
Hires between August 2015 and January 2017
SELECT
COUNT(rental_id)
FROM
`bigquery-public-data.london_bicycles.cycle_hire`
WHERE
DATE_TRUNC(DATE(end_date), month) >= '2015-08-01' and DATE_TRUNC(DATE(end_date), year) < '2017-01-01'
@securetorobert
securetorobert / bicycle_hires_before_2017.sql
Created March 24, 2021 15:26
How many hires do we have before 2017
SELECT
COUNT(rental_id)
FROM
`bigquery-public-data.london_bicycles.cycle_hire`
WHERE
DATE_TRUNC(DATE(end_date), year) < '2017-01-01'
@securetorobert
securetorobert / years_in_bicycle_hire.sql
Created March 24, 2021 15:19
Truncate the end_date to the year in London Bicycle Hires table and group by that.
SELECT
DATE_TRUNC(DATE(end_date), YEAR)
FROM
`bigquery-public-data.london_bicycles.cycle_hire`
GROUP BY
1
@securetorobert
securetorobert / lenet.py
Created October 1, 2020 17:14
LeNet model definition
model = models.Sequential([
layers.Conv2D(filters=6, kernel_size=(5,5), strides=1, activation='tanh', input_shape=(HEIGHT, HEIGHT, NUM_CHANNELS)),
layers.AveragePooling2D(pool_size=(2,2)),
layers.Conv2D(filters=16, kernel_size=(5,5), strides=1, activation='tanh'),
layers.AveragePooling2D(pool_size=(2,2)),
layers.Flatten(),
layers.Dense(120),
layers.Dense(84),
layers.Dense(NCLASSES, activation='softmax')
])