This is a maintained listing of all the different ways to debug and profile Node.js applications. If there is something missing or an improvement, post a comment! :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_validation :set_default_time | |
def set_default_time | |
self.start_date ||= Time.now.beginning_of_day | |
self.end_date ||= Time.now.end_of_day | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clients = Client.limit(10) | |
clients.each do |client| | |
puts client.address.postcode | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index | |
if stale?(:last_modified => @clients.maximum("updated_at"), :etag => @clients) | |
respond_with @clients.as_json(:methods => [:emails_count, :phones_count, :communications_count]) | |
end | |
end | |
def show | |
if stale?(@client) | |
respond_with @client.to_json(:include => { | |
:emails => {:limit => 10}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def touch | |
@user.touch | |
render :json => {"status" => "touched"} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.json | |
reading-image.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2015-11-10T10:32:06.667094+00:00 app[worker.1]: 3 TID-owedgntl8 INFO: Booting Sidekiq 3.4.2 with redis options {:url=>"redis://h:REDACTED@ec2-54-217-238-169.eu-west-1.compute.amazonaws.com:10079", :network_timeout=>5} | |
2015-11-10T10:32:07.827346+00:00 app[worker.1]: FATAL: sorry, too many clients already | |
2015-11-10T10:32:07.827358+00:00 app[worker.1]: /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `initialize' | |
2015-11-10T10:32:07.827366+00:00 app[worker.1]: /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `new' | |
2015-11-10T10:32:07.827367+00:00 app[worker.1]: /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize' | |
2015-11-10T10:32:07.827368+00:00 app[worker.1]: /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new' | |
2015- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SVG path string | |
path_string = "M,208,405C,208,405,206,744,206,744C,206,744,552,715,552,715C,552,715,590,451,590,451C,590,451,208,405,208,405" | |
# points will contain an array of arrays for each point of the path | |
points = Raphael.parsePathString(pe.attrs.path_string) | |
spline = new THREE.Shape() | |
spline.autoClose = true | |
_.each points, (p, i) -> | |
switch p[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open your terminal, navigate to the folder were the book.csv file is residing | |
# and type irb, when the interactive ruby console launches, type in the following | |
# it will print first 5 ISBN-13 numbers | |
require 'csv' | |
i = 0; CSV.foreach('book.csv', headers: :first_row, encoding: 'UTF-16LE:UTF-8') { |line| break if i == 5; puts line['isbn13']; i += 1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table mydata_real (id serial, date date, value text); | |
create table mydata_real_y2015 (check (date >= '2015-01-01' and date < '2016-01-01')) inherits (mydata_real); | |
create table mydata_real_y2016 (check (date >= '2016-01-01' and date < '2017-01-01')) inherits (mydata_real); | |
create function mydata_nope() returns trigger language plpgsql | |
as $f$ begin raise exception 'insert on wrong table'; return NULL; end; $f$; | |
create trigger mydata_nope before insert on mydata_real execute procedure mydata_nope(); | |
create view mydata as select * from mydata_real; |