Skip to content

Instantly share code, notes, and snippets.

@krisys
krisys / swype.py
Last active August 10, 2022 15:58
How swype works?
'''
The MIT License (MIT)
Copyright (c) 2013 Krishna Bharadwaj <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@ddeville
ddeville / gist:1527517
Created December 28, 2011 10:40
MIME type to UTI and back again in Cocoa
#if TARGET_OS_IPHONE
#import <MobileCoreServices/MobileCoreServices.h>
#else
#import <CoreServices/CoreServices.h>
#endif
/*
MIME type to UTI
*/
NSURLResponse *response = ... // assume a URL response from somewhere else.
@mattmccray
mattmccray / PopoverSupport.js
Created March 23, 2015 17:23
Popover (portal) support as an HOC (decorator)...
import {stopEvent, hoistStatics} from 'util'
let Types= React.PropTypes,
_globalContainer= null
export const PopoverSupport= Wrapped => {
class PopoverSupport extends React.Component {
// static propTypes= Wrapped.propTypes // Won't this be nice?
import React, { Component } from 'react'
class ScrollPosition extends Component {
state = {
top: 0,
left: 0
}
render() {
const child = this.props.children(this.state)
import { Component } from 'react'
import { createStore, combineReducers } from 'redux'
import parseLinkHeader from 'parse-link-header'
const START = 'start'
const SUCCEED = 'succeed'
const ERROR = 'error'
const inflight = (state={}, action) => (
((state) => (
import React, { Component } from 'react'
import { View, Image, StyleSheet, ScrollView, Text, Animated, StatusBar, PixelRatio } from 'react-native'
import Icon from 'react-native-vector-icons/MaterialIcons';
import MapView from 'react-native-maps';
const AMSTERDAM = {
latitude: 52.3702,
longitude: 4.8952,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
@mattdesl
mattdesl / really-big-image.js
Created June 5, 2017 16:19
CPU-side "shaders" for really big image rendering
/*
This streams a CPU-side "shader" function into a really huge PNG image.
*/
const PNGEncoder = require('png-stream/encoder');
const fs = require('fs');
const path = require('path');
const Readable = require('readable-stream').Readable;
const vec2 = require('gl-vec2');
const smoothstep = require('smoothstep');
@developit
developit / *state-machine-component.md
Last active February 6, 2021 00:44
265b lib for building pure functional state machine components. https://github.com/developit/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

🔥 JSFiddle Demo

Usage

The API is a single function that accepts 2 pure functions as arguments:

Using server-sent events

Why and how?

  • Documentation: https://web.dev/articles/eventsource-basics
  • Use case: broadcasting data from server to browsers
  • Benefits:
    • Easy to understand and implement (only a few lines of code)
    • No library is needed
  • Can use same HTTP(S) authentication as elsewhere in the app (which can’t be done with websockets)
@GeeWizWow
GeeWizWow / plink-honk.js
Last active October 16, 2023 06:50 — forked from tomhicks/plink-plonk.js
Listen to your web pages