Skip to content

Instantly share code, notes, and snippets.

@sax1johno
sax1johno / AndroidBackHack.java
Created May 17, 2016 20:01
Lifted from StackOverflow, this will allow the developer to capture the back button in an activity and exit the app completely if the button is pressed twice.
/**
* 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);
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"
class Animal {
private String mSpecies = "None";
public void talk() {
printf("");
}
public String getSpecies() {
return mSpecies;
}
}
// 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() {
var reverseString = function(stringToReverse) {
var finalString = "";
// Our code to reverse the string goes here.
return finalString;
}
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.
}
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('');
}
@sax1johno
sax1johno / remove-docker-containers.md
Created August 2, 2016 02:10 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images
  1. Delete all containers

     $ docker ps -q -a | xargs docker rm
    

-q prints only the container IDs -a prints all containers

Notice that it uses xargs to issue a remove container command for each container ID

  1. Delete all untagged images
docker rmi $( docker images -q -f dangling=true)
I just worked out another flow to have Zero downtime (mainly for web apps).
Proxy
We use jwilder/nginx-proxy to handle routing to app servers, this will assist us in dynamically routing requests to services.
First Deploy
For the first deploy run docker-compose --project-name=app-0001 up -d.