Skip to content

Instantly share code, notes, and snippets.

View leftis's full-sized avatar

Lefteris Georgatos leftis

View GitHub Profile
@leftis
leftis / deploy.rb
Created August 12, 2012 15:10
RailsPlayground vps deploy.rb
# Capistrano deploy.rb for rails playground vps
# with support for bundles and assets pipeline
require "bundler/capistrano"
set :ip_address, "vps ip address"
set :scm_username , "scm_account_name"
set :scm, :git
set :application, "application name"
set :repository, "application repo"
@leftis
leftis / Preferences.sublime-settings
Created August 22, 2012 08:24
Sublime user settings
{
"color_scheme": "Packages/Color Scheme - Default/Monokai Soda.tmTheme",
"font_face": "DEJA VU SANS MONO",
"font_size": 9,
"font_options": [],
"word_separators": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?",
"line_numbers": true,
"gutter": true,
"margin": 0,
"fold_buttons": true,
@leftis
leftis / Preferences.sublime-settings
Created August 22, 2012 08:24
Sublime preferences
{
"color_scheme": "Packages/Color Scheme - Default/Monokai Soda.tmTheme",
"font_face": "DEJA VU SANS MONO",
"font_size": 9,
"font_options": [],
"word_separators": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?",
"line_numbers": true,
"gutter": true,
"margin": 0,
"fold_buttons": true,
@leftis
leftis / padder.rb
Created August 23, 2012 10:38
Image with padding for paperclip versions 2.3.1.1
module Paperclip
class Padder < Thumbnail
def transformation_command
trans = []
trans << " -gravity center"
trans << " -background white"
trans << " -extent " << %["#{geometry_extent}"]
trans = trans.flatten.compact.join(" ")
super << trans
end
@leftis
leftis / login.rb
Created October 9, 2012 08:19
failed_login
Processing Admin::SessionsController#create (for 127.0.0.1 at 2012-10-09 11:16:16) [POST]
Parameters: {"login"=>"", "password"=>"", "commit"=>"Σύνδεση", "authenticity_token"=>"ML6asic2E+emsp/DyCcNxMF9MKJse5Auyi9DwKuyujI="}
Access Columns (0.7ms) SHOW FIELDS FROM `accesses`
SQL (0.3ms) SELECT count(*) AS count_all FROM `accesses` WHERE (`accesses`.`client_ip` = '127.0.0.1' AND `accesses`.`user_id` IS NULL)
User Load (0.3ms) SELECT * FROM `users` WHERE (`users`.`login` = 'god') LIMIT 1
CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`login` = 'god') LIMIT 1
CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`login` = 'god') LIMIT 1
Access Load (0.3ms) SELECT * FROM `accesses` WHERE (`accesses`.`client_ip` = '127.0.0.1' AND `accesses`.`user_id` IS NULL) ORDER BY accesses.id DESC LIMIT 1
roles_users Columns (0.7ms) SHOW FIELDS FROM `roles_users`
Role Load (0.4ms) SELECT * FROM `roles` INNER JOIN `roles_users` ON `roles`.id = `roles_users`.role_id WHERE (`roles_users`.user_id
require 'open-uri'
require 'pp'
require 'json'
require 'ostruct'
class FoursquareApiParser
attr_accessor :response
def initialize(url)
@response = JSON.load(open(url))["response"]
.absolute-center {
display:-ms-flexbox;
-ms-flex-pack:center;
-ms-flex-align:center;
/* Firefox */
display:-moz-box;
-moz-box-pack:center;
-moz-box-align:center;
# require 'net/ftp'
require 'nokogiri'
module Orbit
mattr_accessor :folder, :file
DEFAULT_OPTIONS = {
:folder => Pathname.new( Rails.public_path + '/orbit'),
:file => 'orbit.xml'
def pdf_image_tag(image, options = {})
options[:src] = File.expand_path(RAILS_ROOT) + '/public' + image.split('?').first
Rails.logger.info "IMAGE_PATH: #{options[:src]}"
tag(:img, options)
end
def media_to_pdf
if project_have_media
ac = ActionController::Base.new
Number.prototype.ordinate = function(){
var num = this,
numStr = num.toString(),
last = numStr.slice(-1),
len = numStr.length,
ord = '';
switch (last) {
case '1':
ord = numStr.slice(-2) === '11' ? 'th' : 'st';
break;