Skip to content

Instantly share code, notes, and snippets.

View TrevorS's full-sized avatar

Trevor Strieber TrevorS

View GitHub Profile
@TrevorS
TrevorS / add_to_zshrc.sh
Created August 27, 2024 02:58 — forked from karpathy/add_to_zshrc.sh
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It:
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# But - just read and edit the code however you like
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/
gcm() {
@TrevorS
TrevorS / casesafe.sh
Created January 4, 2018 18:55 — forked from scottsb/casesafe.sh
Create and manage a case-sensitive disk-image on macOS (OS X).
#!/bin/bash
# ---------------------------------------------------------
# Customizable Settings
# ---------------------------------------------------------
MOUNT_POINT="${CASE_SAFE_MOUNT_POINT:-${HOME}/casesafe}"
VOLUME_PATH="${CASE_SAFE_VOLUME_PATH:-${HOME}/.casesafe.dmg.sparseimage}"
VOLUME_NAME="${CASE_SAFE_VOLUME_NAME:-casesafe}"
VOLUME_SIZE="${CASE_SAFE_VOLUME_SIZE:-60g}"
#! /usr/bin/env ruby
require 'httparty'
require 'csv'
GROUP_ID = 'PUT THE GROUP ID HERE'
BEFORE_ID = 'PUT THE LAST MESSAGE BEFORE ID HERE'
class GroupMe
include HTTParty
@TrevorS
TrevorS / angularjs_directive_attribute_explanation.md
Created August 9, 2016 23:28 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@TrevorS
TrevorS / json_map_builder.ex
Created January 18, 2016 01:56 — forked from rcdilorenzo/json_map_builder.ex
Convert a elixir json-decoded object to a map no matter how deep
defmodule JSONMapBuilder do
def to_map(list) when is_list(list) and length(list) > 0 do
case list |> List.first do
{_, _} ->
Enum.reduce(list, %{}, fn(tuple, acc) ->
{key, value} = tuple
Map.put(acc, binary_to_atom(key), to_map(value))
end)
_ ->
list
#!/usr/bin/env ruby
# encoding: utf-8
random = Random.new
code = ''
4.times { code << random.rand(1..6).to_s }
puts %q(
Can you guess the code?
function slice(object, keys) {
return keys.reduce(function(results, key) {
if (object.hasOwnProperty(key)) {
results[key] = object[key];
}
return results;
}, {});
}
var h = { a: 1, b: 2, c: 3 };
import java.util.stream.IntStream;
public class TestSB {
private static String a = "";
private static String b = "";
private static int iterations = 100000;
private static long start;
16:20:46.812 [error] #PID<0.507.0> running TsfPix.Endpoint terminated
Server: 172.20.9.62:4000 (http)
Request: POST /v1/batches
** (exit) an exception was raised:
** (Plug.Parsers.ParseError) malformed request, got MatchError with message no match of right hand side value: {:error, :timeout}
(plug) lib/plug/parsers/multipart.ex:14: Plug.Parsers.MULTIPART.parse/5
(plug) lib/plug/parsers.ex:186: Plug.Parsers.reduce/6
(tsf_pix) lib/tsf_pix/endpoint.ex:1: TsfPix.Endpoint.phoenix_endpoint_pipeline/1
(tsf_pix) lib/plug/debugger.ex:90: TsfPix.Endpoint."call (overridable 3)"/2
(tsf_pix) lib/phoenix/endpoint/render_errors.ex:34: TsfPix.Endpoint.call/2
curl -o "tsf-api-backup-$(date +%Y-%m-%d).dump" `heroku pg:backups public-url --app tsf-api`