Skip to content

Instantly share code, notes, and snippets.

Avatar

Lawrence Aberba aberba

View GitHub Profile
View react-double-range-slider.jsx
import { PRIMARY, PRIMARY_LIGHT, IRON_GREY } from '@styles/variables/colors'
import React, { useEffect, useRef, useState } from 'react'
import styled from 'styled-components'
const Slider = styled.div`
position: relative;
margin: 16px auto;
width: calc(100% - 12px);
height: 8px;
background: ${PRIMARY_LIGHT};
@aberba
aberba / multiple-range-input.html
Created May 19, 2021
HTML5 multiple range input
View multiple-range-input.html
<!-- https://jsfiddle.net/z2ov274f/ -->
<div class="range" id="range">
<input type="range" class="lower" min="0" max="10.5" value="5.0" step="0.5">
<input type="range" class="upper" min="0" max="10.5" value="5.5" step="0.5">
</div>
<div id="lower-val"></div>
<div id="upper-val"></div>
View markdown draft-js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Draft • Decorators</title>
<link rel="stylesheet" href="../../dist/Draft.css" />
</head>
<body>
<div id="target"></div>
<script src="../../node_modules/react/dist/react.js"></script>
@aberba
aberba / RichEditor.js
Created Dec 30, 2020 — forked from paulinep/RichEditor.js
Draft js editor with images and videos
View RichEditor.js
import React, {Component} from 'react'
import ReactDOM from 'react-dom';
import { EditorState, RichUtils,Editor, ContentState, DefaultDraftBlockRenderMap, convertFromHTML, getSafeBodyFromHTML, AtomicBlockUtils, CompositeDecorator} from 'draft-js';
import createImagePlugin from "draft-js-image-plugin";
import './rich-editor.scss'
import * as Immutable from "immutable";
import {stateToHTML} from 'draft-js-export-html';
import {InlineStyleControls, BlockStyleControls} from './StyleButton'
import Svg from 'common/Svg';
import createVideoPlugin from 'draft-js-video-plugin';
@aberba
aberba / app.es6
Last active Dec 30, 2020 — forked from sisodiaa/app.es6
A sample DraftJS editor for adding image
View app.es6
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 Nov 16, 2020 — forked from todbot/hidapi-enum-tst.c
hidapi list devices
View hidapi-enum-tst.c
// 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
//
View hidapi.d
/*******************************************************
HIDAPI - Multi-Platform library for
communication with HID devices.
Alan Ott
Signal 11 Software
8/22/2009
Copyright 2009, All Rights Reserved.
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({});