Skip to content

Instantly share code, notes, and snippets.

View iamnewton's full-sized avatar
🏠
Working from home

Newton iamnewton

🏠
Working from home
View GitHub Profile
// I provide a logging API that has some special sauce for formatting.
const echo = (function() {
let queue = [];
var ECHO_TOKEN = {};
const RESET_INPUT = "%c ";
var RESET_CSS = "";
// Attach formatting utility method.
function alertFormatting (value) {
queue.push({
@iamnewton
iamnewton / _images.scss
Created January 24, 2020 00:36
Some SCSS helpers
/// Rounded corners on images
/// @author Newton Koumantzelis
/// @since 1.0.0 - The Sith
/// @example html
/// <img src="" class="img-broken" alt="Generic image">
.img-broken {
position: relative;
min-height: 3rem;
&::before,
@iamnewton
iamnewton / readFile.js
Last active December 4, 2019 22:26
Read a file line-by-line and update a line of it
const fs = require('fs');
const readline = require('readline');
const readFile = () => {
// create readline interface and output to a new file; can't figure out how to write to same file
const readInterface = readline.createInterface({
input: fs.createReadStream(findup('sonar-project.properties')),
output: fs.createWriteStream('sonar-project.properties.temp'),
console: false
});

Keybase proof

I hereby claim:

  • I am iamnewton on github.
  • I am chrisopedia (https://keybase.io/chrisopedia) on keybase.
  • I have a public key whose fingerprint is 6AE7 083D 4404 07C0 7EB1 18EA 3802 412D 8420 6E38

To claim this, I am signing this object:

@iamnewton
iamnewton / format-stock-spreadsheet.js
Last active March 14, 2021 18:29
Runs a few scripts to format the Gain & Loss sheets from stock data.
/*
* get the active selected sheet;
*/
const SHEET = SpreadsheetApp.getActiveSheet();
// ranges are equivalent to rows in this context, but in reality are more
// like A2:B2 which means Column A, Row 2 through Column B, Row 2
// this method pulls back all information from the first column, first row
// to the last column, last row
// | | A | B | C |

Keybase proof

I hereby claim:

  • I am chrisopedia on github.
  • I am chrisopedia (https://keybase.io/chrisopedia) on keybase.
  • I have a public key whose fingerprint is 69F5 8F0D 59D8 9A62 0D75 1F15 D879 14C4 927D 67AC

To claim this, I am signing this object:

@iamnewton
iamnewton / javascript-for-vim-refactoring.js
Created September 25, 2015 06:35 — forked from derwiki/javascript-for-vim-refactoring.js
Moving faster with Vim (5-minute lightning talk presentation). I wasn't inspired to learn effective command of Vim until I saw some people flying around faster than I thought was possible. The goal of this presentation is to call out how slow "normal" text editing is, and how many keystrokes can be reduced by using increasingly more terse Vim co…
$(function() {
// good opportunity to combine into a single statement
// qq w cw <esc> A, <esc> 0 j q
var a = 10;
var b = 20;
var c = 30;
var d = 40;
var e = 50;
// opportunity to simplify syntax
@iamnewton
iamnewton / what-forces-layout.md
Last active October 13, 2022 22:11 — forked from paulirish/what-forces-layout.md
What forces layout/reflow in Chrome. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
#!/bin/bash
set -e
# Send a private message to someone on slack
# from the command line.
# Print a usage message and exit.
usage(){
local name=$(basename "$0")
@iamnewton
iamnewton / rubi.js
Last active August 29, 2015 14:27 — forked from kmoe/highfive.js
module.exports = function rubi( hook ) {
// hook.io has a range of node modules available - see
// https://hook.io/modules.
// We use request (https://www.npmjs.com/package/request) for an easy way to
// make the HTTP request.
var request = require( 'request' );
// The parameters passed in via the slash command POST request.
var params = hook.params;