Skip to content

Instantly share code, notes, and snippets.

@alfrescian
alfrescian / Flash.jsx
Last active April 24, 2019 07:48
highlight component when (re-)rendered
import React from "react";
export default function Flash({ type, ...props }) {
const elRef = React.useRef();
React.useEffect(() => {
window.requestAnimationFrame(() => {
elRef.current.style["box-shadow"] = "0 0 0 2px red";
elRef.current.style["transition"] = "none";
window.requestAnimationFrame(() => {
@alfrescian
alfrescian / useSimpleState.ts
Created April 9, 2019 07:01
useSimpleState hook
import React, {
createContext,
useContext,
useReducer,
Reducer,
Context,
Dispatch,
ReactNode,
Provider,
ReactElement
@alfrescian
alfrescian / HOWTO.md
Last active April 5, 2018 19:12 — forked from cvan/HOWTO.md
get all GET URLs of all network requests made on a web page from the Chrome Dev Tools (from an exported HAR)

Setup

Using Homebrew on Mac OS X:

brew install jq

Add these aliases to your profile (e.g., ~/.zshrc, ~/.bashrc, ~/.profile, etc.):

alias getUrls='pbpaste | jq ".log.entries" | tee >(jq --raw-output "[.[] | select(.request.method == \"GET\")|.request.url] | .[]")'

alias getUrlsTime='pbpaste | jq ".log.entries" | tee >(jq --raw-output "[.[] | select(.request.method == "GET")|.request.url,"blocked :"+(.timings.blocked|tostring),"wait: " + (.timings.wait|tostring), "receive: " + (.timings.receive|tostring)] | .[]")'

@alfrescian
alfrescian / Gruntfile.js
Created February 12, 2015 18:34
basic grunt-atomify + eslint
module.exports = function (grunt) {
'use strict';
var filesToLint = [
'<%= srcDir %>/**/*.js'
];
require('load-grunt-tasks')(grunt);
grunt.initConfig({
@alfrescian
alfrescian / bookmarklet.js
Last active August 29, 2015 14:14
Angular $watch count
javascript: (function () { var root = $(document.getElementsByTagName('body')); var watchers = []; var f = function (element) { if (element.data().hasOwnProperty('$scope')) { angular.forEach(element.data().$scope.$$watchers, function (watcher) { watchers.push(watcher); }); } angular.forEach(element.children(), function (childElement) { f($(childElement)); }); }; f(root); console.log(watchers.length);})();
@alfrescian
alfrescian / start-wf-assigned-to-site-group.js
Created June 25, 2014 07:41
Start Alfresco Workflow assigned to SiteManager group of a site
var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var javaSiteService = ctx.getBean("siteService");
var site = javaSiteService.getSite(document.nodeRef);
var siteManagerGroup = javaSiteService.getSiteRoleGroup(site.getShortName(), "SiteManager", true);
var groupAssignee = people.getGroup(siteManagerGroup)
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "activiti$activitiParallelGroupReview";
workflow.parameters.requiredApprovePercent = 20;
workflow.parameters["bpm:workflowDescription"] = "Please review and approve: " + document.name;

Keybase proof

I hereby claim:

  • I am alfrescian on github.
  • I am alfrescian (https://keybase.io/alfrescian) on keybase.
  • I have a public key whose fingerprint is B8EF 5F6E A8C6 A4FE 989B 05B7 1CF5 5257 294A F794

To claim this, I am signing this object: