Skip to content

Instantly share code, notes, and snippets.

View paulononaka's full-sized avatar

Paulo Henrique Nonaka paulononaka

  • Belo Horizonte, MG - Brazil
View GitHub Profile
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@paulononaka
paulononaka / Regioes
Last active June 21, 2016 18:25
Regioes
[
{
"RegiaoId": 13,
"Nome": "MG",
"Descricao": "Minas gerais"
}
]
import UIKit
class SwiftKeyboardAvoiderHelper: NSObject, UITextFieldDelegate {
private let durationTime: Double! = 0.2
private var viewController: UIViewController!
private var originalFrame: CGRect!
private var necessaryShift: CGFloat! = 0
var shift: CGFloat!
var target: UIView!
$(document).ready(function() {
$form = $("#signup-form");
$form.bind("ajax:beforeSend", function(evt, xhr, settings){
var $submitButton = $form.find('.btn-submit');
$submitButton.attr("disabled", true);
$submitButton.data('origText', $submitButton.text());
$submitButton.text("Cadastrando..." );
})
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')

Capybara

save_and_open_page

Matchers

have_button(locator)
@paulononaka
paulononaka / Git tips
Last active December 15, 2015 15:59
git tips
== last commit that changed a specific file
git rev-list -n 1 HEAD -- <file_path>
== checkout file from commit
git checkout <deleting_commit>^ -- <file_path>
== list files changed in one specific commit
@paulononaka
paulononaka / AndroidGetIPaddress.java
Created June 20, 2011 14:18
Get IP address of device in android. The method returns the device ip address which is currently used by device irrespective of type of connection ie.,either 3g/wifi/any other.
public static String getIPAddress() throws SocketException {
for (Enumeration<?> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = (NetworkInterface) en.nextElement();
for (Enumeration<?> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = (InetAddress) enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress().toString();
}
}
}
@paulononaka
paulononaka / JavaIntToLittleEndianUnsigned
Created April 7, 2011 17:22
Convert a Int (in Java, big endian signed) to LittleEndian unsigned
private static byte[] intToLittleEndian(long numero) {
ByteBuffer bb = ByteBuffer.allocate(4);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.putInt((int) numero);
return bb.array();
}
// OR ...
private static byte[] intToLittleEndian(long numero) {
@paulononaka
paulononaka / AndroidInstallApk
Created April 5, 2011 20:54
Install an apk calling the installation screen default Android
public static void installApk(Context context, File apkFile) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
context.startActivity(intent);
}