Skip to content

Instantly share code, notes, and snippets.

View sriharshakappala's full-sized avatar
🎯
Focusing

Sri Harsha Kappala sriharshakappala

🎯
Focusing
View GitHub Profile
@nikhita
nikhita / install-firacode.sh
Created April 24, 2017 17:32
How to install FiraCode font on Linux
mkdir -p ~/.local/share/fonts
for type in Bold Light Medium Regular Retina; do wget -O ~/.local/share/fonts/FiraCode-$type.ttf "https://github.com/tonsky/FiraCode/blob/master/distr/ttf/FiraCode-$type.ttf?raw=true"; done
fc-cache -f
@TheDeveloper
TheDeveloper / http-aws-es.es6.js
Last active March 31, 2021 09:27
Use the Node elasticsearch client with Amazon ES
/**
* A Connection handler for Amazon ES.
*
* Uses the aws-sdk to make signed requests to an Amazon ES endpoint.
* Define the Amazon ES config and the connection handler
* in the client configuration:
*
* var es = require('elasticsearch').Client({
* hosts: 'https://amazon-es-host.us-east-1.es.amazonaws.com',
* connectionClass: require('http-aws-es'),
@seyhunak
seyhunak / apache_bench.sh
Last active July 5, 2023 17:02
Rails - Apache Bench - Load Testing (if Devise Sign-in Required)
1.
LOGIN_PAGE=http://localhost/users/sign_in
curl --cookie-jar cookie_file $LOGIN_PAGE | grep csrf-token
2.
<meta content="csrf-token" name="csrf-token" />
@harssh-sparkway
harssh-sparkway / dry.rb
Last active July 7, 2022 23:33
Don’t Repeat Yourself (DRY) in Ruby on Rails
#Don’t Repeat Yourself (DRY) in Ruby on Rails
#DRY (Don’t Repeat Yourself) is a principle of Software Development to reducing repetition of information or codes. We can #apply DRY quite broadly to database schema, test plan, system, even documentation. And in this post, we will take example of DRY #in Ruby on Rails development.
#In particular case, if you find some methods whose definitions are more or less similar, only different by the method name, it #may use meta programming to simplify the things to make your model more clean and DRY. Consider this simple example where we #have an article with three states.
#Before
class Article < ActiveRecord::Base
@havenwood
havenwood / producer-consumer.rb
Created May 14, 2013 01:14
Producer-consumer problem in Ruby with SizedQueue
require 'thread'
class ProducerConsumer
def initialize producers = 5, consumers = 5, queue_size = 5
@producers, @consumers = producers, consumers
@queue = SizedQueue.new queue_size
@mutex = Mutex.new
@threads = []
end