Skip to content

Instantly share code, notes, and snippets.

View emkman's full-sized avatar

Ethan Kravitz emkman

View GitHub Profile
@emkman
emkman / chatgpt.js
Created January 3, 2023 07:29
Diceware generator written by chatGPT
// this was written by chatGPT with coaching and feedback from me. The final output runs without any modification
import fs from 'fs';
import crypto from 'crypto';
// Generate a random five digit number where each digit is between 1 and 6
function generateRandomNumber() {
let number = '';
for (let i = 0; i < 5; i++) {
number += crypto.randomBytes(1).readUInt8(0) % 6 + 1;

Keybase proof

I hereby claim:

To claim this, I am signing this object:

Verifying my Blockstack ID is secured with the address 165g4MmXmGvmhz1ELKfSaiJ5qmhA6hWNDk https://explorer.blockstack.org/address/165g4MmXmGvmhz1ELKfSaiJ5qmhA6hWNDk
@emkman
emkman / time-helpers.swift
Created November 12, 2015 01:49 — forked from maddiesch/time-helpers.swift
Simple implementation of x.hours.ago() and others.
enum FloatToDate {
case Second(Double)
case Minute(Double)
case Hour(Double)
case Day(Double)
case Week(Double)
case Month(Double)
case Year(Double)
func ago() -> NSDate {
@emkman
emkman / ATLConversationViewController.m
Created October 28, 2015 21:49
add custom buttons/views to ATLConversationViewController
- (void)addActionButtons {
CGRect toolbarFrame = self.messageInputToolbar.frame;
int seperatorWidth = 16;
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, -(toolbarFrame.size.height+5), self.view.frame.size.width, 50)];
UIButton *declineButton = [UIButton buttonWithType:UIButtonTypeCustom];
toolbar.backgroundColor = [UIColor colorWithRed:255.0 green:255.0 blue:255.0 alpha:1];
@emkman
emkman / sessions.rb
Created November 26, 2012 13:10
control logic anomaly
# /Users/emkman/.rvm/gems/ruby-1.9.3-p286@cc/gems/mongoid-3.0.14/lib/mongoid/sessions.rb
# line 372
def __session__
if name = session_override #name = nil
Sessions.with_name(name) #goes here
elsif storage_options && name = storage_options[:session]
Sessions.with_name(name)
else
Sessions.default #should go here
end