Skip to content

Instantly share code, notes, and snippets.

@eban5
eban5 / random_generator.js
Created September 13, 2017 18:58
Random alphanumeric ID and RGBA generators.
// Borrowed from pieces around the internet and customized.
function makeID() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 4; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text.toUpperCase();
}
@eban5
eban5 / int-with-commas.js
Created April 10, 2018 16:14
Display long int with commas at the thousandths place
//credit to elias-zamaria
const numberWithCommas = (x) => {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
@eban5
eban5 / export_repo_issues_to_csv.py
Created August 2, 2018 13:46 — forked from unbracketed/export_repo_issues_to_csv.py
Export Issues from Github repo to CSV (API v3)
"""
Exports Issues from a specified repository to a CSV file
Uses basic authentication (Github username + password) to retrieve Issues
from a repository that username has access to. Supports Github API v3.
"""
import csv
import requests
@eban5
eban5 / export_repo_issues_to_csv.py
Created August 2, 2018 14:01 — forked from Billy-/export_repo_issues_to_csv.py
Export Issues from Github repo to CSV (API v3)
"""
Exports Issues from a specified repository to a CSV file
Uses basic authentication (Github username + password) to retrieve Issues
from a repository that username has access to. Supports Github API v3.
Derived from https://gist.github.com/unbracketed/3380407
"""
import csv
import requests
@eban5
eban5 / parse_python_requirements.py
Created March 12, 2019 15:41
Python script to parse a Requirements.txt file and get a list of Package Name, Version, and Dependency Source URL
import os
import re
import subprocess
packages = {
'package_name': re.compile(r'Name: (?P<package_name>.*)\n'),
'version': re.compile(r'Version: (?P<version>.*)\n'),
'url': re.compile(r'Home-page: (?P<url>.*)\n'),
}
@eban5
eban5 / eslint-formatter-by-filename
Created October 4, 2021 20:34
Format the output of ESLint to group by filename
// only print filenames
module.exports = function (results) {
return results
.filter((result) => result.messages.length > 0)
.map((result) => result.filePath.split('/')[3])
.flat()
.reduce((acc, val) => {
acc[val] = acc[val] === undefined ? 1 : (acc[val] += 1);
return acc;
}, {});
@eban5
eban5 / eslint-formatter-by-ruleid
Created October 4, 2021 20:34
Format the output of ESLint to group by rule-id
// breakdown by type (ruleId)
module.exports = function (results) {
const processed = results
.filter((result) => result.messages.length > 0)
.map((result) => result.messages.map((item) => item.ruleId))
.flat();
const filtered = processed.reduce((acc, val) => {
acc[val] = acc[val] === undefined ? 1 : (acc[val] += 1);
return acc;
@eban5
eban5 / sips_icns
Last active April 3, 2022 05:24
scriptable image processing system (sips) - create ICNS from PNG
mkdir icon.iconset
sips -z 16 16 Icon1024.png --out icon.iconset/icon_16x16.png
sips -z 32 32 Icon1024.png --out icon.iconset/[email protected]
sips -z 32 32 Icon1024.png --out icon.iconset/icon_32x32.png
sips -z 64 64 Icon1024.png --out icon.iconset/[email protected]
sips -z 128 128 Icon1024.png --out icon.iconset/icon_128x128.png
sips -z 256 256 Icon1024.png --out icon.iconset/[email protected]
sips -z 256 256 Icon1024.png --out icon.iconset/icon_256x256.png
sips -z 512 512 Icon1024.png --out icon.iconset/[email protected]
sips -z 512 512 Icon1024.png --out icon.iconset/icon_512x512.png