Skip to content

Instantly share code, notes, and snippets.

View sagarkt's full-sized avatar
🧩
building....

Sagar Kamble sagarkt

🧩
building....
  • Pune
View GitHub Profile
@torsten
torsten / proxy.rb
Last active April 30, 2024 17:53
A quick HTTP proxy server in Ruby.
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009-2014 Torsten Becker <torsten.becker@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
@uhlenbrock
uhlenbrock / deploy.rb
Created December 14, 2011 17:36
Precompile assets locally for Capistrano deploy
load 'deploy/assets'
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
%x{bundle exec rake assets:precompile}
%x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}}
%x{bundle exec rake assets:clean}
end
@JoshTGreenwood
JoshTGreenwood / bench.rb
Created November 21, 2012 00:14
Benchmark break vs. catch-throw vs. begin-rescue-end in ruby
require 'benchmark'
Benchmark.bmbm do |x|
x.report('Break') do
1_000_000.times do
break
end
end
@ryansobol
ryansobol / gist:5252653
Last active November 22, 2023 11:53
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@thoop
thoop / .htaccess
Last active January 27, 2024 14:07
Official prerender.io .htaccess for Apache.
# Change YOUR_TOKEN to your prerender token
# Change http://example.com (at the end of the last RewriteRule) to your website url
<IfModule mod_headers.c>
RequestHeader set X-Prerender-Token "YOUR_TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
require 'sidekiq'
require 'autoscaler/sidekiq'
require 'autoscaler/heroku_scaler'
heroku = nil
if ENV['HEROKU_APP']
heroku = Autoscaler::HerokuScaler.new
end
Sidekiq.configure_server do |config|
@pokle
pokle / Dockerfile
Created April 16, 2014 04:45
Run ssh server inside a Centos/Redhat Docker container
# ssh server
# Don't forget to run '/usr/sbin/sshd -D' if you actually want to ssh into this container
RUN yum install -y openssh-server
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
ADD src/sshd/sshd_config /etc/ssh/sshd_config
RUN echo root:welcome1 | chpasswd
@ddluc
ddluc / app.js
Last active March 20, 2018 11:42
OOP in AngularJS
/**
* OOP in AngularJS
*
* The following implements some pseudo code for a Video Blog Application using both AngularJS'
* Dependency Injection and 'Classical' Javascript Prototypal Inheritance.
*
* Recently I've decided to use a more 'Classical' Javascript design pattern. My reasoning for this
* decision was based mostly on 2 factors:
*
* 1. Using classes allows you to create code that is reusable and DRY. This is especially helpful
# lib/capistrano/tasks/assets.rake
Rake::Task['deploy:assets:precompile'].clear
namespace :deploy do
namespace :assets do
desc 'Precompile assets locally and then rsync to remote servers'
task :precompile do
local_manifest_path = %x{ls public/assets/manifest*}.strip
@rkjha
rkjha / nginx-config-rails4-with-puma-ssl-version.conf
Last active November 2, 2023 11:57
Nginx config for rails 4 application using puma [ssl and non-ssl version]
upstream myapp_puma {
server unix:/tmp/myapp_puma.sock fail_timeout=0;
}
# for redirecting to https version of the site
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}