Skip to content

Instantly share code, notes, and snippets.

@jmarmolejos
jmarmolejos / reminders
Last active October 11, 2015 10:28
a few post-its I have laying around.
Location: /var/www/test_app
Unicorn: unicorn -c /var/www/test_app/config/unicorn.rb -D
Unicorn: bundle exec unicorn_rails -c config/unicorn.rb -E development
nginx config: /opt/local/etc/nginx/nginx.conf || /etc/nginx/nginx.conf
whenever --set environment=development
whenever --update-crontab
[TestMethod]
public void MergeCustomers()
{
using (TransactionScope scope = new TransactionScope())
{
var context = new AdminModelEntities();
var service = new CustomersService(context);
var newCustomerId = service.MergeCustomers(new List<int> { 523184, 530696 });
// My first attempt
var appointments = _context.T_APPOINTMENT.Where(c => ids.Contains(c.CUSTOMER_ID));
foreach (var appointment in appointments)
{
appointment.CUSTOMER_ID = newCustomer.CUSTOMER_ID;
_context.T_APPOINTMENT.ApplyCurrentValues(appointment);
}
_context.SaveChanges();
@jmarmolejos
jmarmolejos / testing_setup.txt
Last active December 10, 2015 02:48
Rspec + Spork + Guard setup commands
#Commands
rails g rspec:install
guard init rspec
spork --bootstrap
#Related Files
Guardfile: https://gist.github.com/4369789
spec_helper.rb: https://gist.github.com/4369786
#Related links
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch('config/environments/test.rb')
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile')
watch('Gemfile.lock')
def self.get_events_count token
notified_user = ApiKey.find_by_push_token(token).user
notifications_count = 0
# Getting events from active games
active_games = Match.find(:all, :conditions => [ "challenger_id = ? or opponent_id = ? and is_over = false or is_over is null", notified_user.id, notified_user.id ])
active_games.each do |game|
is_challenger = game.challenger_id == notified_user.id
<div class="container" style="width:400px">
<div class="row-fluid">
<div class="span3"><a href="https://twitter.com/share?via=vacantesrd&text=Conoce a http://www.emplea.do, un job board dedicado al sector de tecnología de la información en la República Dominicana. " class="twitter-share-button" data-lang="en">Tweet</a></div>
<div class="span3"><div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div></div>
<div class="span3"><g:plusone></g:plusone></div>
<div class="span3"><script type="IN/Share" data-counter="right"></script></div>
</div>
</div>
class CompaniesController < ApplicationController
include ActionController::MimeResponds
respond_to :json, :xml
def index
@companies = Company.all
respond_with @companies
end