Skip to content

Instantly share code, notes, and snippets.

View demisx's full-sized avatar

Dmitri demisx

View GitHub Profile
@demisx
demisx / protractor-cheatsheet.coffee
Last active September 27, 2020 00:03
Protractor e2e Cheatsheet (CoffeeScript)
browser.get "/phones" # navigate to /phones URL
input.clear() # clear text input field
expect(browser.getTitle()).toMatch 'My Google Photo Gallery'
expect(browser.getCurrentUrl()).toMatch "/phones$"
# Find by...
# --------------
@demisx
demisx / sites-available_default
Last active August 29, 2015 13:57
Nginx default site config
server {
listen 8000;
server_name localhost;
root /Users/dmoore/projects/hotilinet/hotilinet-web;
access_log "/Users/dmoore/projects/hotilinet/hotilinet-web/logs/hotili-net.access.log";
error_log "/Users/dmoore/projects/hotilinet/hotilinet-web/logs/hotilinet-web.error.log";
error_page 404 /app/404.html;
error_page 403 /app/403.html;
@demisx
demisx / nginx-dev.conf
Last active August 29, 2015 13:57
nginx.conf (dev)
worker_processes 1;
error_log /usr/local/etc/nginx/logs/error.log debug;
events {
worker_connections 256;
}
http {
include mime.types;
@demisx
demisx / macosx.sh
Last active December 8, 2017 12:40
Nginx Install
# Mac OS X
# ==============
# Installation
$ brew update
$ brew doctor
$ brew install nginx
$ mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
$ mkdir -p /usr/local/etc/nginx/logs
$ mkdir -p /usr/local/etc/nginx/conf.d
@demisx
demisx / gist:9318336
Created March 3, 2014 04:23
Boostrap New Rails API App
1. Generate new rails api structure
# he "-S" options removes the sprockets stuff, we dont need it since we will use Grunt
# for our frontend code. "-T" is because I use RSpec and no need for "test/" directory
$ rails-api new [app_name]-S -T
2. Remove everything from
$ cd [app_name]
$ rm -fr public/*
@demisx
demisx / gist:9203799
Last active August 29, 2015 13:56
Export Postgres table to CSV file
# Exports specified columns from doctors table to nplate_doctors.csv file
$ rails dbconsole
=# COPY doctors(customer_number,address_line_1,address_line_2,address_line_3,city,state,zip_code,primary_phone,prof_first_name,prof_middle_name,prof_last_name,prof_name_prefix,prof_name_suffix,primary_specialty,secondary_specialty,npi,ims,me,primary_specialty_dscr,latitude,longitude) TO '/Users/dmoore/projects/colddata-amgen/nplate_doc_finder/db/seeds/nplate_doctors.csv' DELIMITER ',' CSV HEADER;
@demisx
demisx / gist:9145465
Last active August 29, 2015 13:56
Redis Installation
# Mac OS X
# =========
$ brew install
# To automatically load on login:
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
# To refresh after upgrade:
@demisx
demisx / application_controller.rb
Last active August 29, 2015 13:56
Temporary stub current_user method in Rails application
# A convinient way to stub out a current_user method if you are in the middle of development and don't want to add authentication yet:
class ApplicationController < ActionController::Base
...
def current_user
OpenStruct.new(admin?: false)
end
helper_method current_user
@demisx
demisx / gist:8965498
Last active August 29, 2015 13:56
Rails migrations integer :limit option
:limit Numeric Type Column Size Max value
--------- ------------ ----------- ----------
1 tinyint 1 byte 127
2 smallint 2 bytes 32767
3 mediumint 3 byte 8388607
nil, 4, 11 int(11) 4 byte 2147483647
5..8 bigint 8 byte 9223372036854775807
Note: by default MySQL uses signed integers, so the max. values noted are for signed integers.
@demisx
demisx / gist:8960218
Last active August 29, 2015 13:56
Rails generators
# Rails::API app
$ rails-api new [nplate-syjdata-api] --skip-sprockets --skip-test-unit
# Rails app
$ rails new [my-app-name] --skip-test-unit
$ rails generate controller PersonalityTests take results
$ rails g model Foo bar:string baz:integer
$ rails g migration AddWorkflowStateToGraduates workflow_state:string
$ rails g serializer doctor