Skip to content

Instantly share code, notes, and snippets.

View cincodenada's full-sized avatar

Ell Bradshaw cincodenada

View GitHub Profile
@cincodenada
cincodenada / apt-tree
Last active November 4, 2024 22:38 — forked from blais/apt-tree
apt-tree
#!/usr/bin/env python3
"""Display a graph of dependencies between Ubuntu packages.
Reads a list of packages from either a file or stdin.
Outputs a PDF.
"""
__author__ = "Martin Blais <[email protected]>"
import argparse
import logging
import random
@cincodenada
cincodenada / esm-package.md
Last active October 19, 2022 00:42 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package that linked you to this page is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@cincodenada
cincodenada / demo.js
Last active September 27, 2021 23:49
A version of my Bull demo script that attempts to clear jobs during their run, used to demonstrate bug #2167
const Queue = require('bull')
const delay = require('delay')
const shouldReAdd = process.argv.includes('--readd')
const timelog = (...args) => { console.log(+Date.now(), ...args) }
;(async () => {
timelog('Creating queue')
const queue = new Queue('example')
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
checkReadOnly = false;
appName = 'Ember Twiddle';
}
@cincodenada
cincodenada / controllers.application\.js
Last active May 25, 2021 00:23
Super in Event Handlers
import Controller from '@ember/controller';
export default Controller.extend({})
@cincodenada
cincodenada / controllers.application\.js
Created May 25, 2021 00:14
Super in Handlers Example
import Controller from '@ember/controller';
const BaseController = Controller.extend({
actions: {
nameAlert: function(person){
window.alert('alert from BaseController: ' + person.lastName + ', ' + person.firstName);
}
}
})
@cincodenada
cincodenada / fix_migrations.sh
Last active November 21, 2020 02:39
A test script to fix old migrations in Bookwyrm
#!/bin/bash
set -e
function echo_header {
echo -e "\e[1m\e[4m\n$1\e[0m"
}
source .env
@cincodenada
cincodenada / words_in_words.py
Created October 3, 2018 01:18
A quick script to find words that are subsets of other words. Designed to find country names that contain other countries, but should be generally applicable.
import fileinput
import re
from collections import defaultdict
class Word:
def __init__(self, word):
self.word = word
self.allcaps = re.sub("[^A-Z]","",word.upper())
self.countified()
@cincodenada
cincodenada / geonames.py
Created April 7, 2017 01:15 — forked from pamelafox/geonames.py
Geonames Python wrapper
import sys
import urllib
import urllib2
import json
import logging
class GeonamesError(Exception):
def __init__(self, status):
@cincodenada
cincodenada / fix_vagrant_gid.sh
Last active February 6, 2017 22:33
Patches Vagrant bug #7616
#!/bin/bash
# Patches a Vagrant permissions-creating script that breaks assigning groups
# that don't have a matching user. See Vagrant bug #7616
# Thanks to @Jc-L for the patch
paths=( "/usr/share/vagrant/" "/opt/vagrant/embedded/gems/gems/vagrant-1.8.5/" )
for p in "${paths[@]}"; do
if [ -d "$p" ]; then
PREFIX="$p"