- 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
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
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
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
(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
Bundler could not find compatible versions for gem "activesupport": | |
In Gemfile: | |
paperclip (~> 5.1.0) was resolved to 5.1.0, which depends on | |
activemodel (>= 4.2.0) was resolved to 5.0.0.1, which depends on | |
activesupport (= 5.0.0.1) | |
friendly_id (~> 5.1.0) was resolved to 5.1.0, which depends on | |
activerecord (>= 4.0.0) was resolved to 4.2.7.1, which depends on | |
activesupport (= 4.2.7.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
SELECT `users`.* FROM `users` | |
INNER JOIN `friendships` `a` ON `users`.`id` = `a`.`friend_id` | |
INNER JOIN `friendships` `b` ON `users`.`id` = `b`.`friend_id` | |
WHERE `a`.`user_id` = 1 AND `b`.`user_id` = 2 |
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
// app/services/invite.js | |
recommendationsFromStore: Ember.computed(function(){ | |
return this.get('store').findAll('pymkRecommendation'); | |
}), |
NewerOlder