Skip to content

Instantly share code, notes, and snippets.

View elnur's full-sized avatar
🤓

Elnur Abdurrakhimov elnur

🤓
  • Earth
View GitHub Profile
public class EmailAddressPartsExtractorTest {
private EmailAddressPartsExtractor extractor = new EmailAddressPartsExtractor();
@Test
public void extractUsername() {
assertThat(extractor.extractUsername("elnur.blog@example.com"), is("elnur.blog"));
}
@Test
public void extractHost() {
@elnur
elnur / postgresql.conf
Created April 18, 2017 06:19
PG Auto Explain Slow Queries
shared_preload_libraries = 'auto_explain'
auto_explain.log_min_duration = 100
auto_explain.log_analyze = true
auto_explain.log_verbose = true
auto_explain.log_nested_statements = true
public function registerAction(Request $request)
{
$user = new User();
$form = $this->formFactory->create('user', $user);
$form->handleRequest($request);
if ($form->isValid()) {
$this->userManager->save($user);
// ...
@Configuration
@EnableTransactionManagement
public class PersistenceConfig {
@Bean
public PlatformTransactionManager transactionManager() {
return new JpaTransactionManager(entityManagerFactory());
}
// other bean definitions
}
task apiTest(type: Test) {
useTestNG()
testClassesDir = sourceSets.apiTest.output.classesDir
classpath = sourceSets.apiTest.runtimeClasspath
doFirst {
tasks.tomcatRun.outputs.upToDateWhen { false }
tasks.tomcatRun.contextPath = '/'
tasks.tomcatRun.daemon = true
<?php
namespace Example\Repository\Doctrine\ORM;
use Example\Test\AbstractIntegrationTest;
use Example\Util\ModelFactory;
class CompanyRepositoryTest extends AbstractIntegrationTest
{
/**
* @var CompanyRepository
@elnur
elnur / deploy.rb
Created June 7, 2014 12:38
Assets Cache Busting in Symfony
before "deploy:finalize_update" do
capifony_pretty_print "--> Update assets version"
run "if [ -f #{shared_path}/app/config/parameters.yml ]; then sed -i.bak 's/\\(assets_version:[[:space:]]*\\)[[:digit:]]*/\\1#{release_name}/' #{shared_path}/app/config/parameters.yml; fi"
capifony_puts_ok
end
@elnur
elnur / User.php
Last active August 29, 2015 14:01
Symfony Without Bundles
<?php
namespace Example\Model;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
/**
* @Entity
@elnur
elnur / NoValidateExtension.php
Last active August 29, 2015 14:01
Symfony: Disabling HTML5 Form Validation Globally
<?php
namespace Acme\Form\Extension;
use JMS\DiExtraBundle\Annotation\Service;
use JMS\DiExtraBundle\Annotation\Tag;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
/**
@elnur
elnur / reboot.yml
Last active April 26, 2021 13:31
Rebooting Servers One-by-One With Ansible http://elnur.pro/rebooting-servers-one-by-one-with-ansible/
- hosts: all
serial: 1
tasks:
- name: Reboot
command: /sbin/reboot removes=/var/run/reboot-required
- name: Wait for the server to reboot
local_action: wait_for host={{ inventory_hostname }} port=22