Skip to content

Instantly share code, notes, and snippets.

View razorcd's full-sized avatar

Cristian Dugacicu razorcd

View GitHub Profile
1. Codebase
One codebase tracked in revision control, many deploys
2. Dependencies
Explicitly declare and isolate dependencies
3. Config
Store config in the environment
4. Backing services
@razorcd
razorcd / ruby_shell.md
Created June 8, 2016 17:03
ways to run shell commands in Ruby
exec("echo 'hello world'") # exits from ruby, then runs the command
system('echo', 'hello world') # returns the status code
sh('echo', 'hello world') # returns the status code
`echo "hello world"` # returns stdout
%x[echo 'hello world'] # returns stdout
== - returns true only if the two compared entities are the same object
=== - is the Case Equality Operator (Case Subsumption Operator) (fits in drawer?)
eql? - method returns true if obj and other have the same value.
equal? - determines object identitfy. Compares pointers
# Returns a User instance that's not saved (does not write to DB)
user = build(:user)
# Returns a saved User instance (writes to DB)
user = create(:user)
# Returns a hash of attributes that can be used to build a User instance
attrs = attributes_for(:user)
# Returns an object with all defined attributes stubbed out
@razorcd
razorcd / commands.md
Created July 9, 2016 14:27 — forked from ondrej-kvasnovsky/commands.md
Commands to install and configure ElasticSearch on Ubuntu

Install ElasticSearch and Java

1  wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.0.1.deb
2  sudo dpkg -i elasticsearch-1.0.1.deb
3  sudo update-rc.d elasticsearch defaults 95 10
4  sudo add-apt-repository ppa:webupd8team/java
5  sudo apt-get update
6  sudo apt-get install oracle-java7-installer
7  java -version
<style>
.dropdown-submenu {
position:relative;
& > .dropdown-menu {
top:0;
left:100%;
margin-top:-6px;
margin-left:-1px;
-webkit-border-radius:0 6px 6px 6px;
@razorcd
razorcd / observableExample.ts
Created October 26, 2016 09:14
Angular2 - RXJS Observable example
import {Component} from '@angular/core';
import {Observable} from 'rxjs/Observable';
@Component({
selector: 'app',
template: `
<b>Angular 2 Component Using Observables!</b>
<h6 style="margin-bottom: 0">VALUES:</h6>
<div *ngFor="let value of values">- {{ value }}</div>
@razorcd
razorcd / Angular2 ngModel manipulation directive
Created November 11, 2016 15:05
Angular 2 directive that manipulates the `ngModel` value on every change.
import {Directive, Attribute} from 'angular2/core';
import {NgModel} from 'angular2/common';
@Directive({
selector: '[mask]',
host: {
'(keyup)' : 'onInputChange()'
}
})
export class MaskDirective{
@razorcd
razorcd / Elasticsearch agregations
Created April 21, 2017 15:32
Elasticsearch agregations
{
"from": 0,
"size": 0,
"aggregations": {
"deviceFilter": {
"filter": {
"or": {
"filters": [
{
"and": {