Skip to content

Instantly share code, notes, and snippets.

docker rmi $( docker images -q -f dangling=true)
@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
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('');
}
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 = "";
// Our code to reverse the string goes here.
return finalString;
}
// 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() {
class Animal {
private String mSpecies = "None";
public void talk() {
printf("");
}
public String getSpecies() {
return mSpecies;
}
}
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"
@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);
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) {