Skip to content

Instantly share code, notes, and snippets.

@yarosla
yarosla / SpringTransactionRollbackSpec.groovy
Created March 20, 2017 15:20
Could not commit JPA transaction: Transaction marked as rollbackOnly (exploring various scenarios for this exception) See http://stackoverflow.com/a/42899742/697313
package ys
import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.PropertySource
import org.springframework.test.context.ContextConfiguration
import org.springframework.transaction.UnexpectedRollbackException
import org.springframework.transaction.annotation.Propagation
package ys
import groovy.util.logging.Slf4j
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.scheduling.annotation.*
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
import org.springframework.test.context.ContextConfiguration
@yarosla
yarosla / py_func_test.py
Created May 17, 2016 18:50
Class methods in Python
import pytest
class A(object):
F='FA'
f1 = lambda: 'f1'
f2 = lambda self: 'f2'
def f3(self):
return 'f3'
f4 = staticmethod(lambda: 'f4')
f5 = classmethod(lambda cls: 'f5')
@yarosla
yarosla / rxweb.py
Last active April 19, 2018 17:40
RxPy + Twisted example - simplistic web server.
# coding=utf-8
from StringIO import StringIO
from datetime import timedelta
from rx import Observer
from rx.concurrency import TwistedScheduler
from rx.disposables import Disposable
from rx.subjects import Subject
from twisted.internet.protocol import Factory, Protocol, connectionDone
from twisted.internet.endpoints import TCP4ServerEndpoint
@yarosla
yarosla / gist:9844359
Created March 28, 2014 22:31
foundation 4.3.2 reveal.js fixed for issue #3258
/*jslint unparam: true, browser: true, indent: 2 */
;(function ($, window, document, undefined) {
'use strict';
Foundation.libs.reveal = {
name : 'reveal',
version : '4.3.2',
@yarosla
yarosla / yandex_money.py
Last active December 30, 2015 09:09
Yandex.Money account ID verification in Python
# coding=utf-8
# Author: Yaroslav Stavnichiy
def verify_account_id(acct):
if not isinstance(acct, (str, unicode)):
return False
try:
E=[int(c) for c in acct]
except:
body {padding:20px;}
@yarosla
yarosla / fixed_topbar_bug.html
Created January 15, 2013 11:02
Zurb Foundation Issue #1278: .fixed .top-bar prevents mouse interaction with adjacent elements
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Welcome to Foundation</title>