Skip to content

Instantly share code, notes, and snippets.

Seivan Heidari seivan

Block or report user

Report or block seivan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:38996b3421ff946d6eb00d84fb8ed331
Shibboleths. Add these up and if you have an opinion on five - agreeing *or* disagreeing - we’d love to hear from you. Do these elicit strong feelings? See the note at the bottom.
- You understand discriminated unions, and how to use the type system to enforce exhaustive checks and other useful patterns.
- You can describe good and bad use cases for single page applications.
- You can describe why nullable types and a type system that enforces it are advantageous over type systems like Java’s.
- You can and have extracted declarative implementations out of imperative code. You know when it’s worth it and when it’s not.
View sdl_application.rs
use std::path::PathBuf;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::thread;
use std::os::raw::c_void;
use std::rc::Rc;
use std::cell::{Cell, RefCell};
use std::i16;
use std::time::Instant;
use failure::{err_msg, Error};
@teamon
teamon / box.ex
Created Aug 25, 2017
Define elixir structs with typespec with single line of code
View box.ex
defmodule Box do
defmacro __using__(_env) do
quote do
import Box
end
end
@doc """
Define module with struct and typespec, in single line
@bsedat
bsedat / Dockerfile
Last active Aug 1, 2019
Elixir Phoenix Umbrella App + Distillery Multistage Docker Build
View Dockerfile
FROM elixir:1.4.5 as asset-builder-mix-getter
ENV HOME=/opt/app
RUN mix do local.hex --force, local.rebar --force
# Cache elixir deps
COPY config/ $HOME/config/
COPY mix.exs mix.lock $HOME/
COPY apps/myproject_web/mix.exs $HOME/apps/myproject_web/
COPY apps/myproject_web/config/ $HOME/apps/myproject_web/config/
@stevedonovan
stevedonovan / shared.rs
Created Apr 14, 2017
An ergonomic way of saying Rc<RefCell>
View shared.rs
use std::rc::Rc;
use std::cell::{RefCell,Ref, RefMut};
use std::ops::Deref;
use std::fmt;
#[derive(Clone)]
struct Shared<T> {
v: Rc<RefCell<T>>
}
View LazyRoute.tsx
import * as React from "react";
import { observer } from "mobx-react";
import inject from "../store/Inject";
import { addTask } from "../module/task";
import { add, exists, fetch } from "../module/cache"
import { Match, Redirect } from "react-router";
import { default as load } from "../module/load";
import { ApplicationStore } from "../store/ApplicationStore";
import { UserStoreKey, UserStoreStructure } from "../store/UserStore";
@kharrison
kharrison / Country.swift
Last active Aug 17, 2018
Swift Hash Functions
View Country.swift
import Foundation
struct Country {
let name: String
let capital: String
var visited: Bool
}
extension Country: Equatable {
static func == (lhs: Country, rhs: Country) -> Bool {
@mrrooijen
mrrooijen / global_register.ex
Created Jan 2, 2017
Ensure that only one instance of a given (supervised) process exists in the cluster.
View global_register.ex
defmodule Party.Clock do
use GenServer
def start_link do
case GenServer.start_link(__MODULE__, [], name: {:global, __MODULE__}) do
{:ok, pid} ->
{:ok, pid}
{:error, {:already_started, pid}} ->
IO.puts("Already started!!")
Process.link(pid)
@redrabbit
redrabbit / absinthe_ecto_resolution_schema.ex
Last active Jul 26, 2018
Absinthe.Ecto.Resolution.Schema
View absinthe_ecto_resolution_schema.ex
defmodule Absinthe.Ecto.Resolution.Schema do
@moduledoc """
This module provides helper functions to resolve a GraphQL query into `Ecto.Query`.
"""
import Absinthe.Resolution.Helpers
import Ecto.Query
alias Absinthe.Resolution
alias Absinthe.Blueprint.Document.Field
@shavit
shavit / broadcast_udp.swift
Created Nov 14, 2016
Send a message using UDP in Swift 3
View broadcast_udp.swift
//: Playground - noun: a place where people can play
import Cocoa
import Darwin
func htons(value: CUnsignedShort) -> CUnsignedShort {
return (value << 8) + (value >> 8)
}
let INADDR_ANY = in_addr(s_addr: 0)
You can’t perform that action at this time.