Skip to content

Instantly share code, notes, and snippets.

@rshiva
rshiva / mail.rb
Last active September 15, 2022 06:29
class UserMailer < ApplicationMailer
default from: "[email protected]"
def send_to_kindle((kindle_mail, file_name, file_path)
attachments["#{file_name}"] = File.read(file_path)
mail(to: kindle_mail,
subject: "Send",
mime_type: 'application/x-mobipocket-ebook'
@rshiva
rshiva / encrypt_decrypt.rb
Created November 2, 2020 05:11 — forked from 0sc/encrypt_decrypt.rb
Simple encrypt decrypt strings in ruby
require 'openssl'
def encrypt_string(str)
cipher_salt1 = 'some-random-salt-'
cipher_salt2 = 'another-random-salt-'
cipher = OpenSSL::Cipher.new('AES-128-ECB').encrypt
cipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(cipher_salt1, cipher_salt2, 20_000, cipher.key_len)
encrypted = cipher.update(str) + cipher.final
encrypted.unpack('H*')[0].upcase
end
@rshiva
rshiva / logstash_csv_to_elasticsearch.conf
Created July 2, 2020 19:00
Convert csv data to elasticsearch
input {
file {
path => "file_name.csv"
start_position => "beginning"
sincedb_path => "/tmp/mysincedbfile"
}
}
filter {
csv {
separator => ","
@rshiva
rshiva / ladder.md
Created June 13, 2020 19:35 — forked from jamtur01/ladder.md
Kickstarter Engineering Ladder
@rshiva
rshiva / logstash_elasticsearch_data_to_csv.conf
Last active June 11, 2020 13:47
Logstash configuration to convert elasticsearch data to csv with metadata
#bin/logstash-plugin install logstash-input-elasticsearch
#bin/logstash-plugin install logstash-output-csv
input {
elasticsearch {
hosts => "localhost:9200"
index => "shop_inventory*"
scroll => "5m"
docinfo => true
query => '{ "query": {"match_all": {} }}'
@rshiva
rshiva / System Design.md
Created April 21, 2019 16:41 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
<!DOCTYPE html>
<html lang="en">
<head>
<title>Welcome to Nginx</title>
</head>
<body>
<h1> Hello World</h1>
<p> This is static page served using nginx. </p>
</body>
@rshiva
rshiva / 0-startup-overview.md
Created January 14, 2019 06:54 — forked from dideler/0-startup-overview.md
Startup Engineering notes

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

pip install selenium #install selenium Driver
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
for i in range(100): #100 times it will run in loop
driver = webdriver.Firefox()
driver.get("https://www.youtube.com/watch?v=37dnlvHfZjE") #paste the url link which you want to see certain number of times