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
| class Ticker: | |
| def __init__(self): | |
| self.t = [time.time()] | |
| def tick(self): | |
| self.t.append(time.time()) | |
| i = len(self.t) - 1 | |
| tot = self.t[-1] - self.t[0] | |
| last = self.t[-1] - self.t[-2] |
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
| #!/usr/bin/env bash | |
| # git-finish | |
| # Does a no-ff rebase and merge onto the target branch from the current one. | |
| # Also updates the origin of the current branch so that the github tracker knows it is merged | |
| set -e | |
| current_branch=$(git rev-parse --abbrev-ref HEAD) | |
| from_branch=${1-${current_branch}} |
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 django_model_values(obj): | |
| fields = obj._meta.get_fields() | |
| field_values = [(f.name, f.value_from_object(obj)) for f in fields if hasattr(f, "value_from_object")] | |
| return field_values | |
| print("%r\n" % f + "\n".join(" %s: %r" % tup for tup in django_model_values(obj))) | |
| def test_querie(): | |
| from django.conf import settings |
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
| # Method chaining in Python | |
| # Examples from http://stackoverflow.com/questions/4768941/how-to-break-a-line-of-chained-methods-in-python | |
| # 1 | |
| subkeyword = Session.query( | |
| Subkeyword.subkeyword_id, Subkeyword.subkeyword_word | |
| ).filter_by( | |
| subkeyword_company_id=self.e_company_id |
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 print_queries(w=80): | |
| from django.db import connection | |
| print() | |
| for i, query in enumerate(connection.queries): | |
| sql = query["sql"] | |
| print("[{:>2}] {}".format(i + 1, sql[:w])) | |
| print("Total queries: %s" % len(connection.queries)) | |
| print() | |
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
| cat .git/tags | grep "\(f\|c\)$" | awk '{print $1, $2}' | tr / . | sed -e s/\.py$// -e s'/\.\.\.//' | awk '{print "from", $2, "import", $1}' | sort |
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
| Proposed default alternative to t_CTRL-\_CTRL-n: | |
| <c-x><c-c> or <c-x>c | |
| Benefits: | |
| No conflicts in default vim or bash. | |
| Easily available on all QWERTY, AZERTY and QWERTZ keyboard layouts. | |
| For reference: |
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
| Som en ängel som inte har nån' medkänsla | |
| Res dig pojke mot himmelen som en hjälte. | |
| Himmel blå, och molnfri som få. | |
| Ler mot dig och knackar på ditt hjärtas dörr. | |
| En blå vind som yr, och från urtiden flyr, i takt med din hjärtas andetag. | |
| Någon som vidrör dig mjukt. Som du ej kan se men du vill söka upp. | |
| Ditt öde är gömt där du inte kan se med dina naiva ögon. |
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
| function! CountSpaces(line) | |
| return strlen(substitute(a:line, '^ *\zs[^ ].*', '', '')) | |
| endfunction | |
| " Move to the next or previous line with less indent than the current line. | |
| function! IndentSearchLess(dir) | |
| let spaces = CountSpaces(getline('.')) | |
| if spaces == 0 | |
| return | |
| endif | |
| let pattern = '^ \{0,'.(spaces-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
| <!-- XCOM Interceptor --> | |
| <vessel uniqueID="5" side="0" classname="Interceptor" broadType="player"> | |
| <art meshfile="dat/artemis.dxs" diffuseFile="dat/artemis_diffuse.png" | |
| glowFile="dat/artemis_illum.png" specularFile="dat/artemis_specular.png" scale="0.2" pushRadius="150"/> | |
| <internal_data file="dat/artemis.snt"/> | |
| <shields front="60" back="60"/> | |
| <performance turnrate="0.008" topspeed="0.8" efficiency="0.8" /> | |
| <beam_port x="0" y="17.8" z="289.0" damage="12" arcwidth="0.3" cycletime="4.0" range="1000"/> | |
| <torpedo_tube x="0" y="8.35" z="258.74"/> | |
| <torpedo_tube x="0" y="8.35" z="258.74"/> |
NewerOlder