Skip to content

Instantly share code, notes, and snippets.

@freddi301
freddi301 / AsyncNode.tsx
Last active August 26, 2019 09:59
React component and hook for rendering promises
export function AsyncNode({ children }: { children: Promise<ReactNode> }) {
return useLatestResolvedValue<ReactNode>(children, () => null) as any;
// as any assertion needed for issue https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20356#issuecomment-336384210
}
export function useLatestResolvedValue<Value>(
promise: Promise<Value>,
initial: () => Value
) {
const [[value], dispatch] = useReducer<
@jmoy
jmoy / thin-film.ipynb
Last active November 18, 2018 19:51
Why soap bubbles are colorful and windowpanes are not
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Motivation

  • expression-oriented programming one of the great advances of FP
  • expressions plug together like legos, making more malleable programming experience in-the-small

Examples

Write in an expression-oriented style, scoping variables as locally as possible:

@MotiurRahman
MotiurRahman / index.js
Created September 5, 2015 07:24
Date Picker using showDatePickerDialog() (Android only)
var picker = Ti.UI.createPicker({
type : Ti.UI.PICKER_TYPE_DATE,
top : 50
});
$.txt.addEventListener('click', function(e) {
picker.showDatePickerDialog({
callback : function(e) {
if (e.cancel) {
Ti.API.info('User canceled dialog');
@morganrallen
morganrallen / _README.md
Last active January 15, 2023 19:41
Janky Browser

JankyBrowser

The only cross-platform browser that fits in a Gist!

One line install. Works on Linux, MacOSX and Windows.

Local Install

$&gt; npm install http://gist.github.com/morganrallen/f07f59802884bcdcad4a/download

Possible jQuery plugins

I'm contemplating two new jQuery plugins, but wanted some feedback, both on the implementation, as well as if it's worth doing.

Here are the two pieces of functionality/problems I'm hoping to address (and they're somewhat related):

Problem/Feature 1

YUI has a feature in Nodes and NodeLists with .get. It supports both:

@FokkeZB
FokkeZB / index.js
Last active November 5, 2015 17:15
Checking for Titanium API objects
var jsObject = {
foo: 'bar'
};
var tiObject = Ti.UI.create2DMatrix();
function isJsObject(obj) {
return typeof obj.__proto__ !== 'undefined';
}
@pburtchaell
pburtchaell / styles.css
Last active February 25, 2024 12:24
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/
@duemunk
duemunk / Guilty
Last active June 23, 2016 12:11
Operator overload badge
<img src="http://img.shields.io/badge/Operator_overload-guilty-red.svg" height="20" alt="Uses operator overloads"/>
@kyledrake
kyledrake / ferengi-plan.txt
Last active April 6, 2024 00:30
How to throttle the FCC to dial up modem speeds on your website using Nginx
# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited
#
# Current known FCC address ranges:
# https://news.ycombinator.com/item?id=7716915
#
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft
#
# In your nginx.conf:
location / {