Skip to content

Instantly share code, notes, and snippets.

View ksafranski's full-sized avatar

Kent Safranski ksafranski

View GitHub Profile
import os
import requests
import json
from pathlib import Path
from openai import OpenAI, openai
from datetime import datetime, timedelta
import asyncio
# Assuming OpenAI Python client is already installed, configured with API key
openai.api_key = os.getenv('OPEN_AI_API_KEY')
@ksafranski
ksafranski / get.spec.ts
Created August 18, 2023 19:03
Lodash `get` alternative
describe('get', () => {
it('return undefined on non-existent key', () => {
const res = get({ hello: 'world' }, 'foo');
expect(res).toBeUndefined();
});
it('returns key when nested', () => {
const res = get({ hello: { world: false } }, 'hello.world');
expect(res).toEqual(false);
});
});
/**
* Function for converting arbitrarily nested arrays into a single, flat array
* @param {Array} arr
* @returns {Array}
*/
function flatDeep (arr) {
if (!Array.isArray(arr)) throw new Error('Expected type `Array`')
return arr.reduce((acc, el) => acc.concat(Array.isArray(el) ? flatDeep(el) : el), [])
}
FROM mhart/alpine-node:8.9
# Dependencies
RUN apk --no-cache add --virtual builds-deps build-base python vim
# Specify pgweb version
ENV PGWEB_VERSION=0.9.12 \
PGWEB_USER=pgweb \
PGWEB_DIR=/app/pgweb
#!/bin/sh
sudo xrandr --newmode "2560x1080_60.00" 230.00 2560 2720 2992 3424 1080 1083 1093 1120 -hsync +vsync
sudo xrandr --addmode HDMI-1 "2560x1080_60.00"
import { observable, computed, action } from 'mobx'
import TodoModel from './TodoModel'
export default class TodoListModel {
@observable todos = []
constructor () {
try {
this.todos = JSON.parse(window.localStorage.getItem('todos'))

Using Git

This document is a quick-start dive into using Git for version control, branching, and collaborative work on projects. It is intended to be a primer on core concepts. For more information, see the Git Docs.

Authentication

The best way to use Git + Github (or any Git hosting) is via SSH. To do this you need an SSH Key (Mac/Linux):

ssh-keygen
@ksafranski
ksafranski / README.md
Last active September 25, 2017 01:19
Slecret - Slack Secret

Slecret

Add a Slash command to easily share secrets on Slack.

Setup

There are three components to using this Webtask

1. Create Redis Instance on RedisLabs

hello

Click to expand whatever
/* global: indexedDB, IDBKeyRange */
// index.js
// Provides easy interaction with indexedDB
// ---
// Part of the Riggr SPA framework <https://github.com/Fluidbyte/Riggr> and released
// under the MIT license. This notice must remain intact.
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {