Skip to content

Instantly share code, notes, and snippets.

View dcalixto's full-sized avatar
🎯
Focusing

Daniel dcalixto

🎯
Focusing
View GitHub Profile
@dcalixto
dcalixto / gist:650c86e96fcc74ff34c9f33ecfd76310
Created November 13, 2016 05:51 — forked from jendiamond/gist:6128723
Creating your own Gem & Command Line Interface Using Bundler

Presentation slides

Create a Gem - Make it a CLI - Add Rspec Tests

Create a Gem - Make it a Command Line Interface - Add Rspec Tests Using Bundler & Thor

#Creating your own Gem

  1. Run this command in your Terminal. This creates and names all the files you need for your gem. We are going to create a Lorem Ipsum Generator; you can call it whatever you want but seeing as we are creating a Lorem Ipsum generator we'll call it lorem. Read about gem naming conventions.

Cheatsheets

NetworkOptions

@author Tim Fox
@dcalixto
dcalixto / double_polymorphism.rb
Created November 18, 2016 02:36 — forked from gerred/double_polymorphism.rb
Doubly Polymorphic Join Models, for fun and profit
class Delivery < ActiveRecord::Base
belongs_to :deliverable, :polymorphic => true
belongs_to :receivable, :polymorphic => true
has_many :delivery_impressions
has_many :users, :through => :delivery_impressions
belongs_to :sender, :class_name => 'User', :foreign_key => :sender_id
end
class DeliveryImpression < ActiveRecord::Base
apt-get -y update
apt-get -y install curl git-core python-software-properties
# nginx
add-apt-repository ppa:nginx/stable
apt-get -y update
apt-get -y install nginx
service nginx start
Introduction
There is nothing quite like reading your (ssh) logs to instil a healthy dose of paranoia. While ssh is a powerful tool, it is a common target for "script kiddies" .
In this tutorial I will show you several methods to help increase the security of your ssh server. My preference is to start with tools already available with a default installation and I personally tend to avoid additional services, such as denyhosts or fail2ban.
I advise you start with proper configuration of the ssh server (sshd_config) and next take a look at ssh key authentication, TCPWrapper, and use of a firewall.
I will cover additional services (denyhosts/fail2ban) last.
~/Downloads$ sudo rm /etc/apt/sources.list.d/upubuntu-com-ppa-trusty*
rm: cannot remove ‘/etc/apt/sources.list.d/upubuntu-com-ppa-trusty*’: No such file or directory
smartron@Ubuntu1:~/Downloads$ cd /etc/apt/sources.list.d
smartron@Ubuntu1:/etc/apt/sources.list.d$ ls -la
-rw-r--r-- 1 root root 150 Jul 18 22:06 openshot_developers-ppa-trusty.list
-rw-r--r-- 1 root root 150 Jul 18 22:06 openshot_developers-ppa-trusty.list.save
smartron@Ubuntu1:/etc/apt/sources.list.d$ sudo rm openshot_developers-ppa-trusty.list
smartron@Ubuntu1:/etc/apt/sources.list.d$ sudo rm openshot_developers-ppa-trusty.list.save
sudo apt-get update (results look good to me - no errors)
sudo apt-get remove gdal-bin
@dcalixto
dcalixto / fine tune ubuntu 14
Created February 4, 2017 07:40
fine tune ubuntu 14
How to Performance Tune Ubuntu 14.04 LTS Trusty in AWS EC2
October 28, 2015
This article will explain how to performance tune Ubuntu 14.04 LTS Trusty in Amazon Web Services EC2. Building a good base AWS AMI is important and if your using Ubuntu 14.04 this will hopefully be of some help.
Step 0
Time Matters! Make sure you have NTP installed otherwise do the following:
sudo apt-get update
@dcalixto
dcalixto / deploy.rb
Created February 11, 2017 01:39
private_pub capistrano tasks
namespace :private_pub do
desc "Start private_pub server"
task :start do
run "cd #{current_path};RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -E production -D -P tmp/pids/private_pub.pid"
end
desc "Stop private_pub server"
task :stop do
run "cd #{current_path};if [ -f tmp/pids/private_pub.pid ] && [ -e /proc/$(cat tmp/pids/private_pub.pid) ]; then kill -9 `cat tmp/pids/private_pub.pid`; fi"
end
@dcalixto
dcalixto / nginx-tuning.md
Created February 11, 2017 14:06 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.