Skip to content

Instantly share code, notes, and snippets.

[{"id": "THISISTHEFIRSTIDYOUWOULDNTUSE"}]
@samfcmc
samfcmc / CARD_0.py
Created March 2, 2015 19:22
Bone101 Tutorial
def cenas():
print('ola')
cenas()
export class Test {
public myString: string;
constructor(myString: string) {
this.myString = myString;
}
}
(function test() {
console.log('Testing');
})();
@samfcmc
samfcmc / ArrayListCapacity.java
Last active July 29, 2018 15:47
Instantiatig an Array List with a capacity argument
int capacity = 20;
List myList = new ArrayList(capacity);
@samfcmc
samfcmc / ThreadSleepExample.java
Created July 29, 2018 16:20
Thread sleep method makes you catch an InterrupedException
try {
Thread.sleep(1500);
} catch(InterruptedException e) {
//This should never happen...
}
public class LoginHandler {
public boolean login(String username, String password) {
String passwordFromDB = getPasswordFromDB(username);
return password.equals(passwordFromDB);
}
//...
}
String s1 = null;
String s2 = "s2";
boolean areEqual = s1.equals(s2);
public class LoginHandler {
public boolean login(String username, String password) {
if(username != null && password != null) {
String passwordFromDB = getPasswordFromDB(username);
return passwordFromDB != null && password.equals(passwordFromDB);
}
return false;
}
// Passing the capacity to the array list... Remember? :)
List<String> list = new ArrayList(2);
list.add("Test"); // This is right
list.add(2) // Compile time error... This list only accepts string elements