Skip to content

Instantly share code, notes, and snippets.

View dharamgollapudi's full-sized avatar

Dharam Gollapudi dharamgollapudi

  • Atlassian
  • San Francisco Bay Area, CA
View GitHub Profile
@dharamgollapudi
dharamgollapudi / sidekiq_retry_time.csv
Created May 16, 2023 18:21 — forked from marcotc/sidekiq_retry_time.csv
Sidekiq retry exponential backoff formula times
Retry count Retry Time Total Cumulative Time Total Cumulative Days
0 0:00:00 0:00:00 0.0
1 0:00:16 0:00:16 0.0
2 0:00:31 0:00:47 0.0
3 0:01:36 0:02:23 0.0
4 0:04:31 0:06:54 0.0
5 0:10:40 0:17:34 0.0
6 0:21:51 0:39:25 0.0
7 0:40:16 1:19:41 0.1
8 1:08:31 2:28:12 0.1
{
"_type": "export",
"__export_format": 3,
"__export_date": "2018-11-02T17:49:05.621Z",
"__export_source": "insomnia.desktop.app:v6.0.2",
"resources": [
{
"_id": "wrk_566964f3c7d044748b99b8c814e40d8e",
"created": 1538419476867,
"description": "",
@dharamgollapudi
dharamgollapudi / email_header_parser.rb
Created January 5, 2022 05:23 — forked from pmarreck/email_header_parser.rb
Superfast email header parser in Ruby, using regular expressions. This solution is 250 times faster than using the "Mail" gem. :O Time with my regex: 0.063965 seconds Time with Mail gem: 16.327161 seconds Note that I included some encoding-fix code. YMMV and encoding fixes are all debatable or fail in some corner case.
require 'ap'
require 'mail'
# String monkeypatch
# This is one of many possible "encoding problem" solutions. It's actually an intractable problem
# but you'd have to read "Gödel, Escher, Bach" to understand why...
class String
def clean_utf8
# self.force_encoding("UTF-8").encode("UTF-16BE", :invalid=>:replace, :replace=>"?").encode("UTF-8")
unpack('C*').pack('U*') if !valid_encoding?
@dharamgollapudi
dharamgollapudi / Validators.kt
Created October 3, 2021 21:06 — forked from vbsteven/Validators.kt
Custom Spring annotation and validator in Kotlin
package io.license.core.validation
import javax.validation.Constraint
import javax.validation.ConstraintValidator
import javax.validation.ConstraintValidatorContext
import javax.validation.Payload
import kotlin.reflect.KClass
@Target(AnnotationTarget.FIELD)
@dharamgollapudi
dharamgollapudi / TAO.md
Created March 28, 2021 23:43 — forked from shagunsodhani/TAO.md
Notes on TAO: Facebook’s Distributed Data Store for the Social Graph

TAO

  • Geographically distributed, read-optimized, graph data store.
  • Favors availability and efficiency over consistency.
  • Developed by and used within Facebook (social graph).
  • Link to paper.

Before TAO

  • Facebook's servers directly accessed MySQL to read/write the social graph.
@dharamgollapudi
dharamgollapudi / audit_globalize.md
Created October 20, 2019 16:54 — forked from maxivak/audit_globalize.md
Rails: Audit Globalize translations
  • Globalize adds model translations to ActiveRecord models.
  • Audited is an ORM extension that logs all changes to your models.

Using Audited gem it will only logs changes to the base model and ignore changes to the translation table.

Below is how to add audited to the translation model.

Audited and Globalize

@dharamgollapudi
dharamgollapudi / Dockerfile
Created October 1, 2018 03:40 — forked from anonoz/Dockerfile
Sample of multistage Dockerfile for Rails app in production
FROM madnight/docker-alpine-wkhtmltopdf as wkhtmltopdf_savior
# STAGE for bundle & yarn install
FROM ruby:2.4.3-alpine3.7 as builder
ENV CA_CERTS_PATH /etc/ssl/certs/
ENV RAILS_ENV production
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_SERVE_STATIC_FILES true
@dharamgollapudi
dharamgollapudi / convertjsoncsv.rb
Created July 19, 2018 19:44 — forked from jordan-thoms/convertjsoncsv.rb
Code to convert json to csv, with correct headings Usage: ruby convertjsoncsv.rb <input file> <output file>
require 'csv'
require 'json'
require "set"
json = JSON.parse(File.open(ARGV[0]).read)["results"]
# Pass 1: Collect headings
headings = SortedSet.new
json.each do |hash|
headings.merge(hash.keys)
end
#!/usr/bin/env ruby
require 'csv'
require 'json'
if ARGV.size != 2
puts 'Usage: csv_to_json input_file.csv output_file.json'
puts 'This script uses the first line of the csv file as the keys for the JSON properties of the objects'
exit(1)
end
@dharamgollapudi
dharamgollapudi / benchmark.rb
Created May 21, 2018 06:58 — forked from PragTob/benchmark.rb
Ruby flat_map vs. map.flatten
require 'benchmark/ips'
Benchmark.ips do |bm|
list = (0..10_000).to_a
bm.report "flat_map" do
list.flat_map do |x|
[x, x * x]
end
end