Skip to content

Instantly share code, notes, and snippets.

View brunojppb's full-sized avatar
🌱
code gardening...

Bruno Paulino brunojppb

🌱
code gardening...
View GitHub Profile
require 'net/http'
require 'json'
def listar_usuarios(quantidade, my_proc)
uri = URI('http://jsonplaceholder.typicode.com/users')
response = Net::HTTP.get(uri)
JSON.parse(response)
my_proc.call(quantidade)
yield JSON.parse(response) if block_given?
puts "Finalizando listagem de usuarios"
$(function() {
$('#id-do-form').submit(function() {
var valuesToSubmit = $(this).serialize();
$.ajax({
type: "POST",
url: $(this).attr('action'), //sumbits it to the given url of the form
data: valuesToSubmit,
dataType: "JSON" // you want a difference between normal and ajax-calls, and json is standard
}).success(function(json){
console.log("success", json);
fetch('/users', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').getAttribute('content')},
credentials: 'same-origin',
body: JSON.stringify( { id: 1, name: 'some user' } )
})
.then(function(data) {
@brunojppb
brunojppb / AppDelegate.m
Created January 23, 2017 15:24
Allow landscape mode in specific ViewControllers
/* Allow Landscape mode for specific ViewControllers */
-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
UIViewController* topVC = [self topViewControllerWith: self.window.rootViewController];
if ([topVC respondsToSelector:@selector(canRotate)]) {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
return UIInterfaceOrientationMaskPortrait;
}
/* get the top ViewController */

ContraChequeAPI

REST API para leitura de contracheques do estado da Paraíba.

Rotas

Login
POST  https://contrachequepb.herokuapp.com/api/contracheques/login
import UIKit
extension CGFloat {
/** Targeting the Photo Book API, converts pixels to points */
var pixelToPoints: CGFloat {
let pointsPerInch: CGFloat = 72
let scale: CGFloat = UIScreen.main.scale
let pixelPerInch: CGFloat
if UIDevice.current.userInterfaceIdiom == .pad {
@brunojppb
brunojppb / deploy.sh
Last active September 18, 2017 08:52 — forked from gre/deploy.sh
Super-small scripts for easy PlayFramework deployment
#!/bin/bash
REMOTE=play@SERVER_IP
REMOTE_APP=/home/play/PROJECT_NAME/
sbt stage || exit 1;
rsync -va target/ $REMOTE:$REMOTE_APP/target;
ssh $REMOTE "cd $REMOTE_APP; ./stop.sh";
ssh $REMOTE "cd $REMOTE_APP; ./start.sh";
@brunojppb
brunojppb / markdown.md
Created October 7, 2017 10:14 — forked from jonschlinkert/markdown-cheatsheet.md
A better markdown cheatsheet. I used Bootstrap's Base CSS documentation as a reference.

Typography

Headings

Headings from h1 through h6 are constructed with a # for each level:

# h1 Heading
## h2 Heading
### h3 Heading
@brunojppb
brunojppb / slick_debug.md
Created February 9, 2018 15:48
How to debug slick generated SQL

To show the generated SQL using slick ad Play framework:

add this line to application.conf

logger.scala.slick.jdbc.JdbcBackend.statement=DEBUG

Add those lines to logback.xml

@brunojppb
brunojppb / sbt_clean_project.sh
Created March 21, 2018 22:10
Clean SBT target cache
find . -regex ".*/target" -exec rm -r {} +