Thursday, January 22, 2015

Understanding Git Rebas

The Base Way to understand git rebase




Follow the link and you will see the light


http://rypress.com/tutorials/git/rebasing

Wednesday, January 21, 2015

Some javascript stuff that existed in javasciprt



Today I learned again another trick using javascript

Problem : check if the string passed the regex , if yes execute the function

you can solve it these way

these will return false
/d/.test("kevin") && (function(){console.log('aw')})()

if you want it to execute
/kevin/g.test("kevin") && (function(){console.log('aw')})()


Tuesday, January 20, 2015

Fix : Netbeans 8 create test problem



If you encounter these error.
The referenced parameter '--ansi' is not registered.

When creating a test . Theres a good chance that you are using an old phpunit-skel generator
so to solve the problem .

Follow the my instruction on how I solve the error.


First download these file . these is the updated skel generator


1. ) https://phar.phpunit.de/phpunit-skelgen.phar




1.1 ) locate the download phar file


1.2 ) usually it is located at downloads folder , atleast in my case . copy that file.


1.3) Locate your skelgen files . in my case it is located at C:\wamp\bin\pear . Paste the copied file in these folder.



2. ) These is what our files should look like .


3. ) Edit the batch file.
4. ) Finally add the .phar extension

5.)  Close the file and save the changes . You can now generate test file from an existing php file.

Sunday, January 18, 2015

things i've learned from javascript the good parts




the bad parts
========================================
type of null is Object
xD ... FWT


use triple equal operator
dont use double equal operator

check if empty or not

somevalues = someArr[x]

if(somevalues === undefined){
alert('wee');
}


0.1 + 0.2 !== 0.3
dont blame javascript here
its a problem with IEEE floating point



JSLint = code quallity checker

==============================

The good parts
lambda

Dynamic objects

Loose Typing

Object Literals


dont use the 'new'

return
{
ok:true
};
doest work , dunno have they fixed these?









Thursday, January 15, 2015

Javascript lessons I've learned


function IWillCallYou(){
alert(arguments[0]);
alert("there are : "+arguments.length+" arguments passed");
}

function IWillCallYou(){
alert("Who dares to call "+arguments.callee);
}



the use of self invoking function  ,
to impose variable issolation ,
awesome!

var dt = (function(){
var myclass = {
someMethod:function(){

}
}
return myclass;
})();
console.log(dt);





javascript array methods
 every = if one is false , all is gone to oblivion , it is false , everything should be true to return true
 some = its okay to make mistakes , even if one is false , besides we only need one statemetn to be true
 filter = define a method that will run and to check which one I should return , using your defintion of how I filter the data . I will run in every data inside these damn array and if I return true then the current value passed , if I dont return true then the current data will be disregarded . now the filtering is done . I will now collect all data passed using your defined way of filter and return it . the unfortunate data (those who failed to pass) , well they dont make it.
 forEach = hey just do your thing in every data inside the  array




 creating custom objects

 when creating class in javascript
 create use prototype
 to define a method

 Person.prototype.isItEfficient(){
  return true;
 }



Method leasing  , yes you heard me method leasing ..
can I use your method for a while .
besides we have the same properties that that method use

for example

var shitMan = {
hasAButtHole:true,
takeADump:function(){
if (this.hasAButtHole) {
console.log(arguments)
console.log("dumping huge shit!");
}
}
}
var cantShitButHasButtHole = {
hasAButtHole:true,
}

the magic code

shitMan.takeADump.apply(cantShitButHasButtHole);
and they live happily ever after ..


side question , what if
I want to pass argument to that freakin method ?
well you can use
arguments
arguments[0] = first argument passed


If you are a hipster and dont want to use that apply
you can use call method
shitMan.takeADump.call(cantShitButHasButtHole,["sexy arguments"]); // yup , it is almost the same to apply




Dont get fooled
arguments is not array , its an object trust me .
heres the magic code to test it

function avadaKadabra(){
console.log(  {}.toString.apply(arguments)  )

}
avadaKadabra()


so how do I treat it like its an array .
well glad you ask . you can do it like these





//TypeError: Function.prototype.apply: Arguments list has wrong type
function avadaKadabra(){
console.log(  [].join.apply(arguments,"|")  )
}
avadaKadabra("one","two")


// no error at all .
function avadaKadabra(){
console.log(  [].join.call(arguments,"|")  )
}
avadaKadabra("one","two")



want to know the difference ,
the answer is the second parameter type .
using apply , the second parameter should be an array


while using call ,
you can pass infinite arguments

to fix the error



//TypeError: Function.prototype.apply: Arguments list has wrong type
function avadaKadabra(){
console.log(  [].join.apply(arguments,["|"])  )
}
avadaKadabra("one","two")

now , whats the difference between apply and call





function something(){
if (arguments instanceOf Object) {};

popedData = Array.prototype.pop.apply(arguments);
console.log("THe poped data is : "+popedData);
console.log(arguments);
}

something(1,2,3,4,5)