Skip to content

Instantly share code, notes, and snippets.

View kaiwren's full-sized avatar

Sidu Ponnappa kaiwren

View GitHub Profile
@kaiwren
kaiwren / client.rb
Created June 28, 2023 07:43
Open AI API Access in Ruby
# gem 'wrest' in Gemfile
# optionally, `Wrest.logger = Rails.logger` in `config/initializers/wrest.rb`
module OpenAI
def self.base_uri
'https://api.openai.com/v1'.to_uri(
default_headers: {
'Content-Type' => 'application/json',
'Authorization' => "Bearer #{ENV.fetch('OPENAI_KEY', nil)}"
@kaiwren
kaiwren / jira_csv_report.rb
Created September 6, 2022 18:21
Generate a simple summary from a Jira full excel CSV export
require 'csv'
csv_file = ARGV[0]
def section_heading(title)
"\n#{'-' * 10} #{title} #{'-' * 10}\n\n"
end
rows = CSV.read(csv_file)[1..-1].map do |r|
created_at = DateTime.parse(r[21])
@kaiwren
kaiwren / net_http_debug.rb
Created September 22, 2010 12:48
Enable debug for all Ruby HTTP requests
require 'net/http'
module Net
class HTTP
def self.enable_debug!
raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development'
class << self
alias_method :__new__, :new
def new(*args, &blk)
instance = __new__(*args, &blk)
instance.set_debug_output($stderr)
Can Code Can't Code
Loves Coding Yes N/A
Hates Coding Maybe No
@kaiwren
kaiwren / gist:1283905
Created October 13, 2011 10:13
Steve Yegge's SOA post
From: https://raw.github.com/gist/933cc4f7df97d553ed89/24386c6a79bb4b31fb818b70b34c5eab7f12e1ff/gistfile1.txt
Stevey's Google Platforms Rant
I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.
I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various effort
// We're going to pick on Mad Service today. If you had a hand in writing this once upon a time, do not fret.
// This isn't accusation or finger-poiniting -- I see everyone's name all over this code, including my own, which
// makes it a nice target.
// This code just needs some tenderness. Let's cook it a hot bowl of soup and play some soft Jazz.
type Operation struct {
timeValue time.Time
s2IDLevel int64
s2ID int64
// ...
// ...
}
func (op operation) Perform() error {
surgeRepository := repository.NewSurgeRepository()
type Operation struct {
timeValue time.Time
s2IDLevel int64
s2ID int64
// ...
// ...
}
func (op operation) Perform(surgeRepository repository.SurgeRepository) error {
// ...
type Operation struct {
timeValue time.Time
s2IDLevel int64
s2ID int64
// ...
// ...
}
func (op operation) Perform(surgeRepository repository.SurgeRepository) error {
// ...
Problem: Why should I get out of bed?
Answer: Because I need to work to support the people I care about. This includes your own time (to spend with them), food, housing, simple luxuries and top-notch healthcare. I personally need between two and five crores in today's money in the bank for this. (INR Five crores == USD ~1 million).
Problem: Ok, you've made that much money. Now why should you get out of bed?
Answer: Well, now it's just your own fulfillment. Boredom is the enemy. Why think small? Cure death. Produce unlimited energy.
Problem: But this takes resources.