Skip to content

Instantly share code, notes, and snippets.

View biancarosa's full-sized avatar
💜

bianca rosa biancarosa

💜
View GitHub Profile
@biancarosa
biancarosa / pre-commit
Created August 15, 2017 22:07
Golang fmt - Pre commit
#!/bin/sh
go fmt ./...
@biancarosa
biancarosa / pre-push
Created August 15, 2017 22:05
Golang Tests - Pre Push
#!/bin/sh
status=0
failing_tests="$(go test ./... | grep "FAIL:" | awk '{print $3}')"
if test -n "$failing_tests" ; then
for fail in $failing_tests; do
echo "git pre-push check failed: go test failed: $fail"
done
status=1
fi

First

  • Documentar a API.

Second

  • mkdir group-orders-api
  • cd group-orders-api
  • git init
  • mkdir tests
@biancarosa
biancarosa / robomongo.desktop
Created February 23, 2017 15:15
Desktop Icon - Fedora - Robomongo
[Desktop Entry]
Name=Robomongo
GenericName=Robomongo
Exec=/opt/robomongo/bin/robomongo
Terminal=false
Icon=/opt/robomongo/icons/robomongo123.png
Type=Application
Categories=Application;
Comment=Robomongo
@biancarosa
biancarosa / firefox_dev.desktop
Created February 23, 2017 15:13
Desktop Icon - Fedora - Firefox Developer Edition
[Desktop Entry]
Name=Firefox Developer
GenericName=Firefox Developer Edition
Exec=/opt/firefox_dev/firefox
Terminal=false
Icon=/opt/firefox_dev/browser/icons/mozicon128.png
Type=Application
Categories=Application;Network;X-Developer;
Comment=Firefox Developer Edition Web Browser.
@biancarosa
biancarosa / docker_consul.sh
Created February 18, 2017 18:24
Script to start Consul as a Docker container
docker pull consul
docker run -d --name=dev-consul -p 8500:8500 consul
firefox localhost:8500
@biancarosa
biancarosa / auth.py
Created September 24, 2016 14:44
Falcon example hook
# hooks/auth.py
import falcon
from api.models.user_token import UserToken
def authorize():
def hook(req, resp, resource, params):
token = req.context.get('token')
if token is None:
description = ('Please provide an auth token as part of the request.')
raise falcon.HTTPUnauthorized('Auth token required', 'Auth token required', description, href='http://docs.example.com/auth')
@biancarosa
biancarosa / json_translator.py
Last active September 24, 2016 14:46
Falcon JSON Translator
# middlewares/json_translator.py
import json
import falcon
class JSONTranslatorMiddleware(object):
def process_request(self, req, resp):
if req.content_length in (None, 0):
return
body = req.stream.read()
if not body:
@biancarosa
biancarosa / app.py
Created September 24, 2016 14:08
Falcon sample app (2 resources)
# app.py
import falcon
import json
class SongsResource:
def on_get(self, req, resp):
songs = [
{
"title": "Your Song", "artist": "Elton John"
'use strict';
/* https://github.com/angular/protractor/blob/master/docs/toc.md */
describe('my app', function() {
it('should automatically redirect to /sign-up when location hash/fragment is empty', function() {
browser.get('index.html');
expect(browser.getLocationAbsUrl()).toMatch("/sign-in");
});