Skip to content

Instantly share code, notes, and snippets.

View miohtama's full-sized avatar
🏠
https://tradingstrategy.ai

Mikko Ohtamaa miohtama

🏠
https://tradingstrategy.ai
View GitHub Profile
try {
$(document).ready(function() {
// ...
});
window.javascriptReady = true;
} catch(e) {
if (window.Raven) {
def translator(term):
return get_localizer(get_current_request()).translate(term)
deform_template_dir = resource_filename('deform', 'templates/')
deformdemo_template_dir = resource_filename('deformdemo', 'custom_widgets/')
zpt_renderer = deform.ZPTRendererFactory(
(deformdemo_template_dir, deform_template_dir,), translator=translator)
@miohtama
miohtama / gist:6f87ca494df96a8d8894812106cadbbc
Created February 6, 2017 10:38
SQLAlchemy + PostgreSQL + deadlock on TransactionRollbackError retryable
Celery task raised an exception (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (psycopg2.extensions.TransactionRollbackError) deadlock detected
DETAIL: Process 18932 waits for ShareLock on transaction 166111; blocked by process 18933.
Process 18933 waits for ShareLock on transaction 166110; blocked by process 18932.
HINT: See server log for query details.
CONTEXT: while updating tuple (15,4) in relation "asset_content"
[SQL: 'UPDATE asset_content SET updated_at=%(updated_at)s, published_at=%(published_at)s, other_data=%(other_data)s WHERE asset_content.id = %(asset_content_id)s'] [parameters: {'published_at': datetime.datetime(2017, 2, 6, 10, 35, 42, 637436, tzinfo=datetime.timezone.utc), 'updated_at': datetime.datetime(2017, 2, 6, 10, 35, 42, 637430, tzinfo=datetime.timezone.utc), 'asset_content_id': UUID('3377ace2-0010-482d-a337-1703de763760'), 'other_data': '{"tags": [{"term": "Bitcoin", "label": null, "scheme": null},
@miohtama
miohtama / purge_logs.sh
Created January 27, 2017 10:04
Remove old logs from Quassel SQLite database
#!/bin/sh
BAK_PATH="${HOME}/.config/quassel-irc.org/quassel-storage.sqlite.bak"
CURRENT_PATH="${HOME}/.config/quassel-irc.org/quassel-storage.sqlite"
# first day of data that will be maintained
# -15 day means that *every* chatline stored before 16 days ago and so on are going to be eliminated.
# only the last 15 days are keeped.
DATE_TO_PRUNE='-15 day'
die() {
@miohtama
miohtama / install-postgresql-client-9.5-on-ubuntu-14.04.bash
Created January 25, 2017 08:10
Upgrade PostgreSQL client to 9.5 on Ubuntu 14.04
# Ubuntu 14.04 repo
# For more repos see https://www.ubuntuupdates.org/ppa/postgresql?dist=trusty-pgdg
# Install key
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# 14.04 repo
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
apt update
@miohtama
miohtama / importer.bash
Created January 17, 2017 01:12
Create repositories and import multiple directories to Bitbucket git hosting
#!/bin/bash
#
# Import old svn folders to Bitbucket
# Repositories can be found under https://bitbucket.org/miohtama/
# Based on bitbucket-cli and http://stackoverflow.com/a/19670989/315168
#
# 1. Add your credentials in ~/.bitbucket before running
# 2. Before running make sure you can SSH authenticate against bitbucket: ssh miohtama@bitbucket.org
#
pragma solidity ^0.4.4;
import "../tokenmarket/MilestonePriced.sol";
import "./TestableNow.sol";
contract TestableMilestonePriced is MilestonePriced {
bool public tested = false;
yoursite.net server has been automatically set up by websauna.ansible playbook.
Helpful commands
----------------
Service statuses::
sudo -i
supervisorctl status
service nginx status && service redis-server status && service postgresql status && service postfix status
@miohtama
miohtama / gist:0f64104fc8aefde8360f0c70cf46b950
Last active January 22, 2017 14:00
SMS based login for React and Websauna app
"""
allows users to sign up and login with their phone number, if that number is assoicated with an
existing customer record.
"""
import logging
import colander
from cornice.service import Service
from pyramid.exceptions import HTTPBadRequest
from pyramid_sms.utils import normalize_us_phone_number
INFO: This package is registered on PyPI.
Upload to pypi (Y/n)? y
There were errors or warnings.
ERROR: Package upload has failed.
Traceback (most recent call last):
File "/Users/mikko/code/wattcoin/venv/lib/python3.5/site-packages/zest/releaser/utils.py", line 749, in retry_twine
return twine_function(*twine_args)
TypeError: upload() missing 3 required positional arguments: 'cert', 'client_cert', and 'repository_url'