A tiny app using opal.rb and nodewebkit to get your weather in your toolbar.
- GitHub Staff
- https://justinherrick.com/
- @jah2488
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Graphics.Element exposing (show) | |
type State = Ready | Working | Complete | |
stateSort a = | |
case a.state of | |
Ready -> 1 | |
Working -> 2 | |
Complete -> 3 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def translate_fields(field) | |
mapping.invert.fetch(field.to_sym, field.to_sym) | |
end | |
def perform_query(sql, opts = {}) | |
results = get_records_from_query(sql, opts) | |
columns = results.shift | |
results.map do |row| | |
model_attr_hash = Hash[ | |
column_names.map(&method(:translate_fields)).zip([nil] * column_names.count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def initialize(default = case $glob | |
when "foo" then (def foobar; "hi!" end) | |
end) | |
@default = default | |
end | |
end | |
Foo.new #=> #<Foo:0x007f849f37be98 @default=nil> | |
$glob = 'foo' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
[ -z "$1" ] && echo "No argument supplied: Your ruby version is required" && exit 1 | |
RUBY_VERSION=$1 | |
PACKAGE_DIR="$HOME/Library/Application Support/Sublime Text 3/Packages/" | |
gem install seeing_is_believing | |
rvm wrapper "$RUBY_VERSION" sublime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ClubInfoContents | |
def initialize(club) | |
@club = club | |
end | |
def title | |
return "Congratulations! #{@club.name}" if @club.valid_member_count? | |
return @club.name | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
articles.each do |article| | |
puts article | |
end.empty? and begin | |
puts ‘sorry, no articles’ | |
end |
I like to manipulate data structures. Sometimes the final out put of that manipulation is a string. So I find myself using the pattern of map + join and its starting to feel like the map + flatten of old. Sadly, ruby does not have an answer for this yet, so this is what I've written in the mean time.
def map_join(arr, sep, &block)
arr.map(&block).join(sep)
end
map_join([1, 2, 3, 4, 5], '-') { |x| x ** 2 } #=> '1-4-9-16-25'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filetype plugin indent on " Turn on plugins, auto indentation, and syntax highlighting | |
set nocompatible " Use Vim settings, rather then Vi settings | |
set nobackup " Stop vim from leaving temp files everywhere | |
set nowritebackup " Don't write your undo history to a file | |
set history=200 " Only save 200 undos | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
set incsearch " do incremental searching | |
set vb " NO BELLS! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signal.trap(:INFO) { | |
puts "chill, I'm processing #@current_number" | |
} | |
@current_number = 0 | |
loop do | |
@current_number += 1 | |
sleep 3 | |
end |