Skip to content

Instantly share code, notes, and snippets.

View omarkdev's full-sized avatar

Marcos Felipe omarkdev

View GitHub Profile
@omarkdev
omarkdev / object-calisthenics-rule1-example2.php
Last active March 5, 2019 01:01
Object Calisthenics - Primeira Regra - Exemplo 2
<?php
function premiumUsers($users)
{
return array_filter($users, "userTypeIsPremium");
}
function userTypeIsPremium($user) {
return $user->type = USER_TYPE_PREMIUM;
}
@omarkdev
omarkdev / object-calisthenics-rule1-example.php
Last active March 5, 2019 01:00
Object Calisthenics - Primeira Regra - Exemplo
<?php
function premiumUsers($users)
{
$premiumUsers = [];
foreach ($users as $user) {
if ($user->type === USER_TYPE_PREMIUM) {
$premiumUsers[] = $user;
}
}
<scheme name="_@user_Atom One Dark" version="142" parent_scheme="Darcula">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2018-03-23T15:28:07</property>
<property name="ide">PhpStorm</property>
<property name="ideVersion">2017.3.6.0.0</property>
<property name="modified">2018-03-23T15:34:31</property>
<property name="originalScheme">Atom One Dark</property>
</metaInfo>
<option name="LINE_SPACING" value="1.4" />
rm routes/botman.php && wget https://raw.githubusercontent.com/botman/studio/master/routes/botman.php -P routes/ && rm app/Http/Controllers/BotManController.php && wget https://raw.githubusercontent.com/botman/studio/master/app/Http/Controllers/BotManController.php -P app/Http/Controllers/; rm app/Conversations/ExampleConversation.php; wget https://raw.githubusercontent.com/botman/studio/master/app/Conversations/ExampleConversation.php -P app/Conversations/
# v2 syntax
version: '2'
volumes:
# MySQL Data
subnet-mysql-data:
driver: local
# Redis Data
subnet-redis-data:
<scheme name="Mark Material Theme Dark" version="142" parent_scheme="Default">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2017-04-07T02:25:41</property>
<property name="ide">PhpStorm</property>
<property name="ideVersion">2017.1.1.0.0</property>
<property name="modified">2017-09-19T22:34:18</property>
<property name="originalScheme">Material Theme - Darker</property>
</metaInfo>
<option name="LINE_SPACING" value="1.6" />
<?php
protected function debug($data)
{
$fileName = "/home/mfurtado/mark.txt";
$content = file_get_contents($fileName);
$newContent = $content . "------------\n".json_encode($data)."\n------------\n";
file_put_contents($fileName, $newContent);
}
<?php
$search = isset($_GET['search']) ? trim($_GET['search']) : null;
if ($search) {
$posts = new WP_Query([
's' = $search,
'post_type' => 'downloads'
]);
}
<?php
public function store(Request $request)
{
$comment = $this->createComment($request->all());
$this->highlightCommentOnUser( $request->get('user_id'), $comment);
$this->notifyUsersInteractedWithPost($comment->post);
return ['success' => true];
<?php
public function store(Request $request)
{
// Create a new comment
$comment = Comment::create($request->all());
// Find the author and highlight the comment on your profile
$user = User::find( $request->get('user_id') );
$user->profile->highlightNewComment($comment);