Tag Archive for console

jquery console.log

jQuery.fn.log = function (msg) {
      console.log("%s: %o", msg, this);
      return this;
  };

source

Shell coloring

export PS1='[ 33[01;31m]u[ 33[01;33m]@[ 33[01;36m]h [ 33[01;33m]w [ 33[01;35m]$ [ 33[00m]'
export LS_OPTIONS="--human --color=always"

source

Stores the name to a string variable and displays it.

x = raw_input("Enter name: ")
print "Hey " + x
raw_input("Press<enter>")

source

Define and call a function in interactive mode

#Define a function
>>> def hola():
        print "hola mundo"

#Call the function
>>> hola()
hola mundo

source

Enter your age.

# Have bug if you write letters instead of numbers I think.
quitar =""
while quitar != "q":
    edad = raw_input("Enter your age
")
    if edad != '':
        #Here it should be asked for if the age variable contains letters fails to convert.
        edad = int(edad)
        if edad == 18 or edad > 18 and edad < 50:
            print "You're of age"
        elif edad < 18:
            print "You're a minor"
        elif edad == 50 or edad > 50:
            print "You are in the golden age"
        else:
            print "You have not written anything"
        quitar = raw_input("Press q to quit or enter to repeat")
    else:
        quitar = raw_input("Press q to quit or enter to repeat")

source

Hello World in Python 3.

print("Hello World")

source

Function Timing Example (includes jQuery)

$(function(){
console.info("Start Test");
var d = new Date();//Get our start time
console.info(d.getSeconds() + " " + d.getMilliseconds());

//Run our test
var testBody = "";
for (var i=0; i<1000; i++){
testBody += "<div class='testable"+i+"'>";
}
$("body").append(testBody);
for (var j=0; j<1000; j++){
$(".testable"+j);
}

var d = new Date();//Get our end time
console.info(d.getSeconds() + " " + d.getMilliseconds());
console.info("End Test");
/**
* Console will now log 2 times, the difference between
* them is how long the test took to run
*/
});

source

Hacky screen clearing through printf

#include <stdio.h>

int main(){
printf(" 33[2J 33[0;0f");
printf(" 33[%d;%df", 0, 0);

return 0 ;
}

source

remove files recursively in Linux

rm -rf `find . -type d -name FILE-TO-DELETE`

source

Check For Console object in web browser with JavaScript

if(typeof(console) !== 'undefined' && console != null) {
console.log("hello world!");
}

source