Skip to content

Instantly share code, notes, and snippets.

View cincodenada's full-sized avatar

Ell Bradshaw cincodenada

View GitHub Profile
@cincodenada
cincodenada / rot.py
Created September 14, 2013 00:09
Quick binary rotation (rotl/rotr) in Python
def rotl(num, bits):
bit = num & (1 << (bits-1))
num <<= 1
if(bit):
num |= 1
num &= (2**bits-1)
return num
def rotr(num, bits):
@cincodenada
cincodenada / logsb
Created November 2, 2013 01:39
A quick alias in irssi to save the scrollback log to a file. I recently turned on logging (/set autolog ON), and wanted to save what scrollback I'd kept as well. After some reading up, this should add the /logsb command, which stores logs for the current channel in the same place as the default logging, in files tagged .scrollback.log. The alias…
/alias logsb lastlog -file ~/irclogs/${tag}/${C}.${F}_${Z}.scrollback.log
@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 / 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 / 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()