Skip to content

Instantly share code, notes, and snippets.

@urjitbhatia
urjitbhatia / custom_download_strategy.rb
Created January 18, 2019 22:14
A custom vendored github private release homebrew tap formula
require "json"
require "rexml/document"
require "time"
require "unpack_strategy"
require "lazy_object"
require "cgi"
class AbstractDownloadStrategy
extend Forwardable
include FileUtils
import React, { createContext, useState, useContext } from "react";
const context = createContext({
activeTabId: "a",
changeTab: (id: string) => {}
});
const Tab = ({ id, children }: any) => {
const tab = useContext(context);
return <div onClick={() => tab.changeTab(id)}>{children}</div>;
@sidneys
sidneys / de.sidneys.jxa.toggle-macos-accessibility-keyboard.scpt
Last active June 21, 2022 03:29
JavaScript for Automation (JXA) | Toggle macOS Accessibility Keyboard
/**
* toggle-macos-accessibility-keyboard
* javascript for automation (jxa)
*
* description:
* macOS automation script to toggle the macOS Accessibility Keyboard.
* Shows and hides the keyboard depending on its current state.
*
* author: sidneys
* homepage: http://sidneys.github.io

How we incorporate next and cloudfront (2018-04-21)

Feel free to contact me at robert.balicki@gmail.com or tweet at me @statisticsftw

This is a rough outline of how we utilize next.js and S3/Cloudfront. Hope it helps!

It assumes some knowledge of AWS.

Goals

const React = require("react");
const Lifecycles = React.createLifecycleEvents({
didMount({ setState }) {
setState({
disabled: false,
});
},
didUpdate({ inputRef }) {
if (document.activeElement !== inputRef.value) {
@bvaughn
bvaughn / updating-subscriptions-when-props-change-example.js
Last active March 27, 2022 09:29
Advanced example for manually updating subscriptions in response to props changes in an async-safe way
// This is an advanced example! It is not typically required for application code.
// If you are using a library like Redux or MobX, use the container component provided by that library.
// If you are authoring such a library, use the technique shown below.
// This example shows how to safely update subscriptions in response to props changes.
// In this case, it is important to wait until `componentDidUpdate` before removing a subscription.
// In the event that a render is cancelled before being committed, this will prevent us from unsubscribing prematurely.
// We also need to be careful about how we handle events that are dispatched in between
// `getDerivedStateFromProps` and `componentDidUpdate` so that we don't put stale values into the `state`.
@raganwald
raganwald / sequence.es6
Last active June 18, 2017 09:31
Generating sequences using iterators and without integers or arrays
/////////////////////////////////////////////////////////////////////////////////
// Generating "A Sequence Problem" using iterators, without integers or arrays //
// See http://raganwald.com/2017/06/04/sequences.html //
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// Generic things useful for working with interables and iterators //
/////////////////////////////////////////////////////////////////////
// 1. These operations produce repeatable iterables.
// @flow
function getOptions() {
return { num: 42, str: "val" };
// ^ Type of this return is inferred without type annotation.
}
/*::
// ^ Comments like this are part of Flow's Comment Syntax.
// They allow you to include any additional syntax and Flow will parse it
@peterhellberg
peterhellberg / graceful.go
Last active August 20, 2023 08:49
*http.Server in Go 1.8 supports graceful shutdown. This is a small example.
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)
@chrisdone
chrisdone / expression_problem.hs
Created November 2, 2016 11:34 — forked from elnygren/expression_problem.clj
Solving the Expression Problem with Haskell
{-# LANGUAGE NamedFieldPuns #-}
-- The Expression Problem and my sources:
-- http://stackoverflow.com/questions/3596366/what-is-the-expression-problem
-- http://blog.ontoillogical.com/blog/2014/10/18/solving-the-expression-problem-in-clojure/
-- http://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/
-- http://www.ibm.com/developerworks/library/j-clojure-protocols/
-- To begin demonstrating the problem, we first need some