This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def f(): | |
| lst = SortedListWithKey([1,4,8,16], lambda k: k) | |
| for i in range(0, 20): | |
| print(i, lst[max(lst.bisect_right(i) - 1, 0)]) | |
| >>> f() | |
| 0 1 | |
| 1 1 | |
| 2 1 | |
| 3 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Input: | |
| <div className="daily-timesheet"> | |
| <h1>Hello</h1> | |
| <MyWidget /> | |
| <SaveStatus /> | |
| </div> | |
| Output: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> 'a'.localeCompare('A', 'en', {sensitivity: 'base'}) | |
| 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % ar x file.deb | |
| (Creates control.tar.gz data.tar.xz debian-binary) | |
| % ar file.deb control.tar.gz data.tar.xz debian-binary | |
| (Recreates file.deb from those three files) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Grep for text but don't filter lines, just highlight the matches | |
| ag <search> --passthrough | |
| # Show a number of lines after the match | |
| ag <search> -A <num> | |
| # One result per line (ie. don't group by filename.. useful for piping to `wc -l`) | |
| ag <search> --nogroup | |
| # Case sensitive |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> import jinja2 | |
| >>> jinja2.Template("{{ variable }}").render(variable="value") | |
| 'value' | |
| >>> import jinja2, json | |
| >>> t = jinja2.Template("{{ a | json }}") | |
| >>> t.environment.filters['json'] = json.dumps | |
| >>> t.render(a="\n\n\n") | |
| '"\\n\\n\\n"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- http://stackoverflow.com/a/36023359/223486 | |
| Executable in psql shell: | |
| DO $$ DECLARE | |
| r RECORD; | |
| BEGIN | |
| -- if the schema you operate on is not "current", you will want to | |
| -- replace current_schema() in query with 'schematodeletetablesfrom' | |
| -- *and* update the generate 'DROP...' accordingly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo apt-get --reinstall install virtualbox-dkms | |
| # http://askubuntu.com/a/768310/211502 | |
| # for example... | |
| for MODULENAME in vboxdrv vboxnetflt vboxnetadp vboxpci; do | |
| openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=Descriptive name/" | |
| sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n $MODULENAME) | |
| sudo mokutil --import MOK.der |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://stackoverflow.com/a/16595367/223486 | |
| find . -not \( -path ./node_modules -prune \) -name '*.js | |
| # Note that the behaviour is different if you reverse the -name and -not arguments. |
OlderNewer