- What is a class?
- What is an object?
- What is a module? Can you tell me the difference between classes and modules?
- Can you tell me the three levels of method access control for classes and modules? What do they imply about the method?
- There are three ways to invoke a method in ruby. Can you give me at least two?
- Explain this ruby idiom: a ||= b
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
const buffer = require('buffer'); | |
const crypto = require('crypto'); | |
// Demo implementation of using `aes-256-gcm` with node.js's `crypto` lib. | |
const aes256gcm = (key) => { | |
const ALGO = 'aes-256-gcm'; | |
// encrypt returns base64-encoded ciphertext | |
const encrypt = (str, aad) => { | |
// Hint: the `iv` should be unique (but not necessarily random). |
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
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script> | |
<%= include_javascripts :maptastic %> | |
<script type="text/javascript"> | |
$j(window).load(function() { | |
initializeMap(); | |
<% @pharmacies.each do |pharmacy| -%> | |
<% unless pharmacy.lat.nil? || pharmacy.lon.nil? -%> | |
// addMarker(new google.maps.LatLng(<%= pharmacy.lat -%>, <%= pharmacy.lon -%>), '<%= escape_javascript h pharmacy.name -%>', '<%= escape_javascript h pharmacy_info_window(pharmacy) -%>'); | |
<% end -%> | |
<% 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
import { IncomingMessage } from "http"; | |
import { Agent, request, RequestOptions } from "https"; | |
const agent = new Agent({ keepAlive: true, timeout: 10000 }); | |
class MissingStatusCodeError extends Error { | |
constructor(public url: string) { | |
super("Missing a status code"); | |
this.name = "MissingStatusCodeError"; | |
this.url = url; |
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
#!/usr/bin/env ruby | |
require "nokogiri" | |
# opens every file in the given dir tree and converts any html img tags to rails image_tag calls | |
# | |
# example usage: | |
# ruby convert.rb ~/my_rails_app/app/views | |
# | |
# ***be careful and backup before using this*** | |
# |
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
require "benchmark" | |
include Benchmark | |
values = (0..10_000_000).to_a | |
bm(1_000_000) do |bench| | |
bench.report("map and select") do | |
values.map { |x| x * 3 }.select { |x| x % 4 == 0 } | |
end | |
bench.report("inject") do |
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
Table | |
----- | |
id msg_id name | |
1 | 1 | Tom | |
2 | 1 | Dick | |
3 | 1 | Harry | |
4 | 2 | Tom | |
5 | 2 | Dick | |
6 | 3 | Tom |
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
annotation | |
class Annotation < ActiveRecord::Base | |
belongs_to :image, :class_name => "Comment:Image" | |
include_root_in_json = false | |
end | |
comment | |
class Comment::Image < Asset | |
versioned | |
has_attached_file :attachment, :styles => { :small => "200x150>", :large => "400x300>" } |
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
(byebug) Survey::Token.find_by(token: params[:token], survey_id: @@survey) | |
nil | |
(byebug) Survey::Token.where(token: params[:token], survey_id: @@survey).take | |
#<Survey::Token id: 49078, |
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
require 'oauth' | |
require 'oauth2' | |
class ContactImporter | |
def initialize(importer) | |
@importer = importer | |
end | |
def authorize_url | |
case @importer |
NewerOlder