Skip to content

Instantly share code, notes, and snippets.

View rbreve's full-sized avatar

Roberto Brevé rbreve

  • Finland
View GitHub Profile
@rbreve
rbreve / .gitignore
Created February 14, 2017 21:15
Git Ignore
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
@rbreve
rbreve / cancel.m
Created March 7, 2017 23:25
Change UIImagePickerController Cancel Button Color
[[UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil] setTitleTextAttributes:@{ NSFontAttributeName : [UIFont fontWithName:@"AmericanTypewriter" size:14.0] } forState:UIControlStateNormal];
@rbreve
rbreve / tapgesture.swift
Last active July 17, 2017 06:14
Add Gesture Recognizer Swift 3
func addTapGesture(){
//creates tap gesture recognizer
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap(recognizer:)))
//add recognizer to a view
view.addGestureRecognizer(tapImageRec)
}
//function called when tap detected
axis = transform.up;
pos += transform.right * Time.deltaTime * MoveSpeed;
transform.position = pos + axis * Mathf.Sin (Time.time * frequency ) * magnitude;
@rbreve
rbreve / rotate.swift
Created September 28, 2017 22:16
Rotate SCNNode by 90 degrees
node.localRotate(by: SCNQuaternion(x: 0, y: 0, z: 0.7071, w: 0.7071))
@rbreve
rbreve / tapnode.swift
Created September 28, 2017 22:20
Add tap gesture recognizer to scnnode
//Create TapGesture Recognizer
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap(rec:)))
//Add recognizer to sceneview
sceneView.addGestureRecognizer(tapRec)
//Method called when tap
@objc func handleTap(rec: UITapGestureRecognizer){
@rbreve
rbreve / Privacy.txt
Created December 18, 2017 22:37
facebook voto social privacidad
Términos de Servicio de Voto Social™
El siguiente es un documento legal que explica como cuidamos tus datos y los términos de servicio cuando utilizas Voto Sociual. Gracias por tu confianza.
POLÍTICA DE PRIVACIDAD
Última Actualización: Diciembre 01, 2017
INTRODUCCIÓN
Bienvenido a Voto Sociual, un servicio en Internet ("El Servicio" o el "Website") proveído por Voto Social ("votosocial.org"). Respetamos su privacidad y queremos que sepa qué información recolectamos sobre usted y qué hacemos con esa información. La siguiente Política de Privacidad fue creada para ayudarlo a entender cómo será usada la información que usted provee a votosocial.org.com. Esta Política de Privacidad aplica para toda la información que recolectamos sobre usted. Por favor sepa que votosocial.org puede contener hipervínculos a otros sitios de Internet y ocasionalmente estos sitios podrían compartir la marca votosocial.org o la marca de uno de nuestros afiliados. Sitios que están conectados a El Servicio o poseen la marca de votosoc
@rbreve
rbreve / DeviseJSON.md
Last active August 28, 2018 05:34
JSON Devise Authentication avoid "Can't verify CSRF token authenticity" Rails 5.x

To be able to authenticate a user using JSON using Devise you need to bypass the CSRF token warning that Rails throws when signing in with JSON, this is useful when trying to use a mobile app that will consume your app api and authenticate. The documention to solve this problem is outdated on google or stack overflow. Rails 5 did some changes, this is how to do it.

Add this on the Application Controller

protect_from_forgery unless: -> { request.format.json? }

More info here

Add this to the Devise SessionController

@rbreve
rbreve / voting.sol
Last active October 13, 2018 09:43
Ejemplo de Smart Contract de Voto Electrónico
pragma solidity ^0.4.0;
contract Election{
struct Candidato {
uint id;
string nombre;
uint votos;
}
pragma solidity ^0.4.21;
contract Lempira {
address public bancoCentral;
uint public supply;
mapping (address => uint) public saldos;
event Enviado(address desde, address hacia, uint valor);