A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.
One-line version to paste in your DevTools
Use $$
if your browser aliases it:
~ 108 byte version
type printable = Printable : 'a * ('a-> string) -> printable;; | |
let myList = [Printable (2, string_of_int); Printable (true, string_of_bool)];; | |
let printPrintable: printable -> string = fun p -> | |
let Printable (data, printer) = p in | |
printer data | |
;; | |
let printables = [Printable (2, string_of_int); Printable (true, string_of_bool)];; | |
let results = List.map printPrintable printables;; |
function mapValues(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
result[key] = fn(obj[key], key); | |
return result; | |
}, {}); | |
} | |
function pick(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
if (fn(obj[key])) { |
// The classic AJAX call - dispatch before the request, and after it comes back | |
function myThunkActionCreator(someValue) { | |
return (dispatch, getState) => { | |
dispatch({type : "REQUEST_STARTED"}); | |
myAjaxLib.post("/someEndpoint", {data : someValue}) | |
.then( | |
response => dispatch({type : "REQUEST_SUCCEEDED", payload : response}), | |
error => dispatch({type : "REQUEST_FAILED", error : error}) | |
); |
Proposal for a lightning talk at the Reactive 2016.
Keep calm and like/retweet it on Twitter and star this Gist to vote on this talk.
I work at Grammarly. We like React and happily use it in our applications. However, sometimes something goes wrong and bugs creep into the code. Here comes testing. It helps make us confident about the quality of our code.
function asyncToReact(fn) { | |
class PromiseComponent extends React.Component { | |
state = { waiting: true, result: null }; | |
componentDidMount() { | |
fn(...this.props.args).then(result => this.setState({ waiting: false, result })); | |
} | |
componentDidUpdate() { | |
fn(...this.props.args).then(result => this.setState({ waiting: false, result })); | |
} | |
shouldComponentUpdate(newProps) { |
# for json | |
import json | |
from collections import OrderedDict | |
# for tl | |
import re | |
import struct | |
import binascii | |
__all__ = [ |
const Immutable = require('immutable-ext') | |
const {Just, Nothing} = require('data.maybe') | |
const Task = require('data.task') | |
// Setup | |
const Reader = f => | |
({ | |
run: f, | |
map: g => Reader(x => g(f(x))), |
{ | |
"α": { "body": "α", "prefix": "\\alpha" }, | |
"β": { "body": "β", "prefix": "\\beta" }, | |
"γ": { "body": "γ", "prefix": "\\gamma" }, | |
"δ": { "body": "δ", "prefix": "\\delta" }, | |
"ζ": { "body": "ζ", "prefix": "\\zeta" }, | |
"η": { "body": "η", "prefix": "\\eta" }, | |
"θ": { "body": "θ", "prefix": "\\theta" }, | |
"ι": { "body": "ι", "prefix": "\\iota" }, | |
"κ": { "body": "κ", "prefix": "\\kappa" }, |
git clone https://github.com/grishka/libtgvoip.git
cd libtgvoip
# Build openssl-1.0.1 and opus-1.1 to prefix libraries/
# Save CMakeLists.txt here (in repo root)
mkdir build
cd build
# Save CallMakefile and main.cpp here