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
@nicolasiensen
nicolasiensen / .bash_profile
Last active Dec 16, 2015
My .bash_profile
View .bash_profile
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
function parse_git_branch_and_add_brackets {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/'
}
export PATH="/usr/local/bin:$PATH"
export PS1="\[\e[1;29;42m\]\w\$(parse_git_branch_and_add_brackets)\[\e[m\] "
export CLICOLOR=1
View .vimrc
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'wincent/Command-T.git'
Bundle 'bbommarito/vim-slim.git'
Bundle 'digitaltoad/vim-jade.git'
Bundle 'pangloss/vim-javascript.git'
Bundle 'vim-ruby/vim-ruby.git'
Bundle 'https://github.com/tpope/vim-fugitive.git'
@nicolasiensen
nicolasiensen / game.rb
Last active Dec 14, 2015
Ordering games by achievements completeness
View game.rb
# by @diogob
def self.by_completeness user
user.games.order("
CASE WHEN (SELECT count(*) FROM achievements a WHERE a.game_id = games.id) = 0 THEN 0 ELSE
(SELECT count(DISTINCT a.id)
FROM
achievements_users au
JOIN achievements a ON a.id = au.achievement_id
WHERE a.game_id = games.id AND au.user_id = #{user.id})::numeric /
(SELECT count(*)
View pokers.rb
User.joins(:pokes).
select("users.*, (
SELECT COUNT(p.*) FROM pokes p
WHERE p.user_id = users.id
AND p.campaign_id = #{self.id}
) as pokes_count").
where(["pokes.campaign_id = ?", self.id]).uniq
View pokers.rb
SELECT DISTINCT users.*, (SELECT COUNT(p.*) FROM pokes p WHERE p.user_id = users.id AND p.campaign_id = 3) as pokes_count FROM "users" INNER JOIN "pokes" ON "pokes"."user_id" = "users"."id" WHERE (pokes.campaign_id = 3) ORDER BY RANDOM() LIMIT 8
@nicolasiensen
nicolasiensen / member_export.rb
Created Aug 6, 2012
Export Meu Rio members from Mr. Dash
View member_export.rb
require "csv"
members = Group.find(1).users
CSV.open("/Users/nicolas/Desktop/members.csv", "wb") do |csv|
csv << ["Nome", "Email"]
members.each do |member|
csv << [member.name, member.email]
end
end
View .vimrc
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'wincent/Command-T.git'
Bundle 'bbommarito/vim-slim.git'
Bundle 'digitaltoad/vim-jade.git'
Bundle 'pangloss/vim-javascript.git'
Bundle 'vim-ruby/vim-ruby.git'
Bundle 'https://github.com/tpope/vim-fugitive.git'
View 01_envvars.rb
ENV["DASH_TOKEN"] = "ebc309c2090073bbfdfd18494353f0771f33aa0da269f1f06e421d7e30b5aa19"
ENV["MAILEE_API_URL"] = "https://api.d3b39ea48efdc.meurio.mailee.me"
View mr_dash.rb
Início: 13 de Outubro de 2011
Deadline: 13 de Abril de 2013
Dias restantes: 375
Dias totais: 548
Membros: 17461
Restantes: 82539
Ideal: 183
Média real: 100
Ontem: 40
View gist:1987534
<html><head><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<!-- Facebook sharing information tags -->
<meta property="og:title" content="Meu Rio">
<title>Meu Rio</title>
<style type="text/css">
/* Client-specific Styles */
#outlook a{padding:0;} /* Force Outlook to provide a "view in browser" button. */
You can’t perform that action at this time.