Install Python
$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7
Symlinks...
| /* | |
| This script attempts to identify all CSS classes mentioned in HTML but not defined in the stylesheets. | |
| In order to use it, just run it in the DevTools console (or add it to DevTools Snippets and run it from there). | |
| Note that this script requires browser to support `fetch` and some ES6 features (fat arrow, Promises, Array.from, Set). You can transpile it to ES5 here: https://babeljs.io/repl/ . | |
| Known limitations: | |
| - it won't be able to take into account some external stylesheets (if CORS isn't set up) | |
| - it will produce false negatives for classes that are mentioned in the comments. |
| #!/usr/bin/python3 | |
| """ | |
| This script adds on_delete to Django migrations. It works on multi-line | |
| definitions of ForeignKey/OneToOneField which may be in your codebase if you | |
| have black'ened the migration files. | |
| It's not perfect, but it doesn't create syntax errors and you can run black on | |
| the code again afterwards. | |
| First version: |
| def get_count(q): | |
| count_q = q.statement.with_only_columns([func.count()]).order_by(None) | |
| count = q.session.execute(count_q).scalar() | |
| return count | |
| q = session.query(TestModel).filter(...).order_by(...) | |
| # Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ... | |
| print q.count() |
| git branch -r --merged | ⏎ ✭ ✱ ◼ | |
| awk -F'/' '/^ *origin/{if(!match($0, /(>|master)/)){print $2}}' | | |
| xargs git push origin --delete |
| class RequestHandler | |
| @processed_body.setter | |
| def processed_body(self, value): | |
| self._processed_body = value | |
| @property | |
| def processed_body(self): | |
| if not hasattr(self, "_processed_body"): | |
| self._processed_body = self.get_processed_body() |
| class AuthTwitterLoginHandler(LoginHandler, tornado.auth.TwitterMixin): | |
| @tornado.web.asynchronous | |
| @gen.engine | |
| def get(self): | |
| my_url = (self.request.protocol + "://" + self.request.host + | |
| "/auth/twitter?next=" + | |
| tornado.escape.url_escape(self.get_argument("next", "/"))) | |
| if self.get_argument("oauth_token", None): | |
| user = yield gen.Task(self.get_authenticated_user) |
| import tornado.auth | |
| from tornado import httpclient | |
| from tornado import httputil | |
| from tornado.httputil import url_concat | |
| from tornado.options import options | |
| from tornado import escape | |
| from tornado.concurrent import Future | |
| from tornado import gen | |
| import logging | |
| import urllib |
| //FightCode can only understand your robot | |
| //if its class is called Robot | |
| var Robot = function(robot) { | |
| }; | |
| Robot.prototype.onIdle = function(ev) { | |
| var robot = ev.robot; | |
| robot.ahead(100); |
| # Export | |
| SELECT id, field1, field2, field3 | |
| INTO OUTFILE '/tmp/data.csv' | |
| FIELDS TERMINATED BY ',' | |
| OPTIONALLY ENCLOSED BY '"' | |
| ESCAPED BY '\\' | |
| LINES TERMINATED BY '\n' | |
| FROM data_table | |
| WHERE field1 = 0; |
Install Python
$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7
Symlinks...