Skip to content

Instantly share code, notes, and snippets.

@cjcenizal
cjcenizal / organizeSourceForImportByLayer.py
Created May 29, 2014 18:02
Organize src for import by layer
# This script reorganizes the src folder to enable importing styles per layer.
#
# - Deletes pre-existing _index.scss files from each package
# - Creates layer-based import files for each package
# - Populates these files with the correct imports
# - Renames object folder to objects, and module folder to modules
# - Prints `@import` statements for use in main.scss, to import all layers
#
# Usage:
# - cd into the dir that contains this script
@cjcenizal
cjcenizal / redirect-401-in-react.jsx
Created January 19, 2016 00:06
Redirect 401 in React
// In the View component
componentWillUpdate(nextProps) {
// Each view or subview should check the results of
// its API requests to make sure the user is authorized.
handleUnauthorizedErrors([
nextProps.someApiError,
], () => {
// If not, then the user should be redirected to the
// login location, with a subsequent redirect back
// to the current location in the app.
@cjcenizal
cjcenizal / kibana-less-files
Created June 3, 2016 19:55
Kibana LESS files
├── installedPlugins
│   └── timelion
│   └── public
│   ├── app.less
│   ├── chart.less
│   ├── suggestions.less
│   └── vis
│   └── timelion_vis.less
├── node_modules
│   ├── angular-bootstrap-colorpicker
@cjcenizal
cjcenizal / css-style-guide.md
Last active June 10, 2016 02:05
CSS style guide
PUT _template/metricbeat-7.5.1
{
"order": 1,
"index_patterns": [
"metricbeat-7.5.1-*"
],
"settings": {
"index": {
"lifecycle": {
"name": "metricbeat-7.5.1",
PUT _ingest/pipeline/test
{
"description": "Pipeline for Cisco ASA logs",
"processors": [
{
"grok": {
"field": "message",
"patterns": [
"(?:%{SYSLOG_HEADER})?\\s*%{GREEDYDATA:log.original}"
],
PUT .kibana_1/_doc/upgrade-assistant-reindex-operation:fb36e570-bca7-11e9-bbfd-f767236c4a9b
{
"upgrade-assistant-reindex-operation": {
"indexName": "filebeat-2019",
"newIndexName": "reindexed-v7-filebeat-2019",
"status": 2,
"lastCompletedStep": 40,
"locked": null,
"reindexTaskId": "MrzNyPknSyCk6WnmIJeLyQ:151888",
"reindexTaskPercComplete": 0,
@cjcenizal
cjcenizal / test.js
Created August 2, 2024 23:26
Testability
// What are some things that make this code difficult to test, and how would you address them?
import { config } from "../constants/config";
import { sendRequest } from "../services/sendRequest";
import { notifications } from "../services/notifications";
export async function fetchUser(userModel) {
const {
server: {
api: { baseUrl },