Skip to content

Instantly share code, notes, and snippets.

View steve8708's full-sized avatar
😄

Steve Sewell steve8708

😄
View GitHub Profile
@kristopherjohnson
kristopherjohnson / pipe-forward.swift
Last active March 29, 2024 19:44
Swift: define F#-style pipe-forward (|>) operator that evaluates from left to right.
// F#'s "pipe-forward" |> operator
//
// Also "Optional-chaining" operators |>! and |>&
//
// And adapters for standard library map/filter/sorted
infix operator |> { precedence 50 associativity left }
infix operator |>! { precedence 50 associativity left }
infix operator |>& { precedence 50 associativity left }
infix operator |>* { precedence 50 associativity left }
@sdiehl
sdiehl / state.hs
Created January 13, 2015 18:44
State monad implementation + example
import Control.Monad
-------------------------------------------------------------------------------
-- State Monad Implementation
-------------------------------------------------------------------------------
newtype State s a = State { runState :: s -> (a,s) }
instance Monad (State s) where
return a = State $ \s -> (a, s)
@agentgt
agentgt / eclipse-one-dark-like.xml
Last active July 4, 2024 00:53
One Dark Atom Theme for Eclipse for the Eclipse Color Theme plugin
<?xml version="1.0" encoding="utf-8"?>
<colorTheme id="9999" name="One Dark Like" modified="2015-09-01 19:55:49" author="Adam Gent" website="http://snaphop.com">
<searchResultIndication color="#E5C07B" />
<filteredSearchResultIndication color="#E5C07B" />
<occurrenceIndication color="#4B4E55" />
<writeOccurrenceIndication color="#4B4E55" />
<findScope color="#4B4E55" />
<deletionIndication color="#DF5F5F" />
<sourceHoverBackground color="#4B4E55" />
<singleLineComment color="#969896" italic="false" />
@nikhan
nikhan / twitter.sh
Created January 1, 2016 04:45
twitter ffmpeg
ffmpeg -i test.mov -vcodec libx264 -vf 'scale=640:trunc(ow/a/2)*2' -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100 -strict experimental -r 30 out.mp4
@DamianEdwards
DamianEdwards / json-in-markdown.md
Last active November 6, 2024 21:20
JSON comments on GH

What happens if you tell GitHub it's JSON

{
  "hello": "world" // I want my comments!
}

Use jsonc as the language instead

{
@Rich-Harris
Rich-Harris / service-workers.md
Last active November 5, 2024 06:39
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

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:

@WebReflection
WebReflection / hyper-lit.md
Last active November 8, 2022 03:55
lit-html is awesome, but it came afterwards

The history of hyperHTML followed by lit-html

While many remember the epic hyperHTML: A Virtual DOM Alternative post I've published the 5th of March 2017, the first official implementation of the library was working as hyperHTML.bind(node) function for tagged literals the day before, and it's been in my experiments folder already for a little while.

The hilarious reaction from the skeptical community

At first glance people couldn't believe performance of the DBMonster demo shown in that article,

@daybrush
daybrush / JavaScriptCore+fetch.swift
Created March 7, 2019 07:19 — forked from yycking/JavaScriptCore+fetch.swift
add fetch, console.log and Promise.then/catch to JavaScriptCore on iOS/Mac
import JavaScriptCore
extension JSContext {
subscript(key: String) -> Any {
get {
return self.objectForKeyedSubscript(key)
}
set{
self.setObject(newValue, forKeyedSubscript: key as NSCopying & NSObjectProtocol)
}
@raghubetina
raghubetina / builder-io-404.md
Last active September 22, 2022 21:33
Delegating 404s to builder.io in Rails

Delegating 404s to builder.io in Rails

Give builder.io a chance to respond to paths that you don't have a route for before serving up a 404 page:

  1. In Gemfile, add gem 'rack-cors' and bundle.

  2. In config/application.rb, add:

     config.middleware.insert_before 0, Rack::Cors do
       allow do