Skip to content

Instantly share code, notes, and snippets.

@cbscribe
cbscribe / gist:19e593e5c52df552b7a066861df34d3a
Created November 2, 2020 19:10
Arduino example: LED toggle button
void setup()
{
pinMode(12, OUTPUT);
pinMode(2, INPUT_PULLUP);
}
int button;
int last_button;
int led = LOW;
void loop()
void setup()
{
for (int i = 1; i < 9; i++)
{
pinMode(i, OUTPUT);
}
}
void loop()
{
// Code in the setup section runs once
void setup()
{
for (int x = 1; x < 5; x++)
{
pinMode(x, OUTPUT);
}
}
// Code in the loop section repeats
@cbscribe
cbscribe / is_gif.c
Last active October 28, 2020 17:19
#include <stdio.h>
// Every GIF must have this first 6 bytes
char *gif_header = "GIF89a";
int main(int argc, char *argv[])
{
// check for correct number of arguments
if (argc != 2)
{
@cbscribe
cbscribe / cards.c
Created October 23, 2020 17:55
Deck of cards in C
#include <stdio.h>
#include <stdlib.h>
#include <cs50.h>
#include <time.h>
#define DECK_SIZE 52
// strings for pretty printing values
string ranks[14] = {"", "Ace", "Two", "Three", "Four", "Five", "Six",
"Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
<!DOCTYPE html>
<html lang="en">
<head>
<title>Cats</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Learn about cats!</h1>
<h2>Section 1</h2>
<p>
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return "Hello world!"
@app.route("/goodbye")
def bye():
@cbscribe
cbscribe / orbit simulation.py
Created January 16, 2020 18:57
Solar system simulation
# http://nssdc.gsfc.nasa.gov/planetary/factsheet/
import turtle
import math
turtle.bgcolor("black")
G = 6.67428e-11
AU = 149.6e9 # m
SCALE = 250 / (2 * AU) # pixels/AU
TIMESTEP = 24 * 3600 # s
@cbscribe
cbscribe / bs4_example.py
Last active October 25, 2018 01:08
Python beautifulsoup example
import requests, bs4
import time
# for n in range(0, 5937):
# url = 'https://www.fiercebiotech.com/biotech?page=0%2C' + str(n)
# data = requests.get(url)
# use this to prevent ddos
# time.sleep(10)
shader_type canvas_item;
/**
Maps object texture onto a sphere and applies a spherical normal
based on a simulated light.
Adapted from
https://www.raywenderlich.com/2323-opengl-es-pixel-shaders-tutorial
and
https://gamedev.stackexchange.com/a/9385