Skip to content

Instantly share code, notes, and snippets.

@mitio
mitio / check_for_late_commits.rb
Last active August 29, 2015 13:56
Quick scripts to help me grade hw 05 for the "Programming Ruby" course -- http://2013.fmi.ruby.bg/tasks/5
require 'time'
task_ends_at = '2014-01-22 17:30:00 +200'
late_commits_unix_timestamp = Time.parse(task_ends_at).utc.to_i
def commit_timestamp_of(commit_line)
commit_line.split(/\s+/).first.to_i
end
@mitio
mitio / test-direct-http-request-to-passenger
Created March 10, 2014 21:33
A quick script to call a Phusion Passenger process directly to assist in debugging server issues.
#!/usr/bin/env ruby
status = `passenger-status -v --show=xml`
pid_to_show = ARGV.first
processes = {}
def extract(tag_name, xml)
if xml =~ /<#{tag_name}>(.*?)<\/#{tag_name}>/s
$1.to_s.strip
@mitio
mitio / .gitignore
Last active August 29, 2015 13:57
"Quick" script to generate an example schedule for the Rails Girls study groups
.DS_Store
*.csv
@mitio
mitio / README.md
Last active August 29, 2015 14:01
A custom Capistrano 3.x strategy that allows deployment from a Git subfolder

You can use this strategy to deploy your Rails app properly when it's located in a subfolder in the main repo.

Supports Capistrano 3.x (tested on 3.2.1).

Usage

  1. Place this file in lib/capistrano/git_subfolder_strategy.rb
  2. Add this line to your Capfile: require_relative 'lib/capistrano/git_subfolder_strategy'
  3. In your deploy.rb, set the following:
@mitio
mitio / rock_paper_scissors_web.rb
Created May 27, 2014 22:04
Rock-paper-scissors implemented in Sinatra
require 'sinatra'
before do
content_type :txt
@moves = {rock: :scissors, paper: :rock, scissors: :paper}
end
get '/play/:move' do
# Be wary when calling #to_sym on random strings!
player_move = params[:move].to_sym
MRuby::Build.new do |conf|
# load specific toolchain settings
toolchain :gcc
# Use mrbgems
# conf.gem 'examples/mrbgems/ruby_extension_example'
# conf.gem 'examples/mrbgems/c_extension_example' do |g|
# g.cc.flags << '-g' # append cflags in this gem
# end
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
@mitio
mitio / ip-of
Created July 13, 2014 14:09
Resolves a hostname and copies the A DNS record to the clipboard. OS X only.
#!/bin/bash
HOST="$1"
echo "Looking up $HOST..."
IP=`dig $HOST +short`
echo -n $IP | pbcopy
echo "Copied $IP to the clipboard."
require 'csv'
CSV.read('file.csv', headers: true).each { |row| row['име на колонката от хедъра'] }
@mitio
mitio / europe_code_week_baruco_2014.md
Last active August 29, 2015 14:06
Europe Code Week, Baruco 2014 Lightning Talk

Europe Code Week 2014

By coming up on this stage, I'm making the assumption that there is a fair amount of people in the audience who like coding and who believe that to be able to code is a very valuable skill. I know for sure that some of you are really passionate about sharing what you know with others. I really like programming communities, and the Ruby community in particular, in that we're pretty open and friendly to newcomers and pretty eager to share our passions and knowledge with them. I've learned a lot this way and I think that's what keeps us moving forward with great speed.

If you agree with me, then I think you'd be interested to get involved in the upcoming Europe Code Week.

The second edition of Code Week will be held this year, from the 11th to the 17th of October. It's a great initiative launched by the Neelie Kroes' Young Advisors with some involvement from the European Commission. It's about spreading the

@mitio
mitio / smart_cities_and_smart_governments_dad2014.md
Last active August 29, 2015 14:07
Smart cities and smart governments; panel discussion during Digital Action Day 2014

Digital Cities And Governments

Public sector and cities also go digital:

What are the solutions for smart government and smart cities?

A work panel discussion, part of Digital Action Day 2014, Brussels, Belguim.

smart cities and governments - dad 2014