A tip my superior posted in group
Use text-transform: uppercase;
Thursday, January 29, 2015
Reminder of laravel variables
Just a reminder from my boss just now
Do not use
<?php echo Config::get('project.name'); ?>
instead use
{{Config::get('project.name') }}
Do not use
<?php echo Config::get('project.name'); ?>
instead use
{{Config::get('project.name') }}
Styling pagination for laravel
Laravel pagination is done pretty much automatically for you behind the scenes by calling ->paginate(x)
from your controller and return it to the view.
Aside from that simply go to your view and create a php block with the line $var->links();
Working behind the scenes is cool, but what if you want to style it to fit your liking or even to fit the design of your page.
After some searching I found a solution that works quite elegantly, I'll credit the source from below. The purpose of this blog entry is simply for my future reference.
Firstly, notice there is a file called
Credits to:
from your controller and return it to the view.
Aside from that simply go to your view and create a php block with the line $var->links();
Working behind the scenes is cool, but what if you want to style it to fit your liking or even to fit the design of your page.
After some searching I found a solution that works quite elegantly, I'll credit the source from below. The purpose of this blog entry is simply for my future reference.
Firstly, notice there is a file called
app/config/view.php
with a 'pagination' key and a value.
Change it to
'pagination' => 'file/path'.
Then, create app/views/file/path.blade.php and paste the following.
From there, freely modify the style name et cetera.Credits to:
Wednesday, January 28, 2015
CALayer alpha
I come across this problem today where I am supposed to change the opacity of an image (It is actually an UIImage)
The problem is that there is no alpha or opacity property for UIImage, if I want to mess with the opacity of the image, I would have to add it to a UIImageView and change the opacity level of the UIImageView.
And then I realized that, the image is sitting on top of a CALayer, and after checking the documentation, I noticed that CALayer has an opacity property (Note: NOT alpha).
So to change the opacity of my CALayer,
layer.opacity = (float);
The problem is that there is no alpha or opacity property for UIImage, if I want to mess with the opacity of the image, I would have to add it to a UIImageView and change the opacity level of the UIImageView.
And then I realized that, the image is sitting on top of a CALayer, and after checking the documentation, I noticed that CALayer has an opacity property (Note: NOT alpha).
So to change the opacity of my CALayer,
layer.opacity = (float);
Laravel route auth
Just a reminder from today morning
Do it using filter.php instead of
if(!(isset(Auth::user()->id)) {
return Redirect::route('users.log')
->with('alert.danger', 'Please login first');
}
Do it using filter.php instead of
if(!(isset(Auth::user()->id)) {
return Redirect::route('users.log')
->with('alert.danger', 'Please login first');
}
Monday, January 26, 2015
Regarding special characters
Avoid using special characters when doing HTML, use HTML entities instead.
Example: ©
Note that they are case sensitive.
Example: ©
Note that they are case sensitive.
Navbar transparency bootstrap
Took me two hours to find this =w=. Just putting it here for future reference.
.navbar {
background-color: transparent;
background: transparent;
border-width: 0;
}
.navbar {
background-color: transparent;
background: transparent;
border-width: 0;
}
Friday, January 23, 2015
Vertical alignment in bootstrap
Since bootstrap itself doesn't have a vertical alignment feature (At least I haven't find any good results after some search), I came into a forum that posted this CSS that solved my problem.
position: absolute;
top: 50%;
left:50%;
transform: translate(-50%,-50%);
Thursday, January 22, 2015
Changing permission
This is just a simple thing but I noticed that I checked the net too many times for this particular terminal command, better note it down instead.
To change permission settings through terminal do:
To change permission settings through terminal do:
chmod -R <permissionsettings> <dirname>
Note the capital R
P/S: make sure that permissionsettings in server side is 755
Tuesday, January 20, 2015
Laravel error with save()
Ok so I spent loads of time with this problem today which it is actually just a small problem(and it is a problem from my side)
I have trouble with $var->save(), with the error code 500.
And the biggest problem is that, using a RAW query is fine =.=
After going to start->global.php and turning on the error logging, apparently it is because I didn't create a created_by column when I create this new table. (Confirmed by checking BaseModel)
The purpose of this blog is mainly to tell myself that I can turn on error logging by visiting start->global.php
I have trouble with $var->save(), with the error code 500.
And the biggest problem is that, using a RAW query is fine =.=
After going to start->global.php and turning on the error logging, apparently it is because I didn't create a created_by column when I create this new table. (Confirmed by checking BaseModel)
The purpose of this blog is mainly to tell myself that I can turn on error logging by visiting start->global.php
Monday, January 19, 2015
Some notes about LESS
Just to note what I did on last Friday.
This is definitely my first time messing with bootstrap.
> means subset.
& means append
This is definitely my first time messing with bootstrap.
> means subset.
& means append
Thursday, January 15, 2015
CVS to SQL (Part 2 of yesterday)
This is pretty awkward
As it turns out, my task yesterday wasn't complete.
The reason is this. The data I pulled has 2 kinds of delimiter, 1 for column_name(in this case, comma) and a second delimiter for values(in my case, bar-|)
So at the end what I imported to my db is
id code name
1 AB value1|value2|value3
2 CD value4|value5|value6
Which is obviously not what I want.
Just in case I myself forget what I am looking for in the future, I am hoping that the name column gets broken down, and get the following
id code name
1 AB value1
2 AB value2
3 AB value3
4 CD value4
Hence, what I ended up doing is break this table to 2 separate tables manually. A code table and a name table. P/S: Similar to countries vs states
So the approach here is to create a dummy route, link to that function, and create the function just for the sake of writing this to the database (make sure to remove this route and function afterwards.
Due to NDA, I decided to name the variables foo for table1, bar for table2 and foo_bar for the combined table that I imported initially.
public function getFoo(){
$jsonResponse = new JsonResponse();
$response = '';
$barName = Bar::getFooByBar();
for($i = 0; $i < count($barName); $i++){
$fooArray = explode('|', $barName[$i]->foo);
foreach ($FooArray as $FooName) {
if($FooName != ''){
$foo_database = new Foo();
DB::table('foo')->insert(
array('bar_id' => $i+1, 'name' => $fooName)
);
}
}
}
$jsonResponse->setResponse($fooArray);
return $jsonResponse
->get();
}
The idea here is to get everything($barName), loop it and tokenize the index with Bar-| and write it to the database.
Don't mind the setResponse($fooArray), I simply use that for debugging process, not wise, but just for convenience since this function is to be removed immediately after I wrote everything to database.
Oh oh! And I just experimented something neat today. After importing foo_bar, since it is only foo that has everything concatenated, I ended up cloning foo_bar,(let's call it foo_bar2 here) then drop foo from foo_bar2, and add a primary key(id), set it to auto increment, it will intelligently assign the ID to existing rows in foo_bar2. Which is neat cause this means that I immediately have 1 table done :)
As it turns out, my task yesterday wasn't complete.
The reason is this. The data I pulled has 2 kinds of delimiter, 1 for column_name(in this case, comma) and a second delimiter for values(in my case, bar-|)
So at the end what I imported to my db is
id code name
1 AB value1|value2|value3
2 CD value4|value5|value6
Which is obviously not what I want.
Just in case I myself forget what I am looking for in the future, I am hoping that the name column gets broken down, and get the following
id code name
1 AB value1
2 AB value2
3 AB value3
4 CD value4
Hence, what I ended up doing is break this table to 2 separate tables manually. A code table and a name table. P/S: Similar to countries vs states
So the approach here is to create a dummy route, link to that function, and create the function just for the sake of writing this to the database (make sure to remove this route and function afterwards.
Due to NDA, I decided to name the variables foo for table1, bar for table2 and foo_bar for the combined table that I imported initially.
public function getFoo(){
$jsonResponse = new JsonResponse();
$response = '';
$barName = Bar::getFooByBar();
for($i = 0; $i < count($barName); $i++){
$fooArray = explode('|', $barName[$i]->foo);
foreach ($FooArray as $FooName) {
if($FooName != ''){
$foo_database = new Foo();
DB::table('foo')->insert(
array('bar_id' => $i+1, 'name' => $fooName)
);
}
}
}
$jsonResponse->setResponse($fooArray);
return $jsonResponse
->get();
}
The idea here is to get everything($barName), loop it and tokenize the index with Bar-| and write it to the database.
Don't mind the setResponse($fooArray), I simply use that for debugging process, not wise, but just for convenience since this function is to be removed immediately after I wrote everything to database.
Oh oh! And I just experimented something neat today. After importing foo_bar, since it is only foo that has everything concatenated, I ended up cloning foo_bar,(let's call it foo_bar2 here) then drop foo from foo_bar2, and add a primary key(id), set it to auto increment, it will intelligently assign the ID to existing rows in foo_bar2. Which is neat cause this means that I immediately have 1 table done :)
Wednesday, January 14, 2015
JSON to cvs
Today I received a task which is to pull state and area into a cvs file to be used for our database down the road.
My senior taught me a few ways to look for where are the data so I know where to retrieve.
If it is from the server side, during inspect element the console will have logged out the actions.
if it is hard-coded in the HTML in the dropdown selection etc, I should see the data by inspecting the element of the form.
And finally, which is what happened today. The data is in the javascript. Firstly I hit view source so I can view the entire HTML file. From there I search for .js and look for the js file that is triggered to load the information.
I then copied the JSON and went to http://www.convertcsv.com/ to convert the JSON to CSV.
Also, my senior taught me that I should always visit jsonlint.com to validate JSON before attempting to do anything with it.
Credits to my senior.
My senior taught me a few ways to look for where are the data so I know where to retrieve.
If it is from the server side, during inspect element the console will have logged out the actions.
if it is hard-coded in the HTML in the dropdown selection etc, I should see the data by inspecting the element of the form.
And finally, which is what happened today. The data is in the javascript. Firstly I hit view source so I can view the entire HTML file. From there I search for .js and look for the js file that is triggered to load the information.
I then copied the JSON and went to http://www.convertcsv.com/ to convert the JSON to CSV.
Also, my senior taught me that I should always visit jsonlint.com to validate JSON before attempting to do anything with it.
Credits to my senior.
Subscribe to:
Posts (Atom)