Skip to content

Instantly share code, notes, and snippets.

$ python3 - a b c
Python 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:04:31)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.argv
['-', 'a', 'b', 'c']
>>> sys.argv = [sys.argv[0]]
>>> sys.argv
['-']
/**
* eg:
* { __createdAt: 'monday', order_id: 123, some_field_: 'abc' } =>
* { createdAt: 'monday', orderId: 123, someField: 'abc' }
*/
function convertPropertyNamesToCamelCase(object) {
const newObject = {};
_.mapKeys(object, (value, prop) => {
const newProp = prop
@jtara1
jtara1 / css-keywords.txt
Last active February 22, 2019 01:32
css keywords - useful for parsing html
:active
additive-symbols
(@counter-style)
::after
(:after)
align-content
align-items
align-self
all
<an-plus-b>
@jtara1
jtara1 / logger.js
Last active July 26, 2022 19:40
logger for JS - built up after several node projects
const winston = require('winston');
const { join, basename, dirname } = require('path');
const fs = require('fs');
const logform = require('logform');
// const { MESSAGE } = require('triple-beam'); // prop for info in winston formater to expose the shown message
function filterMessagesFormat(filterFunc = () => true) {
const formatFunc = (info) => {
if (filterFunc(info.message)) return info;
return null;
@jtara1
jtara1 / decorators.js
Created February 6, 2019 18:50
basic decorator examples
function timeIt(func) {
return async (...args) => {
const start = new Date();
const output = await func(...args);
console.log(`${func.name} took ${(new Date() - start) / 1000} s`);
return output;
}
}
[
"b",
"b",
"b",
"b",
"b",
"b",
"b",
"b",
"b",
This file has been truncated, but you can view the full file.
[
[
2,
1,
1,
1,
6,
6,
3,
2,
export $(grep -v '^#' .env | xargs)
@jtara1
jtara1 / compound-word-splitter.js
Created December 11, 2018 19:10
re-implemented a python module, but this actually already exists as a npm module
const _ = require('lodash');
const checkWords = require('check-word');
const englishWords = checkWords('en');
/**
*
* @param character {string}
* @returns {boolean}
*/
function isUpper(character) {
const fs = require('fs');
function toCsv(arrayOfObjects) {
let getProps = (object) => {
return Object.getOwnPropertyNames(object);
};
let props = getProps(arrayOfObjects[0]);
let outputString = props.join(',') + '\n';