A blog for PHP, YII Framework,Javascript , MySQL, Linux related stuff
Tuesday, December 4, 2018
How to change page title archive page in Wordpress
1.) Install Yoast SEO Plugin
2. ) Go to /wp-admin/admin.php?page=wpseo_titles
3. ) Click Post-Types
4. ) Scroll down and find the custom post type that you want to change the URL and click it.
5. ) After the panel scrolls down abit look for the settings for the archive page .
6. ) Change the SEO-Title field and Save
7.) Done
Sunday, September 18, 2016
Yii2 : Quoting table and column names
To avoid column quoting when creating a query string ,
use [[columnName]]
for columns
and
{{table_name}}
for tables
for example
$result = \Yii::$app->db
->createCommand("SELECT COUNT([[id]]) FROM {{tbl_user_accounts}}")
->queryScalar();
Thursday, August 25, 2016
Yii2 GridPageSize
Tuesday, August 23, 2016
Functional Testing vs Acceptance Testing
Notes for me by me:
Its safe to say that
Functional testing = headless acceptance test , the gist here is to test quickly .
Acceptance Test = involves multiple real web browser.
Friday, July 1, 2016
How to view connected devices on my own pldtmydsl router/wifi
How to view connected devices on my own pldtmydsl router/wifi
You can view list of connected devices on your pldt wifi router by going to
http://192.168.1.1/wlstatbl.htm
Step #1 . Open your web browser and browse http://192.168.1.1/wlstatbl.htm
Step #2 . Login your credentials.
Done : You can now view devices that are connected to your router. EZ
Friday, April 17, 2015
How to remap hjkl in sublime text 2 vintage mode
First go to
Preference >> Browse Package
It would open up your package folder
open
Default.sublime-keymap
Open that and use your analytical skills ....
Im now using
j = left
k = down
l = right
i = up
using these confirguration ... and ohh.... If you want to go back to insert mode ... use " a"
Sunday, February 1, 2015
how to upload csv file to server via ajax in javascript
how to upload csv file to server via ajax in javascript
dropContainer.addEventListener('drop',function(evt){
evt.stopPropagation();//stop event bubble
evt.preventDefault(); // stop event bubble
//iterate through the files
Array.prototype.forEach.call(evt.dataTransfer.files, function (currentData) {
//currentData - File - current file object of evt.dataTransfer.files
filereader = new FileReader; // create a file reader
//define when load ends listener
filereader.onloadend = function(){
contenArea.innerHTML += filereader.result;
}
filereader.readAsText(currentData);//start reading the file
//===== IF you want to send the form data to server ===
// create a form data , you can retrieve the file in PHP via $_FILES['uploadedFile']
var tempFormData = new FormData;
tempFormData.append("uploadedFile", currentData);
// prepare ajax content and sendfile
xhr = new XMLHttpRequest();
//gets called everytime there is a state change
xhr.onreadystatechange = function () {
if (xhr.status === 4) {
console.log("done uploading");
}
};
// configure the xhr
xhr.open("POST", "http://localhost:8000");
// send the form data
xhr.send(tempFormData);
});
});
evt.dataTransfer.files are NOT ARRAYS
Today I have learned that evt.dataTransfer.files are not Arrays , they are Objects
And to iterate through them you must call
Array.prototype.forEach
So I was doing my homework today and to my suprise , I got an error iterating over evt.dataTransfer.files . Like what in the world is going on . Turns out , its not an array its an Object . TO iterate through them you must use Array.prototype.forEach.call . Good thing Ive watched the
TutsPlus - JavaScript Fundamentals 101 . A life saver ,.
dropContainer.addEventListener('drop',function(evt){
evt.stopPropagation();
evt.preventDefault();
Array.prototype.forEach.call(evt.dataTransfer.files, function (currentData) {
alert(currentData.name);
});
filereader = new FileReader;
filereader.onload = function(){
}
//read the files
// prepare ajax content
});
And to iterate through them you must call
Array.prototype.forEach
So I was doing my homework today and to my suprise , I got an error iterating over evt.dataTransfer.files . Like what in the world is going on . Turns out , its not an array its an Object . TO iterate through them you must use Array.prototype.forEach.call . Good thing Ive watched the
TutsPlus - JavaScript Fundamentals 101 . A life saver ,.
dropContainer.addEventListener('drop',function(evt){
evt.stopPropagation();
evt.preventDefault();
Array.prototype.forEach.call(evt.dataTransfer.files, function (currentData) {
alert(currentData.name);
});
filereader = new FileReader;
filereader.onload = function(){
}
//read the files
// prepare ajax content
});
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
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)
Subscribe to:
Posts (Atom)
