Skip to content

Instantly share code, notes, and snippets.

View imranismail's full-sized avatar

Imran Ismail imranismail

View GitHub Profile
@imranismail
imranismail / how-to-set-up-stress-free-ssl-on-os-x.md
Created September 30, 2017 10:40 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@imranismail
imranismail / params.ex
Last active April 14, 2022 11:08
Ecto as Parameter Validator
defmodule Web.InvalidParamsError do
defexception [:changeset, plug_status: 422]
def message(value) do
"""
Invalid parameters
#{inspect(error_messages(value.changeset))}
"""
end
@imranismail
imranismail / formatDistance.js
Created February 6, 2018 15:23
formatDistance for luxon extracted from date-fns
const FORMAT_DISTANCE_LOCALE = {
lessThanXSeconds: {
one: "'less than a second'",
other: "'less than 's' seconds'"
},
xSeconds: {
one: "s' second'",
other: "s' seconds'"
},
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@imranismail
imranismail / API.js
Last active March 20, 2018 03:41
Proper Fetch Error Handling
import { union } from 'folktale';
export default class API {
static Exceptions = union('API.Exceptions', {
NetworkError(error) {
return { error };
},
ServiceError(code, message) {
return { code, message };
},
@imranismail
imranismail / main.go
Last active June 10, 2018 12:27
main.go
package main
import (
"flag"
"fmt"
"log"
"encoding/json"
"github.com/valyala/fasthttp"
)
const Tree = union('Tree', {
Leaf(value) {
return { value }
},
Node(value, ...children) {
return { value, children }
}
})
const HTML = union('HTML', {
@imranismail
imranismail / README.md
Last active July 20, 2018 07:30
Fullstack Interview Question

Problem

We are in need of a new search component to help our users discover our amazing deals. You are tasked to implement this feature.

This feature requires a single backend endpoint as well as the component that consumes it.

Please write your code in a git repository.

Ensure proper commit message through out the exercise so that we can understand your thought process.

@imranismail
imranismail / DEPLOYMENT.md
Last active August 7, 2018 16:59
Continuously Delivered Elixir Apps

Deployment

TODO(@imranismail)