The only cross-platform browser that fits in a Gist!
One line install. Works on Linux, MacOSX and Windows.
$> npm install http://gist.github.com/morganrallen/f07f59802884bcdcad4a/download
#!/bin/bash | |
function is_mac() { | |
if [ `uname -s` = "Darwin" ]; then | |
return 0 | |
else | |
return 1 | |
fi | |
} |
/** | |
* @param {Event} evt | |
* @return {Object} | |
*/ | |
function getMousePosition(evt) { | |
var pageX = evt.pageX; | |
var pageY = evt.pageY; | |
if (pageX === undefined) { | |
pageX = evt.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; |
tears.io { | |
header / { | |
# Enable HTTP Strict Transport Security (HSTS) to force clients to always connect via HTTPS | |
Strict-Transport-Security "max-age=31536000;" | |
# Enable cross-site filter (XSS) and tell browser to block detected attacks | |
X-XSS-Protection "1; mode=block" | |
# Prevent some browsers from MIME-sniffing a response away from the declared Content-Type | |
X-Content-Type-Options "nosniff" | |
# Disallow the site to be rendered within a frame (clickjacking protection) | |
X-Frame-Options "DENY" |
import * as React from 'react'; | |
import { Component } from 'react'; | |
export default function HOCBaseRender<Props, State, ComponentState>( | |
Comp: new() => Component<Props & State, ComponentState>) { | |
return class HOCBase extends Component<Props, State> { | |
render() { | |
return <Comp {...this.props} {...this.state}/>; | |
} | |
} |
// TypeScript Playground: https://tsplay.dev/mq8eYN | |
/// <reference types="@types/jest" /> | |
import type { MatcherState } from 'expect'; | |
const matchers = { | |
toHaveWordsCount(this: MatcherState, sentence: string, wordsCount: number) { | |
// implementation redacted | |
}, |
// | |
// UIImage+H568.m | |
// | |
// Created by Angel Garcia on 9/28/12. | |
// Copyright (c) 2012 angelolloqui.com. All rights reserved. | |
// | |
#import <objc/runtime.h> | |
@implementation UIImage (H568) |
"For comprehension" is a another syntaxe to use map
, flatMap
and withFilter
(or filter) methods.
yield
keyword is used to aggregate values in the resulting structure.
This composition can be used on any type implementing this methods, like List
, Option
, Future
...
curl -i -H 'Content-type: application/json' -H 'Authorization: key=<your_server_key>' -XPOST https://fcm.googleapis.com/fcm/send -d '{ | |
"registration_ids":["registration_ids", "of the", "target", "devices as array"], | |
"notification": { | |
"title":"Title of your notification", | |
"body":"content of your notification" | |
}, | |
"data": { | |
"key1" : "value1", | |
"key2" : "value2", | |
"key3" : 23.56565, |
package com.thurloat.foo; | |
import org.codehaus.jackson.annotate.JsonIgnore; | |
import org.codehaus.jackson.annotate.JsonProperty; | |
/** | |
* In order to write a composite data property (stats) out to JSON without reading | |
* it back in, you need to explicitly ignore the property, as well as the setter and | |
* then apply the @JsonProperty annotation to the getter. | |
**/ |