Skip to content

Instantly share code, notes, and snippets.

Nícolas Iensen nicolasiensen

Block or report user

Report or block nicolasiensen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View share.rb
def share authorizations, urls
authorizations.each do |a|
puts a.email
begin
api = Koala::Facebook::API.new(a.token)
post = api.put_wall_post("A qualquer momento, os deputados poderão decidir se a nossa Internet será livre ou dominada pelos interesses das empresas de telecomunicação. Clique no link para mandar um email a eles e mostrar que quem trabalhar contra a neutralidade da Internet estará comprando briga com a sociedade em ano de eleição. #salveainternet", link: "http://bit.ly/salveainternet", name: "Réu em 3 processos no STF, aliado das teles e inimigo da internet", description: "O voto que define o futuro da Internet será nos próximos dias. Você vai deixar o Eduardo Cunha ganhar sem dizer nada?", picture: urls.sample)
a.update_attribute :facebook_post_id, post["id"]
rescue Exception => e
a.update_attribute :last_token_renew, false
puts e.message
View facaacontecer.rb
def canceled_subscriptions
canceled_subscriptions = []
offset = 0
subscriptions = Moip::Subscription.new.load offset
while subscriptions.any?
subscriptions.each do |subscription|
if subscription["status"] == "CANCELED"
canceled_subscriptions << subscription["code"]
end
View mailchimp_columns.rb
# Subscription.create/Subscription.update
# if subscription.payment_option == "creditcard"
# PLAN
# SUBUPDATED
# SUBVALUE
# Invoice.create/Invoice.update
# NINVOICES
# LINVOICE
View .bash_profile
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
View Gemfile.lock
GIT
remote: git://github.com/rbCAS/casino-activerecord_authenticator.git
revision: c159fbaf59b54e945e4be9ddd049e28eaf172ca3
branch: casino3
specs:
casino-activerecord_authenticator (3.0.0.pre.1)
activerecord (~> 4.1.0)
bcrypt (~> 3.0)
casino (~> 3.0.0.pre.1)
phpass-ruby (~> 0.1)
View cas.yml
defaults: &defaults
login_ticket:
lifetime: 600
service_ticket:
lifetime_unconsumed: 300
lifetime_consumed: 86400
proxy_ticket:
lifetime_unconsumed: 300
lifetime_consumed: 86400
frontend:
View funders_or_sponsors.rb
def self.funders_or_sponsors(opts={})
find_by_sql <<-SQL
SELECT *
FROM (
(SELECT "users".* FROM "users" WHERE "users"."sponsor" = 't')
UNION
(SELECT DISTINCT "users".* FROM "users" INNER JOIN "successful_transactions" ON "successful_transactions"."user_id" = "users"."id")
) AS t
SQL
end
View recent_activities_view.sql
CREATE VIEW recent_activities AS
(SELECT problems.name as title, problems.id as activable_id, problems.user_id, problems.created_at, problems.hashtag, 'Problem' as activable_type FROM problems ORDER BY problems.created_at DESC LIMIT 10) UNION ALL
(SELECT ideas_problems.name as title, ideas.id as activable_id, ideas.user_id, ideas.created_at, ideas_problems.hashtag, 'Idea' as activable_type FROM ideas INNER JOIN problems ideas_problems ON (ideas_problems.id = ideas.problem_id) ORDER BY ideas.created_at DESC LIMIT 10) UNION ALL
(SELECT tasks.title, task_subscriptions.id as activable_id, task_subscriptions.user_id, task_subscriptions.created_at, tasks.hashtag,
View count_users.sql
EXPLAIN ANALYZE SELECT count(*) FROM users;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=166.31..166.32 rows=1 width=0) (actual time=1720.265..1720.266 rows=1 loops=1)
-> Foreign Scan on users (cost=100.00..164.61 rows=3413 width=0) (actual time=2.437..1606.006 rows=118069 loops=1)
Total runtime: 1722.674 ms
(3 rows)
View error_in_github_profile_spec
Failure/Error: GithubProfile.for_username('mdeiters')
NoMethodError:
undefined method `keys' for nil:NilClass
# /home/vagrant/.rvm/gems/ruby-2.1.5@coderwall/gems/activemodel-3.2.21/lib/active_model/mass_assignment_security/sanitizer.rb:19:in `debug_protected_attribute_removal'
# /home/vagrant/.rvm/gems/ruby-2.1.5@coderwall/gems/activemodel-3.2.21/lib/active_model/mass_assignment_security/sanitizer.rb:12:in `sanitize'
# /home/vagrant/.rvm/gems/ruby-2.1.5@coderwall/gems/activemodel-3.2.21/lib/active_model/mass_assignment_security.rb:230:in `sanitize_for_mass_assignment'
# /home/vagrant/.rvm/gems/ruby-2.1.5@coderwall/gems/mongoid-3.1.6/lib/mongoid/attributes/processing.rb:25:in `block in process_attributes'
# /home/vagrant/.rvm/gems/ruby-2.1.5@coderwall/gems/mongoid-3.1.6/lib/mongoid/attributes/processing.rb:193:in `with_mass_assignment'
# /home/vagrant/.rvm/gems/ruby-2.1.5@coderwall/gems/mongoid-3.1.6/lib/mongoid/attributes/processing.rb:22:in `process_attributes'
You can’t perform that action at this time.