Skip to content

Instantly share code, notes, and snippets.

View fdiasr's full-sized avatar

Fernando Dias fdiasr

View GitHub Profile
@fdiasr
fdiasr / functional.js
Last active September 18, 2018 04:07
Functional Javascript
// Regular function
function myFunction(a, b) {
return a + b
}
// Lambda function
const myLambda = (a, b) => a + b
// First Class type
const handler = () => console.log('this is a function')
@fdiasr
fdiasr / curl.md
Created October 10, 2017 03:03 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@fdiasr
fdiasr / inspector.js
Created September 20, 2017 21:38
Node Tips
console.log(require('util').inspect(obj, {depth:null}));
@fdiasr
fdiasr / Dockerfile
Created August 1, 2017 19:37
Dockerfile php
FROM php:7.1-fpm
RUN apt-get update \
&& apt-get install -y git libssl-dev curl libmcrypt-dev libzip-dev zip unzip --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure bcmath \
&& docker-php-ext-install pdo pdo_mysql \
&& docker-php-ext-install bcmath
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
@fdiasr
fdiasr / parse.md
Created November 25, 2016 17:33
AWK Logs
awk '($4 ~ "25\/Nov\/2016:12")' access.log | awk '{print $7}' | sort -n | uniq -c | sort -nr | head -50
@fdiasr
fdiasr / patterns.md
Created November 22, 2016 12:43
Ingresse Developing Patterns

Ingresse Developing Patterns

Devops / Management

  • Containers - Docker
  • Logs
  • Sensu
  • New Relic
  • Unit Tests
  • Behaviour Tests
@fdiasr
fdiasr / example1.php
Created November 10, 2016 18:38
php-datetimezone-bug
<?php
// example 1 - Timestamp is changing
$datetime = new DateTime('2016-11-09 20:00:00', new DateTimeZone('UTC'));
var_dump($datetime->getTimestamp());
$datetime->setTimeZone(new DateTimeZone('-03:00'));
$datetime->setTimeZone(new DateTimeZone('-03:00'));
var_dump($datetime->getTimestamp());
@fdiasr
fdiasr / project.md
Last active August 2, 2016 22:57
PHP DevTest

PHP Project DevTest

Create a RESTful API Using HTTP Verbs for a /user Endpoint

The purpose of this project is the creation of an API (using the REST architecture) for the management of user information.

The attributes of the user are up to the developer to define.

The choice of database is up to you, the developer, but data must be persistent.

<?php
namespace Ingresse\Behat\ApiExtension\Context;
use GuzzleHttp\Psr7\Request;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use GuzzleHttp\Exception\RequestException;
trait RequestContextTrait
@fdiasr
fdiasr / programmer.feature
Last active June 20, 2016 16:52
Bdd Scenarios Examples
# http://knpuniversity.com/screencast/rest/testing#play
# api/features/programmer.feature
# ...
Scenario: Create a programmer
Given I have the payload:
"""
{
"nickname": "ObjectOrienter",
"avatarNumber" : "2",