Skip to content

Instantly share code, notes, and snippets.

View wesbasinger's full-sized avatar

Wes Basinger wesbasinger

View GitHub Profile
@wesbasinger
wesbasinger / pagination.js
Created August 7, 2016 20:27
Pagination in a less hacky way...
// Here's the hacky way. I'm looping 8 times, because I know I have 80 students and therefore need at least 8 pages of ten.
function getSubmissions(course, courseWork) {
var optionalArgs = {
pageSize: 10
}
var submissionObjs = [];
for (var i=0; i<8; i++) {
var response = Classroom.Courses.CourseWork.StudentSubmissions.list(course, courseWork, optionalArgs); // API call with necessary parameter
optionalArgs.pageToken = response.nextPageToken; //set next page token for a new page of results on next request
@wesbasinger
wesbasinger / DynamicReactComponents.js
Last active September 5, 2016 00:18
Adding React Components with Button Clicks
var React = require('react');
var OpenResponse = React.createClass({
render: function() {
return (
<div>
Open Response
</div>
)
}
#include <stdio.h>
#include <cs50.h>
void quit();
void show_menu();
void print_list();
void insert_at_tail();
int search();
@wesbasinger
wesbasinger / member-vars.php
Last active February 1, 2019 13:40
Member Variables in a Class
// Is there a difference between the two ways shown below of declaring a member variable in a class?
// If not, would there be a preference of one over the other?
class Foo {
public $bar = "baz";
}
class Foo2 {
public function __construct() {
function validatePythagorean(a, b, c) {
var rightSide = Math.sqrt(a*a + b*b);
if(Math.abs(rightSide - c) < 0.05) {
return true;
} else {
return false;
}
}
def convert(num, base):
highest_power = 0
while base**highest_power < num:
highest_power += 1
result = ""
@wesbasinger
wesbasinger / gist:ca4962dcaeb5e2b2d500ad8246de32b7
Created November 13, 2021 01:53
Relay Code for Garage Door Opener
/*********
Rui Santos
Complete project details at https://RandomNerdTutorials.com/esp8266-relay-module-ac-web-server/
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*********/
// Import required libraries
#include "ESP8266WiFi.h"
import sys
from machine import Pin, ADC
pot = ADC(Pin(0))
pot.atten(ADC.ATTN_11DB)
t = 0
# ruff: noqa: E402
sys.path.append("")
from micropython import const
import uasyncio as asyncio
import aioble
#include <Adafruit_ADS1X15.h>
#include <SoftwareSerial.h>
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
//Adafruit_ADS1015 ads; /* Use this for the 12-bit version */
SoftwareSerial mySerial(2, 3); // RX, TX
bool selfTestEn = false;