mongoDB – under SUSE SLE11 – SP3
Getting started with mongoDB under Suse Linux. Installation:
1 2 3 |
zypper addrepo --no-gpgcheck http://repo.mongodb.org/zypper/suse/11/mongodb-org# sudo zypper install mongodb-org vi /etc/mongod.conf |
Note: Default port is 27017 Starting/Stopping mongoDB server:
1 2 |
sudo service mongod start sudo service mongod stop |
Verify server status:
1 |
tail -f /var/log/mongodb/mongod.log |
Make it part of the autostart for different run levels:
1 |
sudo chkconfig mongod on |
Getting started with mongoDB
Read MoreHide/Show Desktop Icons on SUSE
Sometimes it is desirable to have a clean desktop. The following steps will allow you to achieve that with minimal commands.
1 2 3 4 5 |
- open a terminal - type gconf-editor - navigate apps/nautilus/desktop - Select/De-select the items you want to display on the desktop. - Exit from there and you are done! |
Mojolicious
Quick Install:
1 |
curl -L https://cpanmin.us | perl - -M https://cpan.metacpan.org -n Mojolicious |
Parent Link: http://mojolicio.us/ Gererating a Lite App called hello_world:
1 |
mojo generate lite_app hello_world |
Place holders:
1 2 3 |
/:foo - Generic place holder /(.foo) - Relaxed place holder which accepts dots /*foo - Wildcard place holder which accepts dots and forward slashes |
Using the above 3 you could drive with 2 more place holders.
1 2 |
optional place holder - specifying a default value makes a place holder optional. restrictive place holder - Specifying a set of values makes the place holder restricted. |
Using CPAN to install Mojolicious Plugins:
1 |
curl -L cpanmin.us | perl - App::cpanmius |
Once the cpanminus tools are installed, you could use cpanm to download and install plugins.
1 |
cpanm Mojolicious::Plugin::ParmsAuth |
Storing Values:
1 2 3 |
stash - works only with current request flash - works only with the next (future) request session - works with all request until deleted or expired |
Debugging Mojo code:
1 |
MOJO_USERAGENT_DEBUG=1 perl mojo_script_name.pl |
Finding …
Read Moremy .vimrc
Here is my .vimrc file on a SUSE SLE11-SP3 box
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
set nu set laststatus=10 set autoindent set tabstop=2 set shiftwidth=2 set smartindent set expandtab syntax on set textwidth=79 set formatoptions=qrn1 "if version >= 703 if exists('+colorcolumn') set colorcolumn=80 endif set history=500 set nobackup set noswapfile "set list "set listchars=tab:.\ ,trail:.,extends:#,nbsp:. set listchars=tab:▸\ ,eol:¬,extends:#,nbsp:.,trail:. if has("gui_running") set guifont=DEC\ Terminal "colorscheme darkblue colorscheme evening set guioptions-=r set go-=L set go-=T else colorscheme darkblue endif "line tracking set numberwidth=5 set cursorline set cursorcolumn " turn off cursor blinking set guicursor+=a:blinkon0 |
LAMP – install on Ubuntu
Easiest way to install LAMP stack on Ubuntu servers
1 2 |
sudo apt-get update sudo apt-get install lamp-server^ |
Yes the ^ is needed.
Read MoreBuild & Install node.js from source code
Following instructions are tested on Ubuntu 10.04 & node v0.12.2 download node package from http://nodejs.org/dist/latest/ tar -xvzf node-v0.12.2.tar.gz cd node-v0.12.2 Run the following commands
1 2 3 |
./configure make sudo make install |
To test the install
1 2 3 4 |
~$ node > (^C again to quit) > |
Hello World Test! vi hello.node.js
1 |
console.log("Hello, World!") |
To Run,
1 |
node hello.node.js |
Let’s do something more than Hello World.
1 |
vi http.test.js |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
var http = require("http"); http.createServer(function (request, response) { // Send HTTP Status: 200 : OK // Content Type: text/plain response.writeHead(200, {'Content-Type': 'text/plain'}); // Send the response body as "Hello World" response.end('Hello World\n'); }).listen(8888); // Console will print the message console.log('Server running at http://127.0.0.1:8888/'); |
To test the above code
1 2 |
On a Console: node http.test.js On a Web browser: http://127.0.0.1:8888 |
jQuery Fundamentals
The jQuery library provides the jQuery function,
1 |
var listItems = jQuery( 'li' ); |
Is same as…
1 |
var listItems = $( 'li' ); |
Which select all ‘li’ elements. The following ensures the page is ready for jQuery operations.
1 |
$(document).ready() |
Is same as…
1 |
$() |
Example:
1 2 3 4 |
// $( document ).ready(function() { $(function() { console.log( 'ready!' ); }); |
Get some elements from a page
1 2 3 4 |
$( '#header' ); // select the element with an ID of 'header' $( 'li' ); // select all list items on the page $( 'ul li' ); // select list items that are in unordered lists $( '.person' ); // select all elements with a class of 'person' |
Filtering selections with jQuery:
1 2 3 4 5 6 7 8 9 10 |
var listItems = $( 'li' ); // filter the selection to only items with a class of 'special' var special = listItems.filter( '.special' ); // filter the selection to only items without a class of 'special' var notSpecial = listItems.not( '.special' ); // filter the selection to only items that contain a span var hasSpans = listItems.has( 'span' ); |
Events
1 2 3 |
$( '#my-unordered-list' ).on( 'click', 'li', function( event ) { console.log( this ); // logs the list item that was clicked }); |
Effects
1 2 3 4 5 6 7 |
.show() Show the selected elements. .hide() Hide the selected elements. .fadeIn() Animate the opacity of the selected elements to 100%. .fadeOut() Animate the opacity of the selected elements to 0%. .slideDown() Display the selected elements with a vertical sliding motion. .slideUp() Hide the selected elements with a vertical sliding motion. .slideToggle() Show or hide the selected elements with a vertical sliding motion. |
Custom effects with .animate()
1 2 3 4 5 6 7 8 9 10 |
$( '.funtimes' ).animate({ left: '+=50', // increase by 50 opacity: 0.25, fontSize: '12px' }, 300, function() { // executes when the animation is done } ); |
Managing animate
1 2 |
.stop() will stop currently running animations on the selected elements. .delay() will pause before the execution of the next animation method. |
dummy sendmail
Lets say you are developing an app that sends mail, but you don’t want to actually send any mails out. The answer for your quest is “dummy sendmail”
1 2 3 4 5 6 7 8 9 |
#!/bin/bash # replace the /usr/bin/sendail with this shell script. # Everytime someone sends a mail, the content of the mail will be written to a file under /tmp/mail.20150203.log TS=`date "+%Y%m%d"` FN="/tmp/mail.$TS.log" cat - >> $FN echo "=== End Of Message Received ===" >> $FN |