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 / gist:5618929
Last active December 17, 2015 13:39
Top level Request error handler - Similar to $.ajaxError in JQuery Example with PHP exception print in JSON by the remote server.
/*
* Top level Request error handler
* - Similar to $.ajaxError in JQuery
*/
Class.refactor(Request, {
__refactor_default_onComplete : null,
initialize : function(options) {
@charlypoly
charlypoly / angular.filters.nl2br.js
Last active August 29, 2015 14:06 — forked from naoyeye/angular.filters.nl2br.js
use strict compliant version + handle undefined case
/*
# Usage in html template:
"xxx | nl2br"
<div ng-bind-html=" YourString | nl2br "></div>
or:
@charlypoly
charlypoly / updateDirectiveIsolateScope.js
Created October 9, 2014 22:21
Angular testing: update directive isolate scope helper
function updateIsolateScope (element, data) {
var directiveScope = element.isolateScope();
directiveScope = angular.extend(directiveScope, data);
element.data('$isolateScope', directiveScope);
}
@charlypoly
charlypoly / yaml_i18n_merge.rb
Last active November 5, 2015 15:07
Merge all yaml locale files into one by locale
# to run in a Rails console !
def returning(value)
yield(value)
value
end
class Hash
def deep_reject_key!(key)
keys.each {|k| delete(k) if k == key || self[k] == self[key] }
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 }
interface Person {
id: string;
name: string;
}
function sayHello(person: Person) {
console.log(person.name);
}
sayHello({} as any);
import { NetworkStatus, isNetworkRequestInFlight } from 'apollo-client/core/networkStatus';
type isNetworkTransitionArg = {
networkStatus: NetworkStatus;
};
export enum NetworkTransition {
LOADED_DATA,
WAS_IN_CACHE,
LOADING,
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,
{
"anonymousId": "<removed>",
"context": {
"library": {
"name": "analytics.js",
"version": "3.2.5"
},
"page": {
"path": "<removed>",
"referrer": "<removed>",