Skip to content

Instantly share code, notes, and snippets.

View hayksaakian's full-sized avatar
🏠
Working from home

Hayk Saakian hayksaakian

🏠
Working from home
View GitHub Profile
#!/usr/bin/ruby
# started at 2:29
# 1
test_list = [42, 512, 7, 3, 11]
# use builtin summing function
expected_value = test_list.reduce(:+)
def sum_for(list)
var moment = require('moment');
var tz = require('moment-timezone');
var timePlugin = {
init: function (client, imports) {
return {
exports: null,
handlers: {
'!time': function (message) {
var timeNow = moment().tz('America/Chicago').format('ddd, h:mm A');
@hayksaakian
hayksaakian / dijkstra
Created September 7, 2014 03:06
Dijkstra path finding in lua
function Dijkstra(start, finish, nodes)
--Create a closed and open set
local open = {}
local closed = {}
--Attach data to all noded without modifying them
local data = {}
for _, node in pairs(nodes) do
data[node] = {
distance = math.huge,
module.exports = function (req, res, next) {
res.locals.flash = {};
if(!req.session.flash) return next();
res.locals.flash = _.clone(req.session.flash);
req.session.flash = {};
next();
# Allow nil values but not zero length strings
validates_length_of :title, :minimum => 1, :allow_nil => true
# Allow zero length strings but not nils
validates_length_of :body, :minimum => 0, :allow_nil => false
@hayksaakian
hayksaakian / git console
Created February 16, 2014 21:18
learning rebase
Hayk-Saakians-Mac:extempengine hayk$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: transitioning to mongoid 3
Using index info to reconstruct a base tree...
M Gemfile
M Gemfile.lock
<stdin>:18: trailing whitespace.
gem 'mongoid-locker' #
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge...
@staticmethod
def get_adjacent_robots(self, game, player_comparator=None):
def generate():
for loc,bot in game.get('robots').items():
if rg.wdist(loc, self.location) <= 1:
if player_comparator == None or player_comparator(self.player_id, bot.player_id):
yield (loc, bot)
return dict(generate())
@hayksaakian
hayksaakian / css is awful
Created May 2, 2013 05:17
awful css. how to do semantic row-fluid?
@testColor: #ff0000;
section#body_content {
#grid > .fluid > .row-fluid;
h1#body_content_title {
#grid > .fluid > .row-fluid;
color: @testColor;
}
/* section#body {
#grid > .fluid > .span(8);
}
@hayksaakian
hayksaakian / log
Created April 5, 2013 01:32
roadie error
Roadie cannot use "(function( window" when inlining stylesheets
Roadie cannot use "undefined )" when inlining stylesheets
Roadie cannot use "" when inlining stylesheets
Roadie cannot use "// Clean-up method for dom ready events\ndetach = function()" when inlining stylesheets
Roadie cannot use ";\njQuery.fn = jQuery.prototype =" when inlining stylesheets
Roadie cannot use "return this;\n// HANDLE: $(#id)\nelse" when inlining stylesheets
Roadie cannot use "this.context = document;\nthis.selector = selector;\nreturn this;\n// HANDLE: $(expr" when inlining stylesheets
Roadie cannot use "$(...))\nelse if ( !context || context.jquery )" when inlining stylesheets
Roadie cannot use "// HANDLE: $(DOMElement)\nelse if ( selector.nodeType )" when inlining stylesheets
Roadie cannot use "else if ( jQuery.isFunction( selector ) )" when inlining stylesheets
@hayksaakian
hayksaakian / error
Created March 24, 2013 03:41
undefined method `tzinfo' for nil:NilClass
rake aborted!
undefined method `tzinfo' for nil:NilClass
(in /tmp/build_14qw7djnbp2vr/vendor/bundle/ruby/2.0.0/bundler/gems/detect_timezone_rails-ba752d91669c/vendor/assets/javascripts/jquery.detect_timezone.js.erb)
/tmp/build_14qw7djnbp2vr/vendor/bundle/ruby/2.0.0/bundler/gems/detect_timezone_rails-ba752d91669c/vendor/assets/javascripts/jquery.detect_timezone.js.erb:34:in `block in singleton class'
/tmp/build_14qw7djnbp2vr/vendor/bundle/ruby/2.0.0/bundler/gems/detect_timezone_rails-ba752d91669c/vendor/assets/javascripts/jquery.detect_timezone.js.erb:-6:in `instance_eval'
/tmp/build_14qw7djnbp2vr/vendor/bundle/ruby/2.0.0/bundler/gems/detect_timezone_rails-ba752d91669c/vendor/assets/javascripts/jquery.detect_timezone.js.erb:-6:in `singleton class'
/tmp/build_14qw7djnbp2vr/vendor/bundle/ruby/2.0.0/bundler/gems/detect_timezone_rails-ba752d91669c/vendor/assets/javascripts/jquery.detect_timezone.js.erb:-8:in `__tilt_70150981721640'
/tmp/build_14qw7djnbp2vr/vendor/bu