Skip to content

Instantly share code, notes, and snippets.

View aberba's full-sized avatar

Lawrence Aberba aberba

View GitHub Profile
@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);
@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 -

@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

@aberba
aberba / example.js
Created January 20, 2020 16:31 — forked from faisalman/example.js
7-bit GSM 03.38 <-> Unicode Map in JS
// Unicode to 7-bit GSM
var write = "Hello, Faisalman!";
var msgSubmit = "";
write.split('').forEach(function(i) {
msgSubmit += parseInt(Unicode2GSM[i], 10).toString(16).toUpperCase() + " ";
});
console.log(msgSubmit); // "48 65 6C 6C 6F 2C 20 46 61 69 73 61 6C 6D 61 6E 21 "
// 7-bit GSM to Unicode
var read = "48 65 6C 6C 6F 2C 20 46 61 69 73 61 6C 6D 61 6E 21 ";
@aberba
aberba / ReactTippy.jsx
Created February 16, 2019 22:02
React Component for Tippy.js
import React from 'react'
import ReactDOM from 'react-dom'
import tippy from 'tippy.js'
class Tippy extends React.Component {
html = React.createRef()
componentDidMount() {
const { children, ...props } = this.props
this.tippyInstance = tippy.one(ReactDOM.findDOMNode(this), {
@aberba
aberba / ServingES6.md
Created January 11, 2019 19:01 — forked from newyankeecodeshop/ServingES6.md
Serving ES6 to modern browsers

Background

Recently I noticed that Safari 10 for Mac/iOS had achieved 100% support for ES6. With that in mind, I began to look at the browser landscape and see how thorough the support in the other browsers. Also, how does that compare to Babel and its core-js runtime. According to an ES6 compatability table, Chrome, Firefox, and IE Edge have all surpassed what the Babel transpiler can generate in conjunction with runtime polyfills. The Babel/core-js combination achieves 71% support for ES6, which is quite a bit lower than the latest browsers provide.

It made me ask the question, "Do we need to run the babel es2015 preset anymore?", at least if our target audience is using Chrome, Firefox, or Safari.

It's clear that, for now, we can't create a site or application that only serves ES6. That will exclude users of Internet Explorer and various older browsers running on older iOS and Android devices. For example, Safari on iOS 9 has pretty mediocre ES6 support.

@aberba
aberba / elementaryos.md
Created November 7, 2018 19:13 — forked from suberb/elementaryos.md
elementaryOS | Things To Do After Installing Elementary OS Loki [Best OS For Switching From Windows & Mac]

FIRST THING FIRST


  • Update OS
sudo apt-get update && sudo apt-get upgrade