Skip to content

Instantly share code, notes, and snippets.

View aberba's full-sized avatar

Lawrence Aberba aberba

View GitHub Profile
@aberba
aberba / app.es6
Last active December 30, 2020 22:04
A sample DraftJS editor for adding image
import React from 'react';
import ReactDOM from 'react-dom';
import {AtomicBlockUtils, Editor, EditorState, Entity, RichUtils, convertToRaw} from 'draft-js';
class MyEditor extends React.Component {
constructor(props) {
super(props);
this.state = {editorState: EditorState.createEmpty()};
@aberba
aberba / hidapi-enum-tst.c
Created November 16, 2020 22:55 — forked from todbot/hidapi-enum-tst.c
hidapi list devices
// hidapi-enum-tst.c -- Demonstrate enumerating
//
// Build with: (assumes you have checked out 'hidapi' into a side directory)
// Mac:
// gcc -I ../hidapi/hidapi ../hidapi/mac/hid.c -framework IOKit -framework CoreFoundation hidapi-enum-tst.c -o hidapi-enum-tst
// Linux (hidraw):
// gcc -I ../hidapi/hidapi ../hidapi/linux/hid.c -ludev hidapi-enum-tst.c -o hidapi-enum-tst
// Linux (libusb):
// gcc -I ../hidapi/hidapi -I /usr/include/libusb-1.0 ../hidapi/libusb/hid.c -lpthread -lusb-1.0 hidapi-enum-tst.c -o hidapi-enum-tst
//
@aberba
aberba / hidapi.d
Created November 9, 2020 00:15 — forked from UplinkCoder/hidapi.d
/*******************************************************
HIDAPI - Multi-Platform library for
communication with HID devices.
Alan Ott
Signal 11 Software
8/22/2009
Copyright 2009, All Rights Reserved.
@aberba
aberba / sample2.d
Created October 20, 2020 20:25 — forked from aferust/sample2.d
module app;
import std.stdio;
import std.experimental.logger: trace;
import std.conv;
import gio.Application : GApplication = Application;
import gtk.Main;
import gtk.Application;
@aberba
aberba / encryption.js
Created October 12, 2020 14:00 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
import { useState, useEffect, useRef } from "react";
export default function useForm({
callback,
validate,
defaultValues = {},
defaultErrors = {}
}) {
const [values, setValues] = useState({});
const [errors, setErrors] = useState({});
@aberba
aberba / feature-flags.md
Created August 8, 2020 22:48 — forked from threepointone/feature-flags.md
Feature flags: why, how, all that

(I'm enjoying doing these raw, barely edited writeups; I hope they're useful to you too)

Feature flags

This is my own writeup on feature flags; for a deep dive I'd recommend something like Martin Fowler's article (https://martinfowler.com/articles/feature-toggles.html).

So. Feature flags. The basic idea that you'll store configuration/values on a database/service somewhere, and by changing those values, you can change the user experience/features for a user on the fly.

Let's say that you're building a new feature, called 'new-button' which changes the color of buttons, which is currently red, to blue. Then you'd change code that looks like this -

[
{
"name": "Ahafo",
"code": ""
},
{
"name": "Ashanti",
"code": ""
},
{

Its not immediately obvious what to do with prebuilt binaries in releases of Raylib. This is how to install the binanries on Debian-based distros.

cd raylib-3.0.0-Linux-amd64
sudo cp lib/libraylib.** /usr/local/lib/
sudo cp include/raylib.h /usr/local/include/
ln -s libraylib.so.3.0.0 libraylib.so.301 
ln -s libraylib.so.301 libraylib.so
sudo ldconfig
@aberba
aberba / vscode_shortcuts.md
Created July 26, 2020 20:27 — forked from bradtraversy/vscode_shortcuts.md
Helpful shortcuts for VSCode

VSCode Shortcuts

List of helpful shortcuts for faster coding

If you have any other helpful shortcuts, feel free to add in the comments of this gist :)

Official List of all commands