This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hyperx = require('hyperx') | |
const hx = hyperx((componentName, properties, children) => { | |
return ['createElement', componentName, properties, children] | |
}, (children) => { | |
return ['createFragment', children] | |
}) | |
class Header { | |
async fetch (ctx) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sorter () { return 0.5 - Math.random() } | |
var styles = [ 'blaze', 'sunshine', 'dusk', 'blood', 'puce' ] | |
function colorize () { | |
var style = styles.sort(sorter)[0] | |
document.body.className = style | |
} | |
colorize() | |
setInterval(colorize, 10000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension URL { | |
func appendingQueryItems(_ items: [String: String]) -> URL { | |
guard var components = URLComponents(url: self, resolvingAgainstBaseURL: false) else { | |
fatalError() | |
} | |
var query = components.queryItems ?? [] | |
items.forEach { (name, value) in | |
query.append(URLQueryItem(name: name, value: value)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Names: SimplePublisher { | |
typealias Output = Result<String, Error> | |
var subscriptions = [SimpleSubscription<Output, Failure>]() | |
let names = ["Alice", "Bob", "Claris", "Doug"] | |
shoutName() { | |
if let name = names.randomElement() { | |
publish(.success(name)) | |
} else { | |
assertionFailure("There are def some names in there...") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Combine | |
extension Subscribers { | |
final public class Forever<Upstream: Publisher>: Subscriber, Cancellable, CustomStringConvertible { | |
public typealias Input = Upstream.Output | |
public typealias Failure = Upstream.Failure | |
private var subscription: Subscription? = nil | |
private let receiveCompletion: (Subscribers.Completion<Failure>) -> Void |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE EXTENSION IF NOT EXISTS "unaccent" | |
CREATE OR REPLACE FUNCTION slugify("value" TEXT) | |
RETURNS TEXT AS $$ | |
-- removes accents (diacritic signs) from a given string -- | |
WITH "unaccented" AS ( | |
SELECT unaccent("value") AS "value" | |
), | |
-- lowercases the string | |
"lowercase" AS ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
which heroku > /dev/null | |
if [[ "$?" != "0" ]]; then | |
echo "You need to brew install heroku" | |
exit 1 | |
fi | |
heroku local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rel/config.exs | |
# ... | |
environment :prod do | |
# ... | |
plugin(Example.Phoenix) | |
end | |
# ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function create (name) { | |
const nameStart = `${name} start` | |
window.performance.mark(nameStart) | |
return { | |
log: () => { log(name) }, | |
end: () => { end(name) } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{- $src := .Get "src" }} | |
{{- $s := newScratch }} | |
{{- if eq (len (findRE "^/" $src)) 0 }} | |
{{- $s.Set "res" ($.Page.Resources.GetMatch $src) }} | |
{{- with ($s.Get "res") }} | |
{{- $s.Set "src" .Permalink }} | |
{{- if ne (len (findRE "@2x" .Permalink)) 0 }} | |
{{- $s.Set "width" (div .Width 2) }} | |
{{- $s.Set "height" (div .Height 2) }} |