Category: Programming Languages

  • setting up background color using JavaScript

    <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”utf-8″ /> <title>Chapter 1, Example 1</title> </head> <body bgcolor=”white”> <p>Paragraph 1</p> <script> document.bgColor = “blue”; </script> </body> </html> Key source : Beginning JavaScript, 5th Edition (wrox)

  • using the dir() Built-in function in Python programming

    >>> import struct >>> dir() # show the names in the module namespace [‘__builtins__’, ‘__doc__’, ‘__name__’, ‘struct’] >>> dir(struct) # show the names in the struct module [‘Struct’, ‘__builtins__’, ‘__doc__’, ‘__file__’, ‘__name__’, ‘__package__’, ‘_clearcache’, ‘calcsize’, ‘error’, ‘pack’, ‘pack_into’, ‘unpack’, ‘unpack_from’] >>> class Shape(object): def __dir__(self): return [‘area’, ‘perimeter’, ‘location’] >>> s = Shape() >>> dir(s) […]

  • Hacking with ANSI C signal Handling

    $sudo strace -e trace=signal -p 1 [sudo] password for jeffrin: Process 1 attached kill(4659, SIGTERM) = 0 kill(4659, SIGCONT) = 0 $gcc crtlc1-p1.c $./a.out Hello world Hello world Hello world Hello world Hello world Hello world Hello world Hello world Hello world ^Ci got a signal 2 Hello world Hello world ^C $cat crtlc1-p1.c #include […]

  • Hacking with a JavaScript Program

    var drawCats = function (howManyTimes) { for (var i = 0; i < howManyTimes; i++) { console.log(i + " =^.^=); } }; drawCats(11); VM455:4 Uncaught SyntaxError: Unexpected token ILLEGALmessage: "Unexpected token ILLEGAL"stack: (…)get stack: function () { [native code] }arguments: nullcaller: nulllength: 0name: ""prototype: StackTraceGetter__proto__: function Empty() {}set stack: function () { [native code] }arguments: […]

  • Looking into a few commands with python interactive shell

    ABOUT PYTHON Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python has a design philosophy that emphasizes code readability, notably using significant whitespace. It provides constructs that enable clear programming on both small and large scales.[26] Van Rossum led the language community until stepping down […]

  • How to write a program to solve project Euler problem 4

    ”’ This file is worked on from http://www.s-anand.net/euler.html , Solution of Problem 4 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. Find the largest palindrome made from the product of two 3-digit numbers. ”’ n = 0 for […]

  • Hacking with runit and sv ( sv – control and manage services monitored by runsv(8) ) commands

    ABOUT runit runit is a cross-platform Unix init scheme with service supervision, a replacement for sysvinit, and other init schemes. It runs on GNU/Linux, *BSD, MacOSX, Solaris, and can easily be adapted to other Unix operating systems ABOUT sv The sv program reports the current status and controls the state of services monitored by the […]

  • Project Euler Problem 2, solution internals related using ruby debugger

    $ruby -rdebug euler-two.rb Debug.rb Emacs support available. /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:57: RUBYGEMS_ACTIVATION_MONITOR.enter (rdb:1) r /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:57: RUBYGEMS_ACTIVATION_MONITOR.enter (rdb:1) r /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:57: RUBYGEMS_ACTIVATION_MONITOR.enter (rdb:1) next /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:143: RUBYGEMS_ACTIVATION_MONITOR.exit (rdb:1) next euler-two.rb:3:n1, n2 = 1, 2 (rdb:1) next euler-two.rb:4:sum = 0 (rdb:1) print n1 1nil (rdb:1) print n2 2nil (rdb:1) next euler-two.rb:6:while n2 < 4000000 (rdb:1) print n2 2nil (rdb:1) next euler-two.rb:7:sum += […]

  • Project Euler Problem 3, solution internals using python debugger

    $python -m pdb euler-three.py > /home/jeffrin/beautifulwork/lib/euler-three.py(7)() -> ”’ (Pdb) r 6857 –Return– > /home/jeffrin/beautifulwork/lib/euler-three.py(17)()->None -> print n (Pdb) next –Return– > (1)()->None (Pdb) next The program finished and will be restarted > /home/jeffrin/beautifulwork/lib/euler-three.py(7)() -> ”’ (Pdb) next > /home/jeffrin/beautifulwork/lib/euler-three.py(9)() -> n = 600851475143 (Pdb) next > /home/jeffrin/beautifulwork/lib/euler-three.py(11)() -> i = 2 (Pdb) next > /home/jeffrin/beautifulwork/lib/euler-three.py(12)() […]

  • Project Euler Problem 2, solution internals using python debugger

    $python -m pdb project-euler-2.py > /home/jeffrin/beautifulwork/lib/project-euler-2.py(13)() -> ”’ (Pdb) next > /home/jeffrin/beautifulwork/lib/project-euler-2.py(15)() -> cache = {} (Pdb) next > /home/jeffrin/beautifulwork/lib/project-euler-2.py(16)() -> def fib(n): (Pdb) next > /home/jeffrin/beautifulwork/lib/project-euler-2.py(20)() -> n = 0 (Pdb) next > /home/jeffrin/beautifulwork/lib/project-euler-2.py(21)() -> i = 0 (Pdb) next > /home/jeffrin/beautifulwork/lib/project-euler-2.py(22)() -> while fib(i) /home/jeffrin/beautifulwork/lib/project-euler-2.py(23)() -> if not fib(i) % 2: n = […]