Skip to content

Instantly share code, notes, and snippets.

@cbscribe
cbscribe / utils.gd
Last active February 7, 2019 06:50
GDScript utility functions
# add this as a singleton and access functions using
# util.<function_name>
extends Node
# choose a random item from an array
static func rand_choice(list):
return list[randi() % list.size()]
# choose a random integer in range (start, end-1)
@cbscribe
cbscribe / RigidbodyController3D.gd
Created August 27, 2017 23:47 — forked from willnationsdev/RigidbodyController3D.gd
A Basic Controller for a 3D Rigidbody in Godot 3.0
# A Rigidbody Controller for basic 3D movement
extends RigidBody
# not sure what to put here to get proper turning
var turn_speed = Vector3(1,0,0)
# not sure what to put here to get proper movement
var movement_speed = Vector3(1,0,0)
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
@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)
@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
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return "Hello world!"
@app.route("/goodbye")
def bye():
<!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>
@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"};
@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)
{
// 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