Skip to content

Instantly share code, notes, and snippets.

Avatar

Igor de Oliveira Sá igordeoliveirasa

View GitHub Profile
@igordeoliveirasa
igordeoliveirasa / gist:6ff4a86b93fd4c57ba00
Last active Aug 29, 2015
Configuring Karma & Jasmine
View gist:6ff4a86b93fd4c57ba00
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 Apr 16, 2015
iOS - Swift - Alamofire - Restful
View gist:b7a8e0a76201a09fdbac
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 Apr 12, 2016
iOS - Swift - Show View Controller
View gist:d97272965b2cdd4d73c6
let _storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = _storyboard.instantiateViewControllerWithIdentifier("countryTableViewController") as CountryTableViewController
vc.setupDelegate = self
self.showViewController(vc, sender: nil)
View gist:bdc54869ce494f756f83
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 Mar 26, 2015
iOS/Swift - Push Notification - Retrieving and Saving Device Token at NSUserDefaults
View gist:81ead0da2c2ecdffed28
//
// 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 Mar 26, 2015
iOS Loading Overlay View - SWIFT
View gist:78a310f0348fcad9b270
//
// 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
View gist:34a6957f82b90333e2fc
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));
View gist:9d414f5772c09d8bfb28
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() {
View gist:27d61a95bf0c610e799a
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 Feb 20, 2015
Linear Layout Programmatically
View gist:74a4a9e0974981de52a5
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));