Skip to content

Instantly share code, notes, and snippets.

View charlypoly's full-sized avatar
🚀
Building thriving devtools

Charly Poly charlypoly

🚀
Building thriving devtools
View GitHub Profile
@charlypoly
charlypoly / redux-form-framework.ts
Created June 6, 2018 12:27
Redux form framework
import * as React from 'react';
/* imports ... */
import { pick } from 'lodash';
class Form extends ModuleForm {
fields: FieldsDefinitions = {
id: 'none',
email: 'none',
picture_path: {
type: 'image', transformations: 'h_200,w_200,r_max,c_fill'
export interface BasicUserFragment {
id: string,
first_name: string,
last_name: string,
username: string | null,
picture_path: string | null,
active: boolean,
portfolio_id: string | null,
job_title: string | null,
email: string,
@charlypoly
charlypoly / example.pac
Created February 23, 2018 22:18
example.pac
function FindProxyForURL(url, host) {
// If the hostname matches, use proxy.
if (
shExpMatch(host, "*.aline.work") ||
shExpMatch(host, "aline.work") ||
shExpMatch(host, "*.ipify.org")
) {
return "PROXY xx.xx.xx.xx:8888";
}
// without TypeScript
import PropTypes from 'prop-types';
class Greeting extends React.Component {
render() {
return (
<h1>Hello, {this.props.name}</h1>
);
}
{
"anonymousId": "<removed>",
"context": {
"library": {
"name": "analytics.js",
"version": "3.2.5"
},
"page": {
"path": "<removed>",
"referrer": "<removed>",
exports.handler = (event, context, callback) => {
var AWS = require('aws-sdk');
AWS.config.update({region: 'eu-west-1'}); // configure region
const athena = new AWS.Athena();
athena.getNamedQuery({ NamedQueryId: '<your-query-id>' }, function(err, data) {
console.log('getNamedQuery', err, data);
if (!err) {
var params = {
QueryString: data.NamedQuery.QueryString,
import { NetworkStatus, isNetworkRequestInFlight } from 'apollo-client/core/networkStatus';
type isNetworkTransitionArg = {
networkStatus: NetworkStatus;
};
export enum NetworkTransition {
LOADED_DATA,
WAS_IN_CACHE,
LOADING,
interface Person {
id: string;
name: string;
}
function sayHello(person: Person) {
console.log(person.name);
}
sayHello({} as any);
class Hash
# {'x'=>{'y'=>{'z'=>1,'a'=>2}}}.leaves == [1,2]
def leaves
leaves = []
each_value do |value|
if value.is_a?(Hash)
value.leaves.each{|l| leaves << l }
elsif value.is_a?(Array)
value.each{|l| leaves << l }