Skip to content

Instantly share code, notes, and snippets.

View tobischw's full-sized avatar

Tobi Schweiger tobischw

  • Square Inc.
  • 19:10 (UTC -05:00)
View GitHub Profile
@tobischw
tobischw / index.js
Created June 4, 2022 19:01
Automatically generate commit messages based on diffs using GPT-3
// 1. npm init
// 2. npm install -save openai simple-git
// 3. Grab an API key from OpenAI: https://beta.openai.com/account/api-keys
// 4. Replace FOLDER_TO_CHECK with the root path of your git-enabled project
//
// Eventually the goal of this is to have a command line utility that lets users
// generates the commit message and commit immediately.
const { Configuration, OpenAIApi } = require("openai");
const simpleGit = require('simple-git');
@tobischw
tobischw / BinPack.elm
Created April 21, 2020 03:21
2D BinPack in Elm (currently broken)
-- This is just a really basic bin packer that does not allow for automatic resizing (yet)!
-- See: https://codeincomplete.com/articles/bin-packing/
module BinPack exposing (..)
import Dict exposing (Dict)
import List.Extra exposing (..)
import Maybe.Extra exposing (..)
@tobischw
tobischw / copy_dir.dart
Created July 31, 2019 00:19 — forked from thosakwe/copy_dir.dart
Recursively copy directory in Dart (requires "path")
/*
* I'm sure there's a better way to do this, but this solution works for me.
* Recursively copies a directory + subdirectories into a target directory.
* There's also no error handling. Have fun.
*/
import 'dart:io';
import 'package:path/path.dart' as p;
Future<void> copyDirectory(Directory source, Directory destination) async {
@tobischw
tobischw / copy_dir.dart
Last active March 8, 2023 15:32
Recursively copy directory in Dart (requires "path")
/*
* I'm sure there's a better way to do this, but this solution works for me.
* Recursively copies a directory + subdirectories into a target directory.
* You may want to replace calls to sync() with Futures. There's also no error handling. Have fun.
*/
import 'dart:io';
import 'package:path/path.dart' as path;
void copyDirectory(Directory source, Directory destination) =>