View prime.rb
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
factors = -> (n) { (1..n).select{|x| n % x === 0} } | |
prime = ->(n){ (factors === n) === [1,n] } | |
(1..).lazy.select(&prime).take(10).to_a |
View sleep.js
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
function sleep (time, arg) { | |
console.log(`Sleep started for ${arg}...`); | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
resolve(arg); | |
}, time); | |
}); | |
} | |
await sleep(1000, this.report.pagination.pageNumber) |
View ar_arel_wrapper.rb
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 'active_record' | |
require 'arel' | |
# Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0). | |
# | |
# What you would usually write like this: | |
# | |
# User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"]) | |
# | |
# can now be written like this (note those parentheses required by the operators precedences): |
View .eslintrc
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
# --------------------------------------------------------------------------------------------------------------------- # | |
# Conversion of http://eslint.org/docs/rules/ to an actual .eslintrc file: | |
# Copied: 04/01/2015 | |
# Updated to yaml format: 05/15/2015 | |
# Copied by: Ely De La Cruz <elycruz@elycruz.com> | |
# --------------------------------------------------------------------------------------------------------------------- # | |
# --------------------------------------------------------------------------------------------------------------------- # | |
# Environemnt Types: | |
# --------------------------------------------------------------------------------------------------------------------- # |
View node-cluster-messaging.js
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
var cluster = require('cluster'); | |
if (cluster.isWorker) { | |
console.log('Worker ' + process.pid + ' has started.'); | |
// Send message to master process. | |
process.send({msgFromWorker: 'This is from worker ' + process.pid + '.'}) | |
// Receive messages from the master process. |
View ruby_private_inheritance.rb
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
class Parent | |
attr_accessor :a, :b | |
def initialize(a) | |
@a = a | |
end | |
private | |
def set_b | |
@b = 'b' | |
end | |
end |
View cs-jq-plugin-template.coffee
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
# A class-based template for jQuery plugins in Coffeescript | |
# | |
# $('.target').myPlugin({ paramA: 'not-foo' }); | |
# $('.target').myPlugin('myMethod', 'Hello, world'); | |
# | |
# Check out Alan Hogan's original jQuery plugin template: | |
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template | |
# | |
(($, window) -> |
View string_sub_bm.rb
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' | |
N = 10_000_000 | |
Benchmark.bmbm do |bm| | |
bm.report('String') do | |
N.times do | |
a = 'devise/session' | |
a.sub('/', '-') | |
end |
View gist:0b5065619e862b54fef6
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
$ ssh egorov@hdp001.rdb | |
$ echo 42 > big_data.txt | |
$ hadoop fs -put big_data.txt /tmp | |
$ hadoop fs -ls /tmp | |
Found 1 item | |
-rw-r--r-- 3 egorov supergroup 3 2015-07-10 02:41 /tmp/big_data.txt | |
$ hadoop fs -du /tmp/big_data.txt | |
3 /tmp/big_data.txt | |
[egorov@hdp001 ~]$ hadoop fs -stat %o /tmp/big_data.txt | |
134217728 |
NewerOlder