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
<?php | |
interface DBTransaction { | |
public function begin(); | |
public function commit(); | |
public function rollback(); | |
} | |
class LaravelDBTransaction implements DBTransaction { | |
public function begin() |
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 {render as rtlRender} from 'react-testing-library' | |
function render ({foo = 'defaultFoo', doSomething = jest.fn()} = {}) { | |
const result = rtlRender(<MyComponent foo={foo} doSomething={doSomething} />) | |
return { | |
...result, | |
doSomething, | |
clickButton: () => fireEvent.click(result.querySelector('button')) | |
} | |
} |
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
function Profile ({userId}) { | |
const [profile, setProfile] = useState(null) | |
useEffect(() => { | |
fetch(`/api/users/${userId}`) | |
.then(res => { | |
setProfile(res.json().profile) | |
}) | |
}, [userId]) // run when it has new userId | |
return ( | |
<div>{profile && profile.full_name}</div> |
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
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
export PS1="> \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ " |
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 React from 'react' | |
import { Route, Link } from 'react-router-dom' | |
const TabLink = ({ to, exact, title }) => ( | |
<Route path={to} exact={exact} children={({ match }) => ( | |
<li className={`nav-item ${match ? 'active' : ''}`}> | |
<Link to={to} className='nav-link' role='tab'>{title}</Link> | |
</li> | |
)} /> | |
) |
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
class Container { | |
constructor () { | |
this._definitions = {} | |
} | |
register (id, func, factory = false) { | |
if (typeof func !== 'function') { | |
throw new Error('Invalid service function.') | |
} | |
this._definitions[id] = { |
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
--- | |
- name: Define release name. | |
set_fact: app_project_release={{ lookup('pipe', 'date +%Y%m%d%H%M%S') }} | |
- name: Set current release directory. | |
set_fact: app_current_release_dir={{app_project_root}}/releases/{{app_project_release}} | |
- name: Set shared directory. | |
set_fact: app_shared_dir={{app_project_root}}/shared |
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
<?php | |
use Doctrine\ORM\EntityManager; | |
use Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver; | |
use Doctrine\ORM\Tools\Setup; | |
use Silex\Application; | |
use Silex\ServiceProviderInterface; | |
class DoctrineServiceProvider implements ServiceProviderInterface |
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
#!/usr/bin/env php | |
<?php // app/cli.php | |
use Silex\Application; | |
use Symfony\Component\Console\Application as Console; | |
require __DIR__ . '/../vendor/autoload.php'; | |
/** @var Application $app */ | |
$app = require 'app.php'; |
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
<?php | |
namespace Acme\Project\Bundle\AppBundle\Data; | |
use Acme\Project\Model\App\Data\TransactionManager; | |
use Doctrine\ORM\EntityManagerInterface; | |
class DoctrineTransactionManager extends TransactionManager | |
{ | |
/** |