Skip to content

Instantly share code, notes, and snippets.

View bhalash's full-sized avatar
💭
🌈

Mark bhalash

💭
🌈
View GitHub Profile
@bhalash
bhalash / promisify.ts
Last active September 16, 2024 20:11
homebrew recreation of util.promisify
/**
* My original mistake was trying to pluck the argument and return types using
* the Parameters<Fn> and Arguments<Fn> generic helpers. It...got messy.
*
* The method overrides act like a switch statement for type. When given a
* function as an argument, Typescript looks through the overrides to see which
* one matches.
*
* Take this function, which takes a callback and prints out the given name
* through it:
@bhalash
bhalash / input.scss
Created November 22, 2021 15:47
Generated by SassMeister.com.
@use 'sass:map';
$spacers: (
0: 0,
1: 0.25rem,
2: 0.5rem,
3: 1rem,
4: 1.5rem,
5: 2.75rem,
6: 3rem,
@bhalash
bhalash / input.scss
Created November 22, 2021 13:17
Generated by SassMeister.com.
@use 'sass:map';
$spacers: (
0: 0,
1: 0.25rem,
2: 0.5rem,
3: 1rem,
4: 1.5rem,
5: 2.75rem,
6: 3rem,
@bhalash
bhalash / AngularDateHttpInterceptor.ts
Last active January 24, 2019 15:47 — forked from martinobordin/AngularRxJs5DateHttpInterceptor.ts
An Angular (> 4.3) interceptor to parse dates from server response.
/**
* Recursively walk HttpResponse object to cast ISO 8601-formatted dates as
* Moment.js objects.
*
* @see https://git.io/fNzJw
* @see https://www.npmjs.com/package/is-iso-date
* @see https://www.npmjs.com/package/traverse
*/
import { Injectable } from '@angular/core';
@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
@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 / 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.
#!/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.

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

@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));
}
}