Skip to content

Instantly share code, notes, and snippets.

@ianrodrigues
ianrodrigues / cleanup.py
Created June 16, 2021 17:02 — forked from luhn/cleanup.py
An AWS Lambda function to delete old AMIs.
"""
Code adapted from and inspired by http://blog.ranman.org/cleaning-up-aws-with-boto3/.
"""
import os
import re
from datetime import datetime, timedelta
import boto3
@ianrodrigues
ianrodrigues / jwtRS256.sh
Created January 1, 2021 13:35 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@ianrodrigues
ianrodrigues / cf_create_or_update.py
Created November 19, 2020 01:17 — forked from svrist/cf_create_or_update.py
Update or create a CloudFormation stack given a name and template + params'
'Update or create a stack given a name and template + params'
from __future__ import division, print_function, unicode_literals
from datetime import datetime
import logging
import json
import sys
import boto3
import botocore
@ianrodrigues
ianrodrigues / bash_curl_loop
Created June 22, 2020 16:04 — forked from ceme/bash_curl_loop
bash curl loop
while true; do sleep 1; curl http://www.google.com; echo -e '\n\n\n\n'$(date);done
@ianrodrigues
ianrodrigues / Schema.graphql
Created April 24, 2020 19:30 — forked from ThisIsMissEm/Schema.graphql
Form Validation as a Result Union
mutation updateUser(
details: UpdateUserInput!
): UpdateUserResult
union UpdateUserResult =
UpdateUserSuccess |
FormValidationError
type UpdateUserSuccess {}
@ianrodrigues
ianrodrigues / responsive-video.css
Created March 16, 2018 19:33 — forked from jaicab/responsive-video.css
Pure CSS solution for embed videos with an aspect ratio of 16:9
.video-container {
position: relative;
padding-bottom: 56.25%; /*16:9*/
padding-top: 30px;
height: 0;
overflow: hidden;
}
.video-container iframe,
.video-container object,
@ianrodrigues
ianrodrigues / paginate.php
Created December 19, 2017 13:15 — forked from vluzrmos/paginate.php
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator
@ianrodrigues
ianrodrigues / README.md
Created September 11, 2017 12:49 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

@ianrodrigues
ianrodrigues / 1.How to easily implement a REST API with oAuth2 presentation.md
Created September 11, 2017 12:45 — forked from lologhi/1.How to easily implement a REST API with oAuth2 presentation.md
Symfony2 : How to easily implement a REST API with oAuth2 (for normal guys)

It's still a work in progress...

Intro

As William Durand was recently explaining in his SOS, he "didn't see any other interesting blog post about REST with Symfony recently unfortunately". After spending some long hours to implement an API strongly secured with oAuth, I thought it was time for me to purpose my simple explanation of how to do it.

Ok, you know the bundles

You might have already seen some good explanation of how to easily create a REST API with Symfony2. There are famous really good bundles a.k.a. :

@ianrodrigues
ianrodrigues / .gitlab.ci.yml
Created May 2, 2017 10:51 — forked from yannhowe/.gitlab.ci.yml
.gitlab.ci.yml for SSH with private key.
# Image neeeds to have ssh-client
image: docker:git
services:
- docker:dind
stages:
- staging
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY