Skip to content

Instantly share code, notes, and snippets.

View dotemacs's full-sized avatar

Александар Симић dotemacs

View GitHub Profile
Given /^I visit subdomain "(.+)"$/ do |sub|
#host! "#{sub}.example.com" #for webrat
Capybara.default_host = "#{sub}.example.com" #for Rack::Test
Capybara.app_host = "http://#{sub}.example.com:9887" if Capybara.current_driver == :culerity
################################################################################
# As far as I know, you have to put all the {sub}.example.com entries that you're
# using in your /etc/hosts file for the Culerity tests. This didn't seem to be
# required for Rack::Test
################################################################################
#!/usr/bin/env ruby
# quick and dirty way to generate a rails app
my_gem_file =<<END
group :development, :test do
gem "rspec-rails"
gem "capybara"
gem "cucumber-rails"
<!-- layout file -->
<% if current_user %>
Welcome <%= current_user.username %>. Not you? <%= link_to "Log out", logout_path %>
<% else %>
<%= link_to "Sign up", signup_path %> or <%= link_to "log in", login_path %>.
<% end %>
@dotemacs
dotemacs / parse-vcard.rb
Created February 17, 2011 09:07
Sometimes I just want contact info in plain text :)
#!/usr/bin/env ruby
# spit out a VCARD, stripping all the 'fluff'
if ARGV.length == 0
puts "supply a file"
exit 1
else
file = ARGV[0]
end
@dotemacs
dotemacs / First error
Created March 19, 2011 13:23
Setup with el-get.el
Warning (initialization): An error occurred while loading `/home/alex/.emacs.d/init.el':
error: el-get: *git submodule update* Could not update git submodules
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
@dotemacs
dotemacs / gist:1033069
Created June 18, 2011 12:54
Regexp for rinari-conosole/inf-ruby mode
Hi Steve, that didn't quite work for me for:
ruby-1.9.2-p0 >
prompt.
So I did a bit of testing with the environments/versions of Ruby that I have available to me and I think this might be a better solution:
"[[:alnum:]-\s.:\(\)]+\\(>\\{1,2\\}\\)\s"
These are the environments I had available to me, might be useful to you along with 'regexp-builder' in Emacs to test.
@dotemacs
dotemacs / types.conf
Created August 6, 2011 09:44
For ffi gem on FreeBSD/i386
rbx.platform.typedef.__int8_t = char
rbx.platform.typedef.__uint8_t = uchar
rbx.platform.typedef.__int16_t = short
rbx.platform.typedef.__uint16_t = ushort
rbx.platform.typedef.__int32_t = int
rbx.platform.typedef.__uint32_t = uint
rbx.platform.typedef.__int64_t = long_long
rbx.platform.typedef.__uint64_t = ulong_long
rbx.platform.typedef.__clock_t = ulong
rbx.platform.typedef.__cpumask_t = uint
@dotemacs
dotemacs / gist:1247477
Created September 28, 2011 09:35
Sample cuke jumps for rinari
(cucumber
"K"
(("features/\\1\\.feature" . "features/step_definitions/\\1.rb")
("features/*.feature" . "features/step_definitions/*.rb")
;; .... some more matchers
)
t)

Бројеви

Пошто смо све припремили, хајде да напишемо програм! Отвори свој омиљени текст едитор и укуцај следеће:

puts 1+2

Сачувај свој програм (да, то је програм!) као calc.rb (.rb

@dotemacs
dotemacs / add-to-mode.el
Created December 3, 2011 14:20
Add multiple file extensions to major modes
;; Instead of this
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile$" . ruby-mode))