Skip to content

Instantly share code, notes, and snippets.

View lastk's full-sized avatar

Rafael Oliveira lastk

  • Salvador-Ba, Brazil
View GitHub Profile
@lastk
lastk / gist:7845935
Created December 7, 2013 17:41
default git ignore for visual studio with asp.net mvc
###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache
$(document).ready(function() {
if ($("[name='search']").length) {
$("[name='search']").each(function() {
var search = new Search.Input(this);
search.setBindings();
});
}
});
@lastk
lastk / gist:2413388
Created April 18, 2012 12:50 — forked from kurko/gist:2410930
DCI in real code
class ReceivablesManagementContext
def initialize(params)
@params = params
end
def save_receivable
sanitize_controller_params
@receivable = AccountReceivable.new(@params[:account_receivable])
@receivable.customer_id = @params[:customer_id]
@receivable.save
class PostCommitmentContext
#how we're using ruby/rails I thought in something like a rubygem and have a 'config' file in other place.
twitterable[:twitterFollower,:twitterPoster]
def initialize(params)
@params = params
end
def save
class PostCommitmentContext
def initialize(params)
@params = params
end
def save
@post = Post.new(@params)
if @post.save
# @post é ActiveRecord, então não há o que extender mesmo porque ActiveRecord já está encruado
Twitter.send_notification({login: "login",pass:"password"},@post.title)
@lastk
lastk / macenv.rb
Created February 22, 2012 20:37 — forked from pjones/macenv.rb
Create an env file for Mac OS GUI applications
#!/usr/bin/env ruby
PASS_THROUGH = %w(PATH MANPATH EDITOR)
DIRECTORY = File.expand_path('~/.MacOSX')
FILENAME = File.join(DIRECTORY, 'environment.plist')
Dir.mkdir(DIRECTORY) unless File.exist?(DIRECTORY)
HEADER = <<EOT
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
=form_for(@user_session,:url=>"/sessions",:method=>"post") do |f|
.field
=f.label :credential
=f.text_field :credential
.field
= f.label :password
= f.text_field :password
.field.actions
<!-- 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 %>
@lastk
lastk / inspect.js
Created December 23, 2010 11:17 — forked from creationix/inspect.js
function escapeString(string) {
string = string.replace(/\\/g, "\\\\").
replace(/\n/g, "\\n").
replace(/\r/g, "\\r").
replace(/\t/g, "\\t");
if (string.indexOf("'") < 0) {
return "'" + string + "'";
}
string = string.replace(/"/g, "\\\"");
return '"' + string + '"';
module Robot
def self.attr_state(*names)
names.each{|n|
n = n.to_sym
attr_writer n
attr_reader n
}
end