Skip to content

Instantly share code, notes, and snippets.

View demisx's full-sized avatar

Dmitri demisx

View GitHub Profile
@demisx
demisx / regenerate-binstubs.sh
Last active December 31, 2020 07:48
Regenerate and Springify Rails 4 binstubs
cd my_rails_app_root_dir
rm bin/*
bundle exec rake rails:update:bin
bundle binstubs rspec-core
spring binstub --all
@demisx
demisx / rails_what_to_test.md
Last active August 29, 2015 13:58
What to Test in Rails App (Spec Types)

These are the spec types we will be mainly working with in Rails applications for now. Other specs maybe added in the future when complexity of an application goes drastically up.

1. Factories (/spec/factories/*)

Simple, flexible, building blocks for test data. To genererate initial spec via scaffolding

@demisx
demisx / active_record_objects_autosave.md
Last active April 29, 2024 09:02
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.
@demisx
demisx / gist:9846057
Created March 29, 2014 00:39
View Rails Autoload Paths
$ bin/rails runner 'pp ActiveSupport::Dependencies.autoload_paths'
@demisx
demisx / http-simple-methods-headers.md
Last active August 29, 2015 13:57
HTTP Simple Methods and Headers

Simple Methods

A method is said to be a simple method if it is a case-sensitive match for one of the following:

GET
HEAD
POST

Simple Headers

A header is said to be a simple header if the header field name is an ASCII case-insensitive match for Accept, Accept-Language, or Content-Language or if it is an ASCII case-insensitive match for Content-Type and the header field value media type (excluding parameters) is an ASCII case-insensitive match for application/x-www-form-urlencoded, multipart/form-data, or text/plain.

@demisx
demisx / regenerate-rvm-gemset.sh
Last active August 29, 2015 13:57
Regenerate Gems in Existing RVM Gemset
# cd to gems directory
localhost: cd ~/.rvm/gems/ruby-2.0.0-p247@gradrocket
server: cd /home/gr/gradrocket/gradrocket-com/shared/bundle/ruby/2.0.0
# Remove gems in the gemset
rm -fr gems/*
rm -fr cache/*
rm -fr build_info/*
rm -fr bin/*
rm -fr bundler/gems/*
@demisx
demisx / gist:9646645
Last active August 29, 2015 13:57
GitLab Upgrade
@demisx
demisx / angularjs-providers-explained.md
Last active March 17, 2024 11:09
AngularJS Providers: Constant/Value/Service/Factory/Decorator/Provider
Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes

Constant

@demisx
demisx / gulpfile.js
Last active November 6, 2019 23:10
My Gulp file example
var gulp = require('gulp'),
debug = require('gulp-debug'),
size = require('gulp-filesize'),
clean = require('gulp-clean'),
coffee = require('gulp-coffee'),
coffeelint = require('gulp-coffeelint'),
gutil = require('gulp-util'),
sass = require('gulp-sass'),
imagemin = require('gulp-imagemin'),
changed = require('gulp-changed'),
@demisx
demisx / sites-available_angularjs_html5
Last active March 28, 2020 18:23
Nginx config for HTML5 AngularJS applications
server {
listen 8000;
server_name localhost;
root /Users/dmoore/projects/tutorials/angular-phonecat2/.build;
access_log "/Users/dmoore/projects/tutorials/angular-phonecat2/logs/hotili-net.access.log";
error_log "/Users/dmoore/projects/tutorials/angular-phonecat2/logs/hotili-net.error.log";
error_page 404 /app/404.html;
error_page 403 /app/403.html;