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
| import static org.junit.Assert.*; | |
| import static org.hamcrest.CoreMatchers.is; | |
| import static org.mockito.Mockito.*; | |
| import static org.mockito.BDDMockito.*; | |
| import org.hamcrest.BaseMatcher; | |
| import org.hamcrest.Description; | |
| import org.hamcrest.Matcher; |
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
| /* | |
| JPA (Java Persistence API) | |
| Transaction Management with an Entity-Mananger: | |
| --- | |
| entityManager.getTransaction().begin(); | |
| entityManager.persist(<some-entity>); | |
| entityManager.getTransaction().commit(); | |
| entityManager.clear(); |
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
| //CURS VALUTE | |
| function get_usd() { | |
| $xmlURL = 'http://www.cbr.ru/scripts/XML_daily.asp?date_req='.date('d/m/Y'); | |
| //$xmlURL = 'http://www.cbr.ru/scripts/XML_daily.asp?date_req='; | |
| //кэширование 6 часов | |
| $filename = 'kurs.xml'; | |
| if (!file_exists($filename) || (file_exists($filename) && time() > filemtime($filename) + 60*60*6)) { | |
| $file = file_get_contents($xmlURL); | |
| if ($file) { |
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
| /** | |
| * Функция склонения числительных в русском языке | |
| * | |
| * @param int $number Число которое нужно просклонять | |
| * @param array $titles Массив слов для склонения | |
| * @return string | |
| **/ | |
| function declOfNum($number, $titles, $position) | |
| { | |
| $cases = array(2, 0, 1, 1, 1, 2); |