This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var reverseString = function(stringToReverse) { | |
var finalString = []; // I prefer to use arrays instead of strings. | |
// loop through the string, starting at the end. | |
for (var i = stringToReverse.length; i > 0; i--) { | |
// push the character at the current index into the finalString array | |
finalString.push(stringToReverse[i]); | |
} | |
// Join the characters in the array into a string and return the string. | |
return finalString.join(''); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var reverseString = function(stringToReverse) { | |
var finalString = []; // I prefer to use arrays instead of strings. | |
// loop through the string, starting at the end. | |
// push the character at the current index into the finalString array | |
// Join the characters in the array into a string and return the string. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var reverseString = function(stringToReverse) { | |
var finalString = ""; | |
// Our code to reverse the string goes here. | |
return finalString; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We create the "Animal" function first. | |
function Animal() { | |
this.species = "None"; | |
this.getSpecies() { | |
return this.species; | |
} | |
} | |
// Now, we create a "dog" function. Notice that there is no indication of inheritance. | |
function Dog() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Animal { | |
private String mSpecies = "None"; | |
public void talk() { | |
printf(""); | |
} | |
public String getSpecies() { | |
return mSpecies; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir test | |
cd test | |
echo "# test_repo" >> README.md | |
cat README.md | |
ls | |
git init | |
ls -la | |
git status | |
git add README.md | |
git commit -m "initial commit" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Back button listener. | |
* Will close the application if the back button pressed twice. | |
*/ | |
@Override | |
public void onBackPressed() | |
{ | |
if(backButtonCount >= 1) | |
{ | |
Intent intent = new Intent(Intent.ACTION_MAIN); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.collidesWith = function(otherObject) { | |
var width = 2*this.radius; | |
var height = 2*this.radius; | |
var translatedX = this.x - radius; | |
var translatedY = this.y - radius; | |
if (translatedX < otherObject.x + otherObject.width && | |
translatedX + width > otherObject.x && | |
translatedY < otherObject.y + otherObject.height && | |
height + translatedY > otherObject.y) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calendar calendar = new GregorianCalendar(TimeZone.getDefault()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL requestUrl = new URL(fullURLRequest); | |
HttpUrlConnection urlConnection = (HttpURLConnection) requestUrl.openConnection(); | |
InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream()); | |
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); | |
StringBuilder jsonString = new StringBuilder(); | |
// You only want to call readLine once - the assignment will fail once readLine is null; | |
// calling ReadLine twice will cause an error. | |
while (String line = bufferedReader.readLine()) { | |
jsonString.append(line); | |
} |