Skip to content

Instantly share code, notes, and snippets.

View lov3catch's full-sized avatar
☺️
🐍 Python / 🐘 PHP / 🚀 Racket

ihor.kpl lov3catch

☺️
🐍 Python / 🐘 PHP / 🚀 Racket
View GitHub Profile
@lov3catch
lov3catch / cascade delete
Created July 20, 2015 13:15
psql sqlalchemy cascade delete
import sqlalchemy
from sqlalchemy import schema
from sqlalchemy import types
from sqlalchemy.orm import relationship
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
metadata = schema.MetaData()
BaseObject = declarative_base(metadata=metadata)
@lov3catch
lov3catch / timezone
Created July 20, 2015 11:27
lng lat to timezone, converting time to timezone
from tzwhere import tzwhere
time_zone_getter = tzwhere.tzwhere()
def convert_time_for_me(self, datetime_obj):
'''
getting datetime obj and convert to datetime with same timezone
'''
def time_zone(me):
lng, lat = db.session.query(ST_X(me.location)).first()[0], db.session.query(ST_Y(me.location)).first()[0]
tz = time_zone_getter.tzNameAt(lat, lng)
# -*-coding:utf-8;-*-
from __future__ import unicode_literals
import time
def run_checker(fn):
def wrapped():
print 'check'
return fn()
@lov3catch
lov3catch / gist:a6115700c7addcaf356f
Created January 27, 2015 19:55
ObjectId to DateTime
# start_date = DateTimeField(default=datetime.datetime.now)
# http://api.mongodb.org/python/current/api/bson/objectid.html
orders = Order.objects()
for order in orders:
print 'generation: ',order.id.generation_time
print 'create: ',order.date
# order.date = order.id.generation_time
# order.save()
<video width="400" controls preload="auto">
<source src="{{ url_for('static', filename='qqq.ogv') }}" type="video/mp4">
<source src="{{ url_for('static', filename='qqq.ogv') }}" type="video/ogv">
</video>
@lov3catch
lov3catch / oanda.test
Created November 7, 2014 15:19
OANDA
#coding: utf-8;
__author__ = 'lov3catch'
from datetime import datetime
import time
import requests
currencies_optional = ['ADP', 'CZK', 'GBP']
args = dict(
@lov3catch
lov3catch / bridge.py
Created February 3, 2014 12:55 — forked from pazdera/bridge.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `bridge' design pattern
# This code is part of http://wp.me/p1Fz60-8y
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@lov3catch
lov3catch / vk_api
Created January 9, 2014 22:22
VK_API: get group statistic
#-*-coding:utf-8-*-
import urllib2
import json
from datetime import date, datetime
import time
from time import gmtime, strftime
today = date.today()
vk_api_url = "https://api.vk.com/method/stats.get?group_id=33006648&app_id=3572991&date_from=%s&access_token=ef57857451d5a0b30cee5f6b3cb341ba27197ab9cba7a88a3591099afb4a5d9fa345be40cbe3dc9e153cb"%today
dataStoragePath = '/media/lov3catch/A0FB-B842/statistic_storage'