Skip to content

Instantly share code, notes, and snippets.

@harssh
harssh / nano_text_editor_cmds.txt
Created November 25, 2013 08:34
Commands for nano text editor
Useful Nano Keyboard Commands
Since the nano editor doesn't really support the use of a mouse, here's a table of commands you're likely to find very useful. You should experiment with every one of them and try to memorize them, it can speed up your work tremendously. (To see a list of all nano commands, type Ctrl+g when in the editor.)
NOTE: There is no “undo” command in nano, so save your work often!
Topics
@harssh
harssh / usefull_links.txt
Last active December 29, 2015 07:49
usefull links
@harssh
harssh / checkbox_styling.html
Last active December 29, 2015 16:59
Changing dtyle of checkbox and radio buttons
Styling checkboxes and radio buttons using CSS
The styling of checkboxes and radio buttons became possible with the introduction of the :checked pseudo-class in CSS3. This page describes two techniques: an image-based method, shown in the demonstration below, and a pure CSS method.
Image-based styling
Image-based styling allows the greatest flexibility in appearance. In the example above we combine the images for the three states (unchecked, selected checkbox, and selected radio button) into a single image for faster loading:
HTML of the following form is used for each checkbox or radio button:

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.

require 'action_dispatch/middleware/static'
module Middleware
class FileHandler < ActionDispatch::FileHandler
def initialize(root, assets_path, cache_control)
@assets_path = assets_path.chomp('/') + '/'
super(root, cache_control)
end
def match?(path)
@harssh
harssh / add_to_gem.rb
Created February 8, 2014 15:50
7 Lines Every Gem's Rakefile Should Have
#Add these 7 lines to your project's Rakefile:
task :console do
require 'irb'
require 'irb/completion'
require 'my_gem' # You know what to do.
ARGV.clear
IRB.start
end
#!/usr/bin/env ruby
require 'gosu' # gem install gosu
$width, $height = 200, 200
$number_of_v_lines,$number_of_h_lines = 10, 10
$chars = ('a'..'z').to_a
class Entity
def initialize(x,y,vel, win)
@pos, @vel = {x:x, y:y}, vel
@harssh
harssh / ruby_hash_use_case.rb
Created March 18, 2014 05:04
7 daily use cases of Ruby Hash
1. How to convert a JSON into a Hash?
You’ve just retrieved a Twitter profile as a JSON:
data = '{
"name": "Aaron Patterson",
"screen_name": "tenderlove",
"location": "Seattle, WA"
}'
You want to transform it as a Hash for easier data manipulation:
@harssh
harssh / sql_notificcation.rb
Last active August 29, 2015 14:00
Log all sql queries in rails
logger = Logger.new("#{Rails.root}+/log/sql.log",'daily') # create new logger
logger.datetime_format = "%Y-%m-%d %H:%M:%S"
logger.formatter = proc do |severity, datetime, progname, msg|
"#{datetime}: #{msg}\n"
end
ActiveSupport::Notifications.subscribe("sql.active_record") do |_, _, _, _, details| # subscribe to active support notification
if details[:sql] # check if SQL query exists
logger.info(details[:sql])
end
end
@harssh
harssh / nginx-config-spdy-example
Created April 21, 2014 06:26 — forked from loopj/nginx-config-spdy-example
Nginx SPDY configuration
server {
listen 443 ssl spdy default_server;
server_name example.com;
ssl_certificate /etc/ssl/certs/my.ssl.crt;
ssl_certificate_key /etc/ssl/private/my.ssl.key;
root /mysite/current/public;
passenger_enabled on;