Skip to content

Instantly share code, notes, and snippets.

@iwarshak
iwarshak / README.md
Created June 8, 2017 12:24 — forked from eproxus/README.md
Use Bootstrap 4 SASS with Phoenix

Versions

  • Bootstrap 4 Alpha 6
  • Phoenix 1.2.1

Instructions

  1. Install npm packages

npm install --save-dev sass-brunch

Types

A type is a collection of possible values. An integer can have values 0, 1, 2, 3, etc.; a boolean can have values true and false. We can imagine any type we like: for example, a HighFive type that allows the values "hi" or 5, but nothing else. It's not a string and it's not an integer; it's its own, separate type.

Statically typed languages constrain variables' types: the programming language might know, for example, that x is an Integer. In that case, the programmer isn't allowed to say x = true; that would be an invalid program. The compiler will refuse to compile it, so we can't even run it.

=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@iwarshak
iwarshak / postgres_convert.sh
Created January 23, 2014 22:38
convert postgres db to utf8 from asii
# from http://www.postgresql.org/message-id/20060329203545.M43728@narrowpathinc.com
# list databases & encodings
# psql --list
vacuumdb --full --analyze --username postgres --dbname mephisto && pg_dump mephisto -Ft -v -U postgres -f tmp/mephisto.tar && dropdb mephisto --username postgres && createdb --encoding UNICODE mephisto --username postgres && pg_restore tmp/mephisto.tar | psql --dbname mephisto --username postgres && vacuumdb --full --analyze --username postgres --dbname mephisto
# [ UIViewController, UIView, etc. ]...
[ UIViewController ].each do |klass|
klass.class_eval do
def self.allocWithZone(zone)
super.tap do |x|
p " + alloc! #{x.inspect}"
end
end
alias_method 'old_dealloc', 'dealloc'
@iwarshak
iwarshak / Gemfile
Last active May 12, 2018 21:54
Here is what you need to get your Rubymotion application logs sent to papertrailapp.com. I am using Cocoalumberjack (CLJ) which seems to be the logging framework of choice for Cocoa, motion-logger which is a thin RM wrapper around Cocoalumberjack. CLJ allows you to write your own loggers, which is what PapertrailLogger is. It simply fires off lo…
source :rubygems
gem "rake"
gem 'motion-logger' #cocoalumberjack wrapper
@iwarshak
iwarshak / why_isnt_this_the_default.rb
Created August 25, 2012 20:52 — forked from tpope/why_isnt_this_the_default.rb
Raise an error on missing assets
Sprockets::Helpers::RailsHelper::AssetPaths.class_eval do
class MissingAssetError < StandardError; end
def digest_for_with_presence_check(logical_path)
unless asset_environment[logical_path]
raise MissingAssetError.new("#{logical_path} doesn't exist")
end
digest_for_without_presence_check(logical_path)
end
alias_method_chain :digest_for, :presence_check
@iwarshak
iwarshak / devise-iphone.rb
Created January 19, 2012 16:33
pulling devise api key out of request
class ApplicationController < ActionController::Base
protect_from_forgery
prepend_before_filter :get_api_key
# devise will look for params[:api_key] automatically. it might need to be configured in devise.rb
private
def get_api_key
if api_key = params[:api_key].blank? && request.headers["X-API-KEY"]
params[:api_key] = api_key
@iwarshak
iwarshak / nginx
Created December 12, 2011 15:31
nginx init script
#!/bin/bash
case "${1:-''}" in
'start')
# start commands here
/opt/nginx/sbin/nginx
;;
'stop')
# stop commands here
kill `cat /opt/nginx/logs/nginx.pid`
@iwarshak
iwarshak / devise_migration.rb
Created August 24, 2011 16:02 — forked from Bertg/devise_migration.rb
Migrating to a new password encryption in devise, coming from authlogic
class MigrateUserToDevise < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.string :encrypted_password, :null => false, :limit => 128
# ...
end
end
def self.down
end