Skip to content

Instantly share code, notes, and snippets.

Avatar

Lawrence Aberba aberba

View GitHub Profile
View 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 Oct 12, 2020 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
View encryption.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);
View useForm.js
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 Aug 8, 2020 — forked from threepointone/feature-flags.md
Feature flags: why, how, all that
View feature-flags.md

(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 -

View regions_in_ghana.json
[
{
"name": "Ahafo",
"code": ""
},
{
"name": "Ashanti",
"code": ""
},
{
View raylib_install_prebuilt_binaries.md

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 Jul 26, 2020 — forked from bradtraversy/vscode_shortcuts.md
Helpful shortcuts for VSCode
View vscode_shortcuts.md

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

View nanogui_demo2.d
import arsd.nanovega;
import nanogui.sdlbackend : SdlBackend;
class MyGui : SdlBackend
{
this(int w, int h, string title)
{
super(w, h, title);
}
View dlang-web-dev-packages.md

D web development package

These are some recommended D web development packages from Dub you may need. These following are choosing because I've either personally used them or they have good documentation.

Any recommendation? Please let me know in the comments.

Web frameworks

  • vibe-d (its like Express.js from Node.js/Javascript)
  • hunt-framework (its like Laravel from PHP)

Json

View nano_gui_demo.d
import std.datetime : Clock;
import std.stdio;
import arsd.simpledisplay;
import arsd.nanovega;
import nanogui.sdlbackend : SdlBackend;
class MyGui : SdlBackend
{
this(int w, int h, string title)
{
You can’t perform that action at this time.