View snippets
Vamos colocar alguns snippets de código no Graffiti da HE:labs
https://www.dropcam.com/p/helabs
Sugira o seu que ele pode entrar na parede, mas tem que ser até final do dia 31 de março (terça)!!
Pode ser qualquer linguagem.
Ex:
while working{
coffee++;
}
View gist:0fa400f8cefec64834c1
Exemplo de `tag` no github
```ruby
codigo = Ruby.new(:param1,:param2)
# comentario
```
```bash
$ export TOKEN=meutoken
$ ls -al
View take-iphone-simulator-screenshot.sh
#!/bin/sh
# script to screenshot the iPhone Simulator to the correct size
# to upload to iTunes Connect
# written by Jehiah Czebotar http://jehiah.cz/
OUTPUTDIR=~/Desktop
TEMPFILE=iPhoneSimulatorScreenshot_`date +%Y%m%d_%H%M%S`.png
echo "output filename:\c"
View swap-usage.sh
#!/bin/sh
free -m | grep Swap | while read output;
do
swap=$(echo $output | awk '{print $2}' )
used=$(echo $output | awk '{ print $3 }' )
freed=$(echo $output | awk '{ print $4 }' )
echo "Swap : $swap"
echo "Used : $used"
echo "Free : $freed"
usep=`expr $used \* 100 / $swap`
View bank_billet.rb
class BankBillet
include HTTParty
include Virtus
base_uri 'https://app.cobregratis.com.br'
attribute :id, Integer
attribute :name, String
attribute :amount, Float
attribute :expire_at, Date
attribute :external_link, String
View deferred_garbage_collection.rb
# Joe Van Dyk discovered that running the Ruby garbage collector only every X seconds can speed up your tests.
# I found that deferring garbage collection would speed up my RSpec examples by about 15%,
# but it probably depends on the nature of your tests.
# https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection
class DeferredGarbageCollection
RESERVED_IVARS = %w(@loaded_fixtures)
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 10.0).to_f
@@last_gc_run = Time.now
def self.start
View find_unused_images.rake
# It requires ACK - http://betterthangrep.com/
task :find_unused_images do
images = Dir.glob('app/assets/images/**/*')
images_to_delete = []
images.each do |image|
unless File.directory?(image)
# print "\nChecking #{image}..."
print "."
result = `ack -1 -G '(app|public)' --ruby --html --css --js #{File.basename(image)}`
View new_mailer_spec.rb
# -*- encoding : utf-8 -*-
require "spec_helper"
describe Notification do
describe "new_question" do
let(:user) { Factory.create(:user, name: 'Dart Vader', email: 'dart@example.com') }
let(:category) { Factory.create(:category, name: 'Saúde') }
let(:owner) { Factory.create(:user, name: 'Jaspion') }
let(:question) { Factory.create(:question, user: owner, category: category) }
let(:mailer) { Notification.new_question(question.id, user.id) }
View aws_sdk_log_formatter.rb
module AWS
module Core
class LogFormatter
# @param [Object] value
# @return [String]
def summarize_value value
case value
when String then summarize_string(value)
when Hash then '{' + summarize_hash(value) + '}'
when Array then summarize_array(value)
View gist:2884599
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 130 | 117 | 13 | 20 | 1 | 3 |
| Helpers | 44 | 41 | 0 | 8 | 0 | 3 |
| Models | 241 | 218 | 9 | 31 | 3 | 5 |
| Libraries | 15 | 13 | 0 | 1 | 0 | 11 |
| Model specs | 696 | 676 | 0 | 0 | 0 | 0 |
| Controller specs | 455 | 430 | 0 | 6 | 0 | 69 |
| Helper specs | 126 | 121 | 1 | 0 | 0 | 0 |