Skip to content

Instantly share code, notes, and snippets.

View bhalash's full-sized avatar
💭
🌈

Mark bhalash

💭
🌈
  • Ireland
View GitHub Profile
@bhalash
bhalash / fizzbuzz.js
Created May 25, 2016 16:41
Recursive JavaScript Fizzbuzz
(function fizzbuzz(number, max) {
var fizz = '';
number = number || 1;
max = max || 100;
if (!(number % 5)) {
fizz += 'fizz';
}
@bhalash
bhalash / add_locale_string.rb
Last active June 6, 2016 15:27
Add Locale Strings
#!/usr/bin/env ruby
require 'yaml'
#
# Consts
#
PROG_VERSION = '1.0.0'
PROG_NAME = 'add_locale_string'
@bhalash
bhalash / instasort.sh
Created June 21, 2016 08:45
Sort Dropbox-uploaded photographs
#!/usr/bin/env zsh
#
# Functions
#
#
# Check if Photograph is Square
#
var doublers = [
n => n * 2,
n => n + n,
n => n << 1
];
var double = n => _.sample(doublers)(n),
verifyDoubling = (n, x) => n * 2 === x;
var a = [];
@bhalash
bhalash / numbers.js
Last active December 15, 2016 11:58
Numbers to Binary
const seconds = days => parseFloat(days) * 86400;
const milliseconds = seconds => parseFloat(seconds) * 1000;
const binary = milliseconds => (milliseconds >> 0).toString(2);
function compose(a, b) {
return function(c) {
return b(a(c));
}
}

Someone recently asked the following question in the discussion forum of the Rubyists LinkedIn group: What separates a junior Rails developer from a senior one?

My response follows. Join us at http://www.linkedin.com/groups?gid=120725 to weigh in on this and other topics of interest to Rubyists. As of today there are almost 1,200 members, including numerous movers and shakers in the Ruby and Rails communities.

Distinguishing between junior and senior people in the Rails world is not so different from making the distinction in other web development environments.

Junior Rails people have not dealt with scaling issues to the degree that senior people have. Getting a public-facing Rails application to perform under significant stress is more challenging than doing the same with other building materials such as PHP. Senior people know how to performance-test Rails applications, where to look for bottlenecks, and how to eliminate them one after another until performance is acceptable in real conditions

#!/usr/bin/env bash
#
# Sort automatically-uploaded Dropbox photographs and videos into correct
# folders after removing crud like gifs and screenshots:
#
# 1. A dated folder (e.g. 1970-01-01 for an image taken on January, 1970) for
# non-square (non-Instagram) images.
# 2. My dump folder for square Instagram images.
#
# Blame Mark ([email protected]) for this.
@bhalash
bhalash / likes.rb
Created September 6, 2017 10:37
Like/Dislike Model Example Code
# Add given object to self's liked objects.
#
# @example
#
# @user.like Post.first
# @user.public_send('liked_posts') << Post.first
# @uuse.liked_posts << Post.first
#
# @param obj [ApplicationRecord::Likeable] Any likeable record.
@bhalash
bhalash / questions.md
Last active October 18, 2017 09:57
Fiendishly-Difficult Candidate Questions (Muahahahahaha)

Problem 1

Reverse all characters in a string.

'Bob Ate Fresh Gummy Karate Monkeys' => 'syeknoM etaraK ymmuG hserF etA boB'

Problem 2

Reverse only the order of words in a string.

'Bob Ate Fresh Gummy Karate Monkeys' => 'Monkeys Karate Gummy Fresh Ate Bob'

@bhalash
bhalash / yarn.config
Last active October 17, 2017 16:43 — forked from sealocal/yarn.config
Install Yarn and NodeJS on AWS Elastic Beanstalk EC2 Instance with Amazon Linux Ruby Platform, prior to precompiling assets for a Rails app
# vim: set ft=yaml:
# @see https://gist.github.com/sealocal/0cd468ba4f12cdada436aebe534b40da
---
files:
'/opt/elasticbeanstalk/hooks/appdeploy/pre/09_yarn_install.sh':
mode: '000775'
owner: root
group: users
content: |
#!/bin/bash