Skip to content

Instantly share code, notes, and snippets.

View benjcal's full-sized avatar

Ben Calderon benjcal

View GitHub Profile
@benjcal
benjcal / sdlsimple.h
Last active August 13, 2023 04:23
sdlsimple.h
#ifndef H_SDLSIMPLE
#define H_SDLSIMPLE
#include <SDL2/SDL.h>
#include <stdbool.h>
#include <stdio.h>
// defines
typedef struct sdlsimple_events_t {
bool quit;
@benjcal
benjcal / wordle.tcl
Last active September 12, 2022 13:31
Wordle with Tcl
# wordle.tcl
set inc_l s
set excl_l judgemcbn
set inc_pt [list '.la.k' ]
set excl_pt [list 's....']
proc include-letters {letters} {
set letters_list [split $letters {}]
import React from 'react'
import { observer } from 'mobx-react'
import store from './store'
let student1 = {
id: 'student1',
name: 'Ben'
}
let student2 = {
id: 'student2',
import { observable, computed } from 'mobx'
const store = observable({
students: observable.map(),
courses: observable.map(),
enrollment: observable.map(),
addStudent(student) {
if (this.students.has(student.id)) {
throw new Error('student already exists')
/**********************************************
*
* This simple library is used to redirect
* functions like printf(), scanf(), putchar()
* among other to the UART output on the STM32
* using HAL.
*
* Credits to the book Mastering STM32
* File by Benjamin Calderon 2017
*
@benjcal
benjcal / index.js
Last active March 23, 2018 17:16
JS - Rust comparison
let startArr = [1, 2, 3, 4, 5]
let newArr = startArr.filter(n => n > 2) // -> [3, 4, 5]
let newStr = "foo bar"
let result = newStr.startsWith("foo") // -> true
@benjcal
benjcal / www-data_permissions.sh
Last active January 24, 2018 23:16
www-data permissions
sudo chown -R admin:www-data /var/www;
sudo find /var/www -type f -exec chmod 664 {} \;
sudo find /var/www -type d -exec chmod 775 {} \;
sudo find /var/www -type d -exec chmod g+s {} \;
// Credits: https://github.com/hexagon5un/AVR-Programming/blob/master/AVR-Programming-Library/macros.h
#define BV(bit) (1 << bit)
#define set_bit(sfr, bit) (_SFR_BYTE(sfr) |= BV(bit)) // old sbi()
#define clear_bit(sfr, bit) (_SFR_BYTE(sfr) &= ~BV(bit)) // old cbi()
#define toggle_bit(sfr, bit) (_SFR_BYTE(sfr) ^= BV(bit))
alias nah="git reset --hard && git clean -df"