Skip to content

Instantly share code, notes, and snippets.

View ys's full-sized avatar
💭
Doing stuff with computers

Yannick Schutz ys

💭
Doing stuff with computers
View GitHub Profile
@ys
ys / padded.rb
Created December 13, 2013 15:12
#!/usr/bin/env ruby
def padded_tweet(message)
if message.size >= 140
message[0..139]
elsif %w{. ! ? …}.include? message[-1]
message.ljust(140, message[-1])
else
message.ljust(140, '!')
end
@ys
ys / padded.rb
Created December 13, 2013 15:10
#!/usr/bin/env ruby
def padded_tweet(message)
if message.size >= 140
return message[0..139]
end
dup = message.dup
if %w{. ! ? …}.include? message[-1]
return dup.ljust(140, message[-1])
end
class Follow < ActiveRecord::Base
belongs_to :follower, class_name: 'User'
belongs_to :followee, class_name: 'User'
end
@ys
ys / .gitignore
Last active December 26, 2015 06:39
.bundle
@ys
ys / puma.rb
Created October 17, 2013 15:25
threads 0, Integer(ENV['MAX_THREADS'] || 10)
on_restart do
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
FB::RedisPool.shutdown
end
workers Integer(ENV['WEB_CONCURRENCY'] || 3)
@ys
ys / todos
Last active December 25, 2015 18:59
My todo lists handler
function todo {
vim ~/Dropbox/todos/$1.txt
}
function list-todo {
for i in ~/Dropbox/todos/*; do echo $(basename $i | cut -f 1 -d '.') ":" $(wc -l < $i); done
}
alias t='todo'
alias lt='list-todo'
{ '@tadas_t' => ' 124553,
'@chrisbelpaire' => ' 124744,
'@floris' => ' 124798,
'@chucky4711' => ' 124960,
'@mr_foto' => ' 125077,
'@deogracia_974' => ' 125132,
'@christophePhilemotte' => ' 125267,
'@beanieboi' => ' 125469 }
ls . | xargs -I file vim -d file /comparable_folder/file
class SuggestedUsers
attr_reader :user, :options
def initialize(user, options = nil)
@user = user
@options = options || {}
end
def suggested_users
User.joins('JOIN follows as follows_follows ON follows_follows.followee_id = users.id')
class SuggestedUsers
attr_reader :user
def initialize(user)
@user = user
end
def suggested_users
User.joins('JOIN follows as follows_follows ON follows_follows.followee_id = users.id')
.joins('JOIN follows as user_follows ON follows_follows.follower_id = user_follows.followee_id')