sailfish os – the true linux experience on your smartphone

From wiki:

Sailfish OS (also styled as SailfishOS[4] or abbreviated to SFOS) is a mobile operating system combining the Linux kernelfor a particular hardware platform use, the open-source Mer core middleware, a proprietary UI contributed by Jolla, and other third-party components.[1][2]

well, i would simply put it as:

THE BEST ALTERNATIVE OS OUT THERE FOR SMARTPHONES

if you are a linux user you will be at ease with this phone…

if you turn on developer settings then you have a fully fledged terminal (through terminal app) to do anything like your linux box…. (the lines “with more power comes greater responsibilites” resonates all over)

package manager: RPM

in other words, a rooted phone out of the box, set the root password and you are good to go……so, like all rooted phones, power in your hands….

One huge surprise (to me its the best thing about the phone):

NO back, home & recent keys

  • it’s only gestures you need and that’s how it should have been from the very beginning in a smartphone (touch device)…why do you need the keys?
  • a truly multi-tasking OS in the true sense which you will fall in love straight away….

to me google is no lesser evil than the coporates out there and a phone away from the clutches of google is like a true freedom at last…..

Can android apps (whatsapp, fb and the likes) still run on it?
YES they do but sailifish from its “jolla store” has alternatives for the major android apps.
not to disappoint the “play store” fans they run android apps on a special vm known as “android dalvik cache” in sailfish world which helps you download apps form google play store and run them as normal android apps….

stable but for rare instances when apps just doesnt open for sometime (in the starting stages but the latest update looks good)

it’s a refreshing OS, and if you havent checked it out, I suggest you get your hands on one right away!!!

final verdict – 4 out of 5 stars

ndoe js primer

What is node.js?

Direct from Source:

it is a headless javascript engine.

it is literally the same JavaScript engine (named V8) that runs inside of Google Chrome, except that with Node.js, you can run JavaScript from the command line instead of in your browser.

what i have understood from reading is that its like the lego toy you give to kid…

you have the blocks and now you got to make building, vehicles etc…the choice is what you want to build….

why is it popular?

node.js uses only one language (JavaScript) left, right and centre….

isnt’t it cool to make great apps just knowing javascript alone….well thats the power of node.js

so lets cut the talk and walk the talk….

a basic hello node in nodejs


var http = require('http'); //import the http module

http.createServer(function(req, res) { //create an http server instance equivalent to triggering an httpd start on linux for LAMP
res.writeHead(200); //write header for OK status
res.end('hello node..let us start');
//res.end('Blank lines');
}).listen(8080);

save the file as http_test.js (name it what you want..doesnt matter)

open up a terminal and run the node instance

~[3]$>node /path/to/http_test.js

Fire up a browser and run

localhost:8080

now you should see the lines on the page:

hello node..let us start

Well thats the node.js up and running

a very important thing not documented everywhere (it must be dont know why it isnt):

try changing the lines to something else

var http = require('http'); //import the http module

http.createServer(function(req, res) { //create an http server instance equivalent to triggering an httpd start on linux for LAMP
res.writeHead(200); //write header for OK status
//res.end('hello node..let us start');
res.end('hello node i cant run as you expect you wont see me');
}).listen(8080);

try refreshing the browser page and you wont see your changes…instead you get a cached version of the file (older code ie. the older instance of node)

the reason is you need to restart the node instance with file name to re-parse the whole file…

you need to stop and re run the server to see your latest update.

ofcourse this is a pain in the ass to restart node instance everytime we make changes…but not to worry node.js has a great community and has already provided lots of solutions…

i prefer nodemon to automate the task of restarting node instance when you update your file or make changes to it

npm is node package manager your modules manager in node.js environment

1) Install nodemon. To install, from your terminal run:

npm install -g nodemon

2) Now, go to terminal, where you have the program. And, run

nodemon http_test.js

Now, everytime when you make changes to your app, just save your changes and it will get reflected.

Details :-

Nodemon is a utility that will monitor for any changes in your source and automatically restart your server

 

 

Anonymous functions

what are anonymous functions?

Anonymous functions(aka. lambda) originating from the Lambda calculus are similar to our regular functions, in that they contain a block of code that is run when they are called (well, pretty similar and now you all know that before). They can also accept arguments, and return values.

The key difference — as their name implies — is that anonymous functions have no name.
Another difference is that they end in semicolons i.e. function definitions are expressions, whereas regular function definitions are code constructs.

so why do we need functions with no name?

the best solution or answer that can come to my mind is when you think of callbacks.

well, you can refer here and i have pasted the same below for continued reading

since an anonymous function is an expression — much like a number or a string — you can do various handy things with it. For example, you can:

1. Assign it to a variable, then call it later using the variable’s name. You can even store a bunch of different anonymous functions in a single array. – variable functions

2. Pass it to another function that can then call it later. This is known as a callback.

3. Return it from within an outer function so that it can access the outer function’s variables. This is known as a closure.

 

So, to code straight away and here is the example for the first set i.e. variable functions.


<?php
<pre>#use type one for anonymous function
#i.e. variable functions
class VarFuncs{
 public $my_var;
 public function __construct(){
 $this->my_var=function( $name, $timeOfDay ) {
 return ( "Welcome to another glorious $timeOfDay, $name!" );
 };
 }
 #workaround for PHP ver < PHPv7
 function __call($method, $args)
 {
 if (isset($this->$method) && $this->$method instanceof \Closure) {
 return call_user_func_array($this->$method, $args);
 }

 trigger_error("Call to undefined method " . get_called_class() . '::' . $method, E_USER_ERROR);
 } 
}

$object=new VarFuncs();
$check_output=$object->my_var("nightslacker","night");
echo $check_output."\n";
?>

As of PHPv7 we can replace the line 19 with

</pre>
<pre>$check_output=($object->my_var)("nightslacker","night");//note the brackets around the object</pre>
<pre>

 

Now, we can go on and implement the second point i.e. callbacks.

<?php</pre>
<pre>#use type two for anonymous function
#i.e. callbacks</pre>
<pre>
class MainFunc{
private function toUpperCase($receiveArr) {
return strtoupper($receiveArr);
}
public function changeCase(array $arr){
return array_map(array($this,'toUpperCase'),$arr);
}
}
$objMainFun=new MainFunc();

$resultArr=$objMainFun->changeCase(array('nightslacker','changed','to','uppercased nightslacker'));
print_r($resultArr);
?>

you get the result of the array with all caps for the array that’s passed using the callback toUpperCase

 

how to connect an android phone with linux to transfer files

the post i am going to present is for connecting your android phone with slackware or any linux distribution and secondly, transfer files to it….

here is the link that send me in the correct path!!! cheers to him!!!

https://lucky13linux.wordpress.com/2009/07/04/using-libmtp-mtp-tools-in-fedora-10/

first of all make sure you have the mtpfs library in your system…(slackers can fetch it from slackbuilds.org)

we need to make a mount point for our phone….

i made it in /mnt as in /mnt/phone

once we got mtpfs installed run the below commands as i have typed them…

mtpfs /mnt/phone

mtpfs -o allow_other /mnt/phone


now the final step is to transfer files to phone…but wait….a normal mtpfs-sendfile wont work here…weird…..whats weirder is that android phone has all its folders mapped to a number….you need to use this number to transfer files to it…..

not to worry….mtpfs has the solution for it….

so to get the list of numbers for our folders in the android phone just type

mtp-folders

now you get a mapping of key value pairs where each file in your android is mapped to which number…..i wanted to copy an mp3 file and it was 172

so am all set to transfer and i enter the below command:

mtp-connect –sendfile /path/to/file/nightcrawler.mp3 172

voila! and guess what the file was successfully transferred…..

 

Well that’s one way of doing it without a network around to help you.

Note: am editing this post and updating the content

If you got a wifi network where you use your laptop or desktop you do not have to go through all these hassles like above.

Just download any of the following apps from google play store:

Airdroid

Xender

 

I prefer Xender to Airdroid. its a much better interface.

So now once you got your phone and laptop/desktop connected to the same wifi network all you got to do is open any of the app in your phone.

It gives you an IP as well as a url.

Type it in your favourite browser on your laptop/desktop.

It will ask you “whether you want to accept or reject the connection in your phone”

Click on accept and you are good to go….

 

NOTE: Its a direct connection and hence it would not consume your ISP(Internet Service Provider) bandwidth or ISP data which is in layman terms as unlimited download and uploads from phone to laptop and vice-versa…

so as always happy slacking folks….

how to mount usb devices in slackware

a small primer or quick steps to mount usb devices on your slackware machine or for any linux distro…

as my personal motto goes: if it works in slackware, you can bet 99.99% its good to go in any other linux or unix flavors too….

before we begin lets switch user (su) to the root user

basically 4 steps to go through:

STEP 1:first, we attach the usb device to our laptop or desktop and check dmesg status to check if the usb is detected. dmesg requires privilege user rights hence we su before we go ahead…..

# dmesg | tail //here, dmesg piped to tail so as to read the last last few lines

usb-storage 2-1.1:1.0: USB Mass Storage device detected
scsi host9: usb-storage 2-1.1:1.0
scsi 9:0:0:0: Direct-Access hp v100w 1100 PQ: 0 ANSI: 4
sd 9:0:0:0: [sdd] 31285248 512-byte logical blocks: (16.0 GB/14.9 GiB)
sd 9:0:0:0: [sdd] Write Protect is off
sd 9:0:0:0: [sdd] Mode Sense: 43 00 00 00
sd 9:0:0:0: [sdd] No Caching mode page found
sd 9:0:0:0: [sdd] Assuming drive cache: write through
sdd: sdd1
sd 9:0:0:0: [sdd] Attached SCSI removable disk

STEP 2: we create a directory in our slackware machine, usually in the /mnt path but yes again you are free to place it anywhere you like..

# mkdir /mnt/usb_device

STEP 3: mount our usb device found from step 1, to this location.
we have seen from the output of step 1 that the usb is attached at sdd
again step 2 is for time use only as when we make this directory it will be available on our machine till we decide to do away with it…you can delete mount point after usage if you want just like how you delete a file….remember everything is treated as a file in *nix (linux or unix)…or keep it for all future usb devices being mounted….if you plan to mount multiple usb’s simultaneously make different mount points for each device….

mount /dev/sdd1 /mnt/ub_device //mounting our usb device to our path created on our machine

STEP 4: now you are good to go…cd to the directory where you mounted your device and browse the contents….

STEP 5: unmount the usb devices from the location using the umount command

umount /mnt/usb_device

happy slacking folks….

execute shell command from python script using subprocess module to search for a string in the directory of your choice

elementary script to execute shell commands using your very own python language…
i post this snippet here to demonstrate the power of python and yes an intro into the beautiful language called python and why i recommend learning it….

subprocess module in python helps to execute your favorite shell commands through python scripts…
for more references do look into python docs -> https://docs.python.org/2/library/subprocess.html

diving straight into the code…..
equivalent linux command for the below script is: ls -ltrh some_directory | grep search_term


#################################
#Script to search for a term in unix shell
#equivalent linux command: ls -ltrh some_directory | grep search_term
#author:nightslacker
#################################

#import sys module for taking system arguments from command line
import sys
#import subprocess module to execute unix shell commands from python script
import subprocess
#pass first argument as your directory
directory = sys.argv[1]
#pass second argument as the search string you want
search_term = sys.argv[2]
cmnd1 = subprocess.Popen(["ls", "-ltrh", directory], stdout=subprocess.PIPE)
cmnd2 = subprocess.Popen(["grep", search_term], stdin=cmnd1.stdout, stdout=subpr
ocess.PIPE)
output = cmnd2.communicate()[0]//cmnd2.communicate() returns a tuple containing (data of stdout,data of stderr)

print "*** Running ls -ltrh command on directory", directory, " and search term
:",search_term, "***\n", output

how to execute the above script from command line interface or CLI mode?
python anyname.py /home/nightslacker/Documents pythondocs

on executing the above line, the script checks in the Documents folder for any file with pythondocs in their filename and returns the output on your shell

keep slacking folks!!! cheers!!!

how to chroot from installation media( or my installation disk) when my slackware doesnt boot

so, you get situations where you edit your /etc/lilo.conf file and fail to run /sbin/lilo…an example is upgrading the kernel or changing to a generic kernel etc….in such a case your slackware system fails to reboot correctly….and it prompts because of a failed lilo configuration….

selfless and selfish too because i need it posted to come back again cause it recurs way too often:

upgrading kernel without running lilo for me….

Relax, you are in safe quarters if you reached here…

follow the steps here to get back up and running….

quoting from
http://docs.slackware.com/howtos:slackware_admin:how_to_chroot_from_media

In order to gain access to your system without booting directly to it, it is possible to use an installation media such as Slackware CD1 or the DVD. Once the installation media loads and starts, you can change the media’s root directory into a mounted hard-disk partition and use it as the root directory, thus running commands directly from it and affecting it.

1. so the first step is to mount your root partition….if you dont know your root partition just enter fdisk -l and check for the linux partition in it….

(let me explain for a single partition….If this is not the case, and you are using LVM/EVMS or an encrypted volume you will need to prepare the volumes before you can mount and chroot into them)

2. if its /dev/sda1, type

mount /mount/sda1 /mnt

3.   next, we need to prepare three virtual directories to be used by the environment. Those are /dev, a directory with virtual files that represent hardware devices, /proc, a directory with virtual files that represent processes and /sys which contains the kernel and other system files:

mount -o bind /dev /mnt/dev

mount -o bind /proc /mnt/proc

mount -o bind /sys /mnt/sys

4. now, since the partitions are mounted now we can chroot to it

chroot /mnt /bin/bash

quoting slackdocs again…..making my life easier…..

“The bash prompt that you see here is a bash prompt started on your system. You can now work on this environment naturally. For example editing /etc/lilo.conf and executing /sbin/lilo will happen on your system, not from the installation media.”

thats all there to it….now with the help of your installation disc you can use your underlying system when it doesnt boot up…

5. when you are done using, dont forget to run lilo again….and then there is the reboot or poweroff command which you can execute as per your needs….

*i was a bit panicky when my slackware failed to start…..but slackware it always surprises you with its tools…..and the folks at LQ…they keep your worries out….

keep slacking!!!

update/upgrade slackware distro through slackpkg utility

today, i will give a post on how to keep your slackware distro up to date quickly to the latest patches (bugs, security fixes if any) released for the distro the really quick way with slackpkg utility ( default in the distro if you have installed the full installation)….

1. open up /etc/slackpkg/mirrors with your fav text editor
vi /etc/slackpkg/mirrors

2. uncomment the mirror for your distro version or if you want the bleeding edge uncomment a link for slackware-current (note, this is not the stable releases but cutting edge developer’s build…where you have to tinker with issues and fix them if any./…dont uncommnet for production environments…not recommended thoughstill stable…yes i can assure you on that cos its current thats running for me and i feel at home for now with it too)

3. once done, save changes and close the file or exit vi…

4. now, run these four commands one by one….

i. slackpkg update gpg
ii. skackpkg update
iii. slackpkg install-new
iv. slackpkg upgrade-all

5. you can do system clean up after this to ensure no orphan files are present…

well, for now you should check for files with *.new extensions in your system….they are new configuration files that are from your updates for your applications and libraries….

the new files come into existence if you have made any changes to the old configuration files of those respective libraries….in such a case, slackware lets you have keep those old files while an update gives you the new configuration files in .new format so that you can see the difference between them and apply the changes as you wish….

eg: /etc/wpa_supplicant.conf usually have changes for your wireless connection or wifi you added like your essid and password….you get a wpa_supplicant.conf.new on an update so that you can check the diff and apply them…

i recommend going through each new files to see the changes and then remove old configs….

and now you get a brand new slackware( well, basically means you up to date with your times! )

keep slacking!!!

a distro you can tweak to how you want( and most importantly you are in full control)

rooting your android phone – a primer for beginners

i know it’s been a long time since i have penned down some thoughts…

the latest post i have got for you is all related to mobile rooting (hacking into your mobile device for more power)

a brief on rooting:

Mobile phones available in the market comes with a stock android (a term referred to android that comes pre-built in our mobile devices) that’s ready to use.

But the major caveat in this is that the system files are locked and we don’t have full access to the device. It’s like a locked device to me and one that is waiting to be explored.

Rooting is used to specify the action where we grant root access (similar to the super user or administrator in linux ) to the user, so that we can access the locked android files too and add more of our own.

Why do we need rooting?

if you google there are plenty of pages with pros and cons of rooting.

Major cons :

  • rooting voids any company warranty left on your device…in simple terms, you cannot take it to an authorized service center after rooting
  • workaround: unroot the device before you take it to the service center. Do a full unroot and they cannot trace if you had rooted the phone before.
  • chance of bricking the device (in rooting world that’s also known as damaging the device due to a corrupted file or hardware part thus rendering it useless) while performing the rooting
  • Now, to the brighter side (pros of rooting):

  • Giving more power to the user
  • Customization of phone right from tweaking hardware and additional softwares to changing the UI (user-interface)
  • Remove limitations of stock android to access system files
  • Customize, customize and more customizations
  • The last line is the only line needed to confirm us to make the switch from an un-rooted device to a rooted device.

    Rooting of mobile phones has come a long way and it is way more reliable than before but yes you got to be warned beforehand as precaution:

    Any firmware or executable on one phone might not necessarily work on your phone.

    Check your phone model, android version and firmware installed to proceed.
    To root your phone, all you need to do is google your phone model, android version and also firmware version to be just super sure to know you got the right tools to proceed.

    The tutorials or step by step procedure for the rooting procedure is all that is needed to perform a successful rooting.

    I rooted my asus zenfone 5 using the below working link:

    hack(root) into my asus zenfone 5

    kindly be warned that I am not responsible for you bricking your device. Not to worry folks, I think this has a success rate of 100% as compared to others. I tried a lot of them and yes could have bricked my device too trying them out.

    What I did after rooting?

    · Used device control (an app for rooted phones available from google play store) to overclock my cpu from 1.3 ghertz to 1.6 ghertz

    · Expand your ram using your physical memory that’s external card memory if any

    · Protect your apps using greenify which monitors apps and puts them to sleep as desired.

    · Gamers, can have a rich hd feel experience playing heavy games, (games that are a load on your phone before rooting it) like N.O.V.A. 3, tegra etc

    · A host of other apps waiting to be tried out if you have rooted your phone.
    . Xposed Framework for customizations to front end,flash your custom ROM ( more like a themer right from kernel to your front end), and a whole lot of tuner apps to check into.

    my view on rooting?
    you give power to yourself and life to your phone once you root it….you can turn any low cost android mobile handset and root it…

    ofcourse you can jailbreak your iphone too….
    do it to have freedom!
    a small last note to remember:
    if you find you lose root access after OTA (over the air) update of your android, you will have to root again…..thats all…just repeat the process in the link…..

    fluxbox – sticky wonder

    i loved fluxbox when i first installed it….
    low on resources pretty neat to look at….
    here is the sticky think i found…thought to share here too…

    basically it lets any application of your wish to stay on top….

    if you right click anytime on application taskbar and check the sticky option for the application then any application say firefox for instance stays across workspaces....so that when you switch to a terminal say in another workspace you still have this firefox as a side tab along with the other existing tabs you had in it as well....
    

    no cut of flow also….its way too cool….
    thats from the front end….

    cli mode:
    there is a directory in the home directory of current user namely fluxbox hidden so its .fluxbox....browse the files in it you'd be amazed at the options available....
    well the file in concern for us is the apps file which has application window settings saved across sessions....
    open the file and add this piece of line to make sticky stick
    
    [app] (name=firefox)
    [Sticky] {yes}
    [end]
    
    

    i think for low memory footprint and decent usage fluxbox, a fork of blackbox is a nice window manager to have…..