Skip to content

Instantly share code, notes, and snippets.

@nelsnelson
nelsnelson / dupefixer.rb
Created March 2, 2016 06:05
Remove duplicate bookmarks in Firefox quickly
# Did Mozilla F1 and Firefox Sync manage to duplicate your bookmarks 57814 times (like they did mine)?
# Did CheckPlaces and other misc addons completely fail at the task of removing duplicate bookmarks?
# Does the bookmarks manager grind to a halt even selecting an item?
# This is the fix for you..
# Backup the bookmarks in Firefox using the Backup function
# (from the star icon in the bookmarks manager) to JSON.
# Invoke this script as following:
# ruby dupefixer.rb /Users/yourname/Desktop/bookmarks.json
$.fn.equalHeights = function(px) {
var tallestHeight = 0;
if (!px) {
$(this).each(function() {
if ($(this).height() > tallestHeight) {
tallestHeight = $(this).height();
}
});
@nelsnelson
nelsnelson / log.py
Last active September 10, 2015 15:54
#! /usr/bin/env python
import logging
import sys
log_format = "%(asctime)s %(levelname)s [%(name)s] %(message)s"
formatter = logging.Formatter(log_format)
handler = logging.StreamHandler()
@nelsnelson
nelsnelson / demand_not_none_keyword_args.py
Last active August 29, 2015 14:23
What is the best way to verify that a specific set of named keyword argument parameters of a method are not None, and be able to refer to those parameters, by name, in a log message reporting the missing parameters, but not causing the method to explicitly fail?
def _possibly_deprecated_someday(
required_a,
required_b,
named_only_for_readability_a=None,
named_only_for_readability_b=None,
named_only_for_readability_c=None,
named_only_for_readability_d=None):
"""Does some complicated stuff."""
required_keywords = [
$ cat compute/capacity/galaxy.yaml
galaxy:
name: 'agent-galaxy'
product: 'compute'
feature: 'capacity'
location:
region: 'iad'
cell: 'iad1'
galaxy:
url: 'http://galaxy.ohthree.com'
Successfully installed galaxy-api-master cli-tools numpy PyYAML requests six stevedore simplejson pymongo argparse setuptools pbr pip
Cleaning up...
(.venv)nels.nelson@durga:~/src/hubble$ python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to hubble.egg-info/requires.txt
writing hubble.egg-info/PKG-INFO
writing top-level names to hubble.egg-info/top_level.txt
writing dependency_links to hubble.egg-info/dependency_links.txt
$ virtualenv .venv
New python executable in .venv/bin/python
Installing setuptools, pip...done.
(.venv)$ source .venv/bin/activate
(.venv)$ pip install --upgrade --requirement requirements.txt
Obtaining galaxy-api-master from git+git@github.rackspace.com:Galaxy/python-galaxy_api.git@eb65e4a5c6fe55200de9857e2d148eaaf6d18462#egg=galaxy_api-master (from -r requirements.txt (line 1))
Cloning git@github.rackspace.com:Galaxy/python-galaxy_api.git (to eb65e4a5c6fe55200de9857e2d148eaaf6d18462) to ./.venv/src/galaxy-api-master
Could not find a tag or branch 'eb65e4a5c6fe55200de9857e2d148eaaf6d18462', assuming commit.
Running setup.py (path:/home/nels.nelson/src/hubble/.venv/src/galaxy-api-master/setup.py) egg_info for package galaxy-api-master
@nelsnelson
nelsnelson / brainfuck url
Created March 11, 2015 19:37
brainfuck url
+ url = ("http://%s:%s/render/?target=alias(transformNull(asPercent(diff"
+ "Series(sumSeries(derivative(servers.production.f5-networks."
+ "icontrol.load-balancer-1.public-api-ssl-v4.http_total_requests),"
+ "derivative(servers.production.f5-networks.icontrol.load-balancer-2."
+ "public-api-ssl-v4.http_total_requests)),sumSeries(derivative"
nels.nelson@sol:~/src/abacus-fork[inframon-34]$ vagrant up
Bringing machine 'abacus' up with 'virtualbox' provider...
Bringing machine 'abacus_build' up with 'virtualbox' provider...
[abacus] Importing base box 'centos-6.5-64-vagrant'...
[abacus] Matching MAC address for NAT networking...
[abacus] Clearing any previously set forwarded ports...
[abacus] Creating shared folders metadata...
[abacus] Clearing any previously set network interfaces...
[abacus] Preparing network interfaces based on configuration...
[abacus] Forwarding ports...
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 8000 is already in use
on the host machine.
To fix this, modify your current projects Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:
config.vm.network :forwarded_port, guest: 80, host: 1234