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
BLUETOOTH_MAC_ADDRESS = "00:02:02:33:B1:87" | |
SINK_NAME = "bluez_sink.00_02_02_33_B1_87" | |
def connect | |
`bt-audio -c #{BLUETOOTH_MAC_ADDRESS}` | |
end | |
def disconnect | |
`bt-audio -d #{BLUETOOTH_MAC_ADDRESS}` | |
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
if [ -z $1 ]; then | |
GEM_NAME=${PWD##*/} | |
else | |
GEM_NAME=$1 | |
fi | |
GEMSPEC="$GEM_NAME.gemspec" | |
if [ -f $GEMSPEC ];then | |
gem build $GEMSPEC |
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
#!/usr/bin/env ruby | |
require 'open3' | |
class NojzError < StandardError | |
def initialize(msg) | |
@msg = msg | |
super(msg) | |
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
alias productive='git log --since="today" --oneline | sed "s/^\w\+/*/g"' |
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 flash_messages | |
content_tag :div, class: "flash-messages" do | |
flash.map do |key, value| | |
content_tag :div, class: "alert alert-dismissable alert-#{key}" do | |
content_tag(:span, '×'.html_safe, class: :close, 'data-dismiss' => 'alert') + value | |
end | |
end.join().html_safe | |
end | |
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
Returning an array as a response: | |
[200, {'Content-Type' => 'text/html'}, ["<h1>Hello!</h1>"]] | |
Benchmark: | |
10000 runs | |
0.037738 seconds total | |
0.0037738 millisec/run | |
With a controller rendering a template with erb: |
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
stormpath_client = Stormpath::Client.new(api_key: api_key, cache: { | |
regions: { | |
applications: { store: Stormpath::Cache::RedisStore, ttl_seconds: 300, tti_seconds: 300, store_opts: {:host => uri.host, :port => uri.port, :password => uri.password} }, | |
directories: { store: Stormpath::Cache::RedisStore, ttl_seconds: 300, tti_seconds: 300, store_opts: {:host => uri.host, :port => uri.port, :password => uri.password} }, | |
groups: { store: Stormpath::Cache::RedisStore, ttl_seconds: 300, tti_seconds: 300, store_opts: {:host => uri.host, :port => uri.port, :password => uri.password} } | |
} | |
}) |
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
```ruby | |
"SERVER_SOFTWARE"=>"thin 1.6.2 codename Doc Brown", | |
"SERVER_NAME"=>"localhost", | |
"rack.version"=>[1, 0], | |
"rack.errors"=>#<IO:<STDERR>>, | |
"rack.multithread"=>false, | |
"rack.multiprocess"=>false, | |
"rack.run_once"=>false, | |
"REQUEST_METHOD"=>"GET", | |
"REQUEST_PATH"=>"/", |
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
pretty_echo() { | |
echo_length=${#1} | |
stars="" | |
star_length=$(($echo_length+8)) | |
for i in $(seq 1 $star_length); do | |
stars="$stars*" | |
done | |
echo "\n"; echo "$stars"; echo "*** $1 ***"; echo "$stars"; echo "\n" | |
}; |
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
### Rails app generator template. Run it: | |
### rails new _app_name_ -m https://gist.githubusercontent.com/DamirSvrtan/28a28e50d639b9445bbc/raw/app_template.rb | |
remove_file "README.rdoc" | |
create_file "README.md", "Development: run ./bin/setup" | |
run 'mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss' | |
database_type = ask("Do you want to use postgres or mysql?", limited_to: ["pg", "mysql"]) | |
adapter = if database_type == 'pg' |