Skip to content

Instantly share code, notes, and snippets.

View regedarek's full-sized avatar
🏠
Working from home

Darek Finster regedarek

🏠
Working from home
View GitHub Profile
@regedarek
regedarek / gist:1643261
Created January 19, 2012 22:21
Chcę aby po kliknięciu w Fast Verification, a następnie Verify aby redirect_to było do ostatniego niezweryfikowanego ogłoszenia.
#verifications/index.haml
- unless @ads.unverified_ads.empty?
= link_to "Szybka Weryfikacja", fast_verify_info_verification_path(@ads.unverified_ads.last), :method => :put
= link_to "Ogłoszenia do zweryfikowania", verifications_path(:scope => "unverified_ads")
= @ads.unverified_ads.count
= link_to "Normal Verify", verify_info_verification_path(ad), :method => :put
#verifications/verify_info.haml
= link_to "Verify", verify_verification_path(@ad)
#verifications/fast_verify_info.haml
@regedarek
regedarek / gist:1653215
Created January 21, 2012 16:28
Prosty bot do wysylania wiadomości regularnie na jakiś kanał.
# muzang_instance.rb
require 'muzang'
require 'muzang-plugins'
class SendMessageToChannel
include Muzang::Plugins::Helpers
def initialize(bot)
@bot = bot
end
- unless @unconfirmed_ads.empty? # którą wersję wybrać?
- unless Ad.unconfirmed_empty? # metoda w modelu - Tak miałem do tej pory, wg wskazówek :)
= link_to "Szybka Weryfikacja", verification_path(@last_unverified_ad), :method => :put
= link_to "Ogłoszenia do zweryfikowania", verifications_path(:scope => "unverified_ads")
[
= @unverified_count # tak wydaje się nienajlepszą opcją
]
= link_to "Ogłoszenia potwierdzone", verifications_path(:scope => "confirmed_ads")
[
Show
You can show the structure of the groups and their Guards with the show task:
$ guard show
(global):
shell
Group backend:
bundler
@regedarek
regedarek / file_uploader.rb
Created January 26, 2012 23:42
CarrierWave
# encoding: utf-8
class FileUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :file
def store_dir
"photos/#{model.attachable_id}"
end
@regedarek
regedarek / gist:1689561
Created January 27, 2012 16:16
tabela users w wersji dla sqlite
CREATE TABLE users (
id INTEGER PRIMARY KEY,
user_login text NOT NULL DEFAULT '',
user_pass text NOT NULL DEFAULT '',
user_nicename text NOT NULL DEFAULT '',
user_email text NOT NULL DEFAULT '',
user_url text NOT NULL DEFAULT '',
user_registered datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
user_activation_key text NOT NULL DEFAULT '',
user_status integer NOT NULL DEFAULT '0',
@regedarek
regedarek / hkshop.rb
Created January 28, 2012 15:40
Warden + md5
%w[rubygems digest/md5 sinatra haml sass warden rack/flash ./db/database].each{ |gem| require gem }
require "sinatra/reloader" if development?
set :root, File.dirname(__FILE__)
set :views, "views"
get '/main.css' do
header 'Content-Type' => 'text/css; charset=utf-8'
sass :main
@regedarek
regedarek / hkshop.rb
Created January 28, 2012 19:42
Warden + Sinatra
%w[rubygems digest/md5 sinatra sinatra/reloader haml sass warden rack/flash sinatra/activerecord].each{ |gem| require gem }
set :root, File.dirname(__FILE__)
set :views, "views"
get '/main.css' do
header 'Content-Type' => 'text/css; charset=utf-8'
sass :main
end
@regedarek
regedarek / rezerwacja
Created January 29, 2012 19:34
System rezerwacji przedmiotów do klubu turystycznego
Aplikacja(w sinatrze pisana) powinna:
- pozwolić użytkownikowi wypozyczyć przedmiot na dany okres czasu
- zabronić wypożyczyć jeżeli dany przedmiot jest w tym okresie czasu wypożyczony
- sprawdzać w magazynie czy jest jeszcze jakiś przedmiot dostępny i wypożyczyć ostatni niewypozyczony
Przykład:
Magazyn: 2 namioty, 3 pary raków
Użytkownik wypożycza namiot na dany okres czasu(na początek ustalmy że wpisuje ręcznie np. "na tydzien")
source 'http://rubygems.org'
gem 'sinatra'
gem 'haml'
gem 'sass'
gem 'warden'
gem 'sinatra-activerecord'
gem 'rack', '1.3.6'
gem 'rack-flash'
group :development do
gem 'guard-livereload'