Skip to content

Instantly share code, notes, and snippets.

@lettertwo
lettertwo / vim.md
Created April 8, 2019 14:56
Philosophy of VIM

Philosophy of Vim

  • most of programming time is spent editing, not writing.
  • editing is a process of manipulating text in ways beyond just writing, such as deletion, replacement, reordering, duplication, formatting, etc.
  • since writing (input) is a relatively small part of the whole of programming, making the other tasks easier by default can be a productivity win.
  • os shortcuts for editing can't get 'shadowed' by custom actions, since they take the form of commands in 'normal' (command) mode

A Modal Editor

@kguidonimartins
kguidonimartins / github_issues_to_csv.py
Last active May 17, 2018 12:50 — forked from patrickfuller/github_issues_to_csv.py
Export Issues from Github repo to CSV (API v3)
"""
Exports issues from a list of repositories to individual csv files.
Uses basic authentication (Github username + password) to retrieve issues
from a repository that username has access to. Supports Github API v3.
Forked from: patrickfuller/github_issues_to_csv.py
"""
import argparse
import csv
from getpass import getpass
import requests
@Bunk
Bunk / uploadLocalFile.js
Created November 21, 2017 21:45
Nightwatch — Upload local files to remote selenium grid
const path = require('path')
const util = require('util')
const events = require('events')
const archiver = require('archiver')
const handleResult = cb => result => {
if (result.status !== 0) throw new Error(result.value.message)
cb(result.value)
}
@Atinux
Atinux / async-foreach.js
Last active October 10, 2023 03:04
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@homaily
homaily / index.js
Last active December 16, 2022 13:13
Lambda download and cache gzipped file from s3
'use strict';
console.log('// loading function');
const aws = require('aws-sdk');
const s3 = new aws.S3({apiVersion: '2006-03-01'});
const gzip = require('zlib').createGunzip();
const fs = require('fs');
@codeluggage
codeluggage / es6ToNightwatch.js
Last active October 22, 2021 04:47
Convert ES6 classes to basic Javascript objects to export for Nightwatch
'use strict';
/*
* The purpose of this function is to convert an ES6 class to either:
* 1) A test suite if it has "tests" as a property
* 2) A page object with optional "elements", "commands" and "url"
* @param es6Class The actual class object (not instance of the class) to convert
*/
module.exports = function(es6Class) {
let properties = Object.getOwnPropertyNames(es6Class.prototype);
@naesheim
naesheim / buildWhenAffected.sh
Last active November 28, 2022 20:20
CircleCi - only build features that has changed
##################
### config.yml ###
##################
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6
steps:
@lmcneel
lmcneel / remove-node-modules.md
Last active July 9, 2024 19:06
How to remove node_modules after they have been added to a repo

How to remove node_modules

Create a .gitignore file

  1. Check for an existing .gitignore file in the project directory
ls -a
@msmfsd
msmfsd / es7-async-await.js
Last active February 4, 2024 17:38
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
@montanaflynn
montanaflynn / CONCURRENCY.md
Last active June 28, 2024 12:00
Examples of sequential, concurrent and parallel requests in node.js

Concurrency in JavaScript

Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.