Skip to content

Instantly share code, notes, and snippets.

View maletor's full-sized avatar

Ellis Berner maletor

View GitHub Profile
@maletor
maletor / crypto-aes-256-gcm-demo.js
Last active July 14, 2023 06:45 — forked from rjz/crypto-aes-256-gcm-demo.js
example using node.js crypto API with aes-256-gcm
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).
@maletor
maletor / enum_perf_small.rb
Last active June 7, 2018 23:08 — forked from taq/enum_perf_small.rb
Ruby 2.0 lazy enumerators small collection performance
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
@maletor
maletor / Ruby and Rails Interview Cheat Sheet.md
Created March 21, 2017 17:32 — forked from ahmadhasankhan/Ruby and Rails Interview Cheat Sheet.md
This is my Ruby interview cheat sheet. Feel free to fork it, Use it, Share it, or do whatever you want with it. PLEASE let me know if there is any error or if anything crucial is missing. I will keep updating...

Ruby and Rails Interview Questions

Ruby

  • 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
@maletor
maletor / content-for-group.js
Created May 3, 2016 05:46 — forked from mrozema/content-for-group.js
Ember 2.0 compatible select box
import Ember from "ember";
export default Ember.Helper.helper(function([content, group, contentGroupKey]) {
return content.filterBy(contentGroupKey, group);
});
require 'rubygems'
specs_with_extensions = Gem::Specification.each.select { |spec| spec.extensions.any? }
specs_with_extensions.each do |spec|
puts "#{spec.name} (extensions: #{spec.extensions.inspect})"
end
groups = Rails.groups(assets: %w(development test))
groups << ENV["GITHUB_USER"] unless user.blank? unless Rails.env.production?
Bundler.require(*groups)
rds-modify-db-parameter-group dox-prod-55 \
--parameters="name=character_set_server, value=utf8, method=pending-reboot" \
--parameters="name=collation_server, value=utf8_general_ci, method=pending-reboot" \
--parameters="name=tmp_table_size, value=4563402752, method=pending-reboot" \
--parameters="name=max_heap_table_size, value=4563402752, method=pending-reboot" \
--parameters="name=query_cache_type, value=1, method=pending-reboot" \
--parameters="name=query_cache_size, value=2281701376, method=pending-reboot" \
--parameters="name=table_open_cache, value=2500, method=pending-reboot" \
--parameters="name=join_buffer_size, value=1140850688, method=pending-reboot" \
--parameters="name=thread_cache_size, value=5803, method=pending-reboot" \
diff --git a/app/models/inbox/recruiter_message.rb b/app/models/inbox/recruiter_message.rb
index 2373ae2..c1b7eab 100644
--- a/app/models/inbox/recruiter_message.rb
+++ b/app/models/inbox/recruiter_message.rb
@@ -20,6 +20,8 @@ class Inbox::RecruiterMessage < Inbox::Message
validate :available_credits, on: :create
validate :active_subscription, on: :create
+ after_create :doc_mail_debit
+
@maletor
maletor / app.js
Created July 23, 2012 07:09
Bootstrap data using RequireJS and Backbone
require(['userAttributes', 'backbone', 'user_router'], function (config, Backbone, UserRouter) {
var userRouter = new UserRouter() {
userAttributes: userAttributes
};
return router;
});
@maletor
maletor / default.rb
Created February 9, 2012 10:23 — forked from stigkj/default.rb
A simple Chef recipe to install Jenkins
#
# Cookbook Name:: jenkins
# Recipe:: default
#
# https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
# This is super-simple, compared to the other Chef cookbook I found
# for Jenkins (https://github.com/fnichol/chef-jenkins).
#
# This doesn't include Chef libraries for adding Jenkin's jobs via