Skip to content

Instantly share code, notes, and snippets.

View Khauri's full-sized avatar

Khauri Khauri

  • GoTab Inc.
  • Arlington, Virginia
View GitHub Profile
@Khauri
Khauri / index.js
Last active January 3, 2023 14:51
OpenAI Self-Programming in JS
// The guess function reads the current line from the file and returns an ai generated result
// Currently this only works in v8 (ie node) and probably not when using a bundler or modules
// The getCurrentLine function is particularly flimsy.
// inspired by https://mobile.twitter.com/goodside/status/1609436504702717952?cxt=HHwWgMDQ9an-7tUsAAAA
// requires openai module. Run using `node index.js`
import fs from 'fs';
import { Configuration, OpenAIApi } from 'openai';
const configuration = new Configuration({
@Khauri
Khauri / flow.md
Created February 24, 2022 14:34
Integration Flow

Integration Flow

This document is a draft outlining an example of how a third party integrator might use GoTab's publically available APIs to accomplish a variety of tasks.

Obtaining Credentials

At the moment credentials are manually provisioned to partners by GoTab representatives. An integrator should contact a GoTab representative to receive access credentials. In the future credentials may be manageaable by partners after some approval process.

@Khauri
Khauri / README.MD
Created October 25, 2021 23:36
CSS Properties as JS/JSON Arrays And Objects (kebab-cased and camelCased)

CSS properties as JS/JSON arrays and objects in both kebab-cased and camelCased form. Does not include browser prefixed properties. Useful for building tools, ui libraries, static analyzers, etc.

The properties were generated using some simple scripts. If more properties get added, simply copy-paste these scripts into your browser console and you can generate them yourselves.

Array (kebab-cased)

Object.values(getComputedStyle(document.body));
@Khauri
Khauri / readme.md
Last active September 3, 2020 12:09
Migrate Lasso To Webpack

This guide was written a while ago by someone who is neither a webpack or lasso expert. Information here may be incorrect or outdated. If you know/figure out a better way to solve some of these migration problems feel free to leave a comment

This is a guide for migrating a marko project from lasso to webpack. This was created for migrating an express app that directly requires .marko files to render on the server, and thus makes use of a multi-compiler setup to handle .marko file resolution. Your mileage may vary.

Before migrating from lasso to webpack the first thing to realize is that with webpack, everything is intended to be a module, even client-side js. You probably shouldn't write code that assumes the existence of global variables unless they are browser globals OR loaded via a script tag somewhere AND you can guarantee they will load BEFORE they are used.

0. Installl packages

These are the packages that will be used in the webpack configuration below.

@Khauri
Khauri / js-better-variable-indentation.js
Created July 12, 2017 14:35
Maybe it's innovative, maybe I'm a madman. Look closely if you dare to discover an interesting way of indenting variables declared under one declaration.
const
React = require('react'),
ReactDOM = require('react-dom'),
Cookies = require('js-cookie'),
{
BrowserRouter ,
Route ,
Link ,
} = require('react-router-dom'),
// Views
@Khauri
Khauri / hard_stop_rainbow.html
Created July 8, 2017 13:30
CSS hard stop/seperated/no transition rainbow effect using linear-gradient.
<style>
/**
* Classic seperated/hard-stop rainbow effect
* One rainbow takes up the whole background of whatever it's applied to
*/
.rainbow{
background:linear-gradient(to right, red 0, red 14.28%, orange 0, orange 28.57%, yellow 0, yellow 42.86%, green 0, green 57.14%, blue 0, blue 71.42%,indigo 0, indigo 85.71%,violet 0, violet 100%)
}
/**
@Khauri
Khauri / ClassPropsExtend.js
Last active June 30, 2017 14:13
ES6 class properties management using the spread syntax and object.assign (or deep merge strategy).
/**
* An amusing ES6 example for easy class property management using the spread syntax
* (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator)
* and Object.assign.
* This pattern also allows custom properties to be defined at initialization
*/
class Animal{
constructor(...args){
// deep merge function (_.deepExtend) would work as well
Object.assign(