Skip to content

Instantly share code, notes, and snippets.

@mattvonrocketstein
mattvonrocketstein / pybcompgen.py
Last active August 29, 2015 14:08
Pybcompgen calculates context sensitive tab-completion data from environment bash system settings
#!/usr/bin/env python
""" pybcompgen
Pybcompgen calculates context sensitive tab-completion data which is
derived from environment bash system settings. It doesn't need to know
anything about whether you use /etc/completion or /etc/bash_completion.d,
all that matters is whether *bash* knows about the completion. The benefit
of doing this are obvious: you get access to all the completion features
that the system has installed without caring how the completion features
work. Note that this approach doesn't just work for things in the users
File Edit Options Buffers Tools Python Help
#!/usr/bin/python3
"""
"You can't spell 'skateboarding' without d-a-t-a-g-r-o-k."
Usage: python3 cantspell.py WORD
Prints all the words in its dictionary that contain at least all the
letters given in WORD
"""
from collections import Counter
@qwcode
qwcode / gist:3088149
Created July 11, 2012 05:14
non-recursive force upgrade

Upgrading a package, w/o upgrading dependencies that are already satisifed

suppose the following packages: a, b, c, d

with the following dependency relationships between their versioned distributions

  • a-1
  • b
So let's consider a small business that runs a website that happens to run on GPL'd software. They don't know anything about the GPL but they paid a local web shop to set it up on their shared web host. They don't have to know that the GPL requires them to provide source code if they convey a copy because they don't convey
Let's say the same business runs a wwebsite that runs on AGPL software. They don't know anything about the AGPL but they paid a local web shop to set it up on their shared web host. What happens when someone requests a copy of the source? The answer will likely be "what's source code?"
The local business doesn't want to pay someone to get them the source. And we can't even tell them "give us the contents of directory holding the web site" because that might contain private configuration information which isn't covered by the AGPL.
This is why I don't normally recommend AGPL software to anyone unless they already understand licensing and source code.
@alecperkins
alecperkins / TodoMVC.TodoApp.coffee
Created August 15, 2012 19:57
TodoMVC tutorial in coffeescript
TodoMVC.module 'TodoApp', (App, TodoMVC, Backbone, Marionette, $, _) ->
log arguments
class App.TodoForm extends Marionette.ItemView
events:
'keypress #new-todo' : 'createOnEnter'
'click .mark-all-done' : 'toggleAllClicked'
triggers:
'click .todo-clear a' : 'clear:completed'
@wolever
wolever / git-unpull
Last active December 21, 2015 04:08
git-unpull: undoes the merge commit created by an accidental 'git pull', plus some added helpful information!
#!/bin/bash
# Reverts HEAD back to ORIG_HEAD, for example after a 'git pull' accidentally
# creates a merge. This is identical to running 'git reset --hard ORIG_HEAD',
# except that unpull prints some helpful information along the way.
# Useage:
# $ git unpull
# HEAD: a0ac0fd Merge branch 'master' of /tmp/foo
# 2284c9d some remote commit
# ORIG_HEAD: 35431fd my local commit
# Really reset HEAD to ORIG_HEAD? (y/n) y
@nrb
nrb / y260.md
Created April 28, 2016 20:26
Unorganized notes about getting ArchLinux running on a Lenovo Thinkpad Y260

Installing

Disable SecureBoot for the time being.

For booting my Archlinux kernel (4.3 series on the USB drive I made), I needed the following options:

nomodeset intel_pstates=no_hwp

You can edit the parameters by hitting the e key on the ArchISO boot option

@queertypes
queertypes / .psqlrc.sql
Last active February 12, 2017 22:47
Allele's psqlrc
-- make psql really quiet while the next several commands are processed
\set QUIET 1
-- a colorful prompt that displays, in order:
-- * hostname (green)
-- * port number (yellow)
-- * user (blue)
-- * database (purple)
-- in the format: host:port user@db#
\set PROMPT1 '%[%033[1;32m%]%M:%[%033[1;33m%]%> %[%033[1;34m%]%n@%[%033[1;35m%]%/%R%[%033[0m%]%# '
@Aissen
Aissen / gist:2925633
Created June 13, 2012 18:20
Linux users: watch out for last-gen Intel Atom

Linux users: watch out for last-gen Intel Atom

Oops. They did it again.

It hit the market during the last few weeks. Last generation of Intel Atoms: CedarView (D2300, D2500, D2550, D2600, D2700) and Cedar Trail (N2600, N2700, N2800) SoCs integrate a PowerVR GPU from Imagination instead of the usual Intel GPU. If you remember the Poulsbo fiasco, it's the same. More or less.

An unsupported graphic card on Linux distributions, and which can't properly support a basic desktop environnment like Unity or Gnome 3.

To prevent this issue, Intel woke up MeeGo from the dead in last february [to add support for CedarView]

@ftfarias
ftfarias / README.md
Created January 24, 2017 23:10 — forked from datagrok/README.md
Circular imports in Python 2 and Python 3: when are they fatal? When do they work?

When are Python circular imports fatal?

In your Python package, you have:

  • an __init__.py that designates this as a Python package
  • a module_a.py, containing a function action_a() that references an attribute (like a function or variable) in module_b.py, and
  • a module_b.py, containing a function action_b() that references an attribute (like a function or variable) in module_a.py.

This situation can introduce a circular import error: module_a attempts to import module_b, but can't, because module_b needs to import module_a, which is in the process of being interpreted.

But, sometimes Python is magic, and code that looks like it should cause this circular import error works just fine!