Skip to content

Instantly share code, notes, and snippets.

View igordeoliveirasa's full-sized avatar

Igor de Oliveira Sá igordeoliveirasa

View GitHub Profile
@igordeoliveirasa
igordeoliveirasa / gist:6ff4a86b93fd4c57ba00
Last active August 29, 2015 14:20
Configuring Karma & Jasmine
mkdir tests
echo "
describe(\"A suite\", function() {
it(\"contains spec with an expectation\", function() {
expect(true).toBe(true);
});
});
" > tests/test.spec.js
npm install karma --save-dev
@igordeoliveirasa
igordeoliveirasa / gist:b7a8e0a76201a09fdbac
Created April 16, 2015 02:43
iOS - Swift - Alamofire - Restful
let params: Dictionary<String,AnyObject> = ["user[country_name]": countryName, "user[country_code]": countryCode, "user[mobile_number]": mobileNumber, "user[name]":"", "user[device_token]":deviceToken]
Alamofire.request(.POST, ConstantsBackend.URL_REGISTER, parameters: params)
.validate(statusCode: 200..<300)
.validate(contentType: ["application/json"])
.responseJSON { (_, _, JSON, ERROR) in
if (ERROR != nil)
{
println("FALHA AO REGISTRAR")
LoadingOverlay.shared.hideOverlayView()
@igordeoliveirasa
igordeoliveirasa / gist:d97272965b2cdd4d73c6
Last active April 12, 2016 13:24
iOS - Swift - Show View Controller
let _storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = _storyboard.instantiateViewControllerWithIdentifier("countryTableViewController") as CountryTableViewController
vc.setupDelegate = self
self.showViewController(vc, sender: nil)
let alertController = UIAlertController(title: "Atenção...", message: "Código de funcionário inválido!", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alertController, animated: true, completion: nil)
@igordeoliveirasa
igordeoliveirasa / gist:81ead0da2c2ecdffed28
Created March 26, 2015 08:35
iOS/Swift - Push Notification - Retrieving and Saving Device Token at NSUserDefaults
//
// AppDelegate.swift
// app
//
// Created by Igor de Oliveira Sa on 25/02/15.
// Copyright (c) 2015 Igor de Oliveira Sa. All rights reserved.
//
import UIKit
import CoreData
@igordeoliveirasa
igordeoliveirasa / gist:78a310f0348fcad9b270
Created March 26, 2015 01:41
iOS Loading Overlay View - SWIFT
//
// LoadingOverlay.swift
// app
//
// Created by Igor de Oliveira Sa on 25/03/15.
// Copyright (c) 2015 Igor de Oliveira Sa. All rights reserved.
//
// Usage:
//
// # Show Overlay
public class CharlieFTPClient {
FTPClient ftpClient;
public CharlieFTPClient(FTPClient ftpClient) {
this.ftpClient = ftpClient;
}
public boolean connect(String ip, String userName, String pass) throws IOException {
ftpClient.setConnectTimeout(10 * 1000);
ftpClient.connect(InetAddress.getByName(ip));
@igordeoliveirasa
igordeoliveirasa / gist:9d414f5772c09d8bfb28
Created February 20, 2015 13:43
Android Alert With Text Input
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle("Title");
alert.setMessage("Message");
// Set an EditText view to get user input
final EditText input = new EditText(context);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@igordeoliveirasa
igordeoliveirasa / gist:27d61a95bf0c610e799a
Created February 20, 2015 12:36
Image View Programmatically
ImageView imageView = new ImageView(context);
LinearLayout.LayoutParams imageViewLayoutParams = new LinearLayout.LayoutParams(56,56);
imageViewLayoutParams.setMargins(context.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), 0, 0, 0);
imageView.setLayoutParams(imageViewLayoutParams);
imageView.setTag(photo);
@igordeoliveirasa
igordeoliveirasa / gist:74a4a9e0974981de52a5
Created February 20, 2015 12:36
Linear Layout Programmatically
LinearLayout linearLayout = new LinearLayout(context);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(context.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin),0,0,0);
linearLayout.setLayoutParams(layoutParams);
linearLayout.setBackground(context.getResources().getDrawable(R.drawable.shape_rounded_background));