As someone who creates designs for the Internet, one of the most challenging job is to create design elements aligned. In that case MeasureIt comes in handy and allows you to overlay a ruler on a browser page so you can verify width, height and alignment of page elements. With this beautiful extension you can measure distances between any two points on the page.
Permanent link to this article: https://blog.openshell.in/2010/11/measureit/
Nov 30
ColorZilla
ColorZilla add-on features an online eyedropper, which makes it quite simple to get the exact value of a specific color. With ColorZilla you can get a color reading from any point in your browser, quickly adjust this color and paste it into another program. In addition to color picker, ColorZilla offers a DOM color analyzer which allows you to locate elements on the page that correspond to a given color and find out the CSS rules that specify a certain color. ColorZilla also features a online palette viewer that allows choosing colors from pre-defined color sets and saving the most used colors in custom palettes.
Permanent link to this article: https://blog.openshell.in/2010/11/colorzilla/
Nov 30
Firebug
Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page. Firebug gives you full control over the CSS, HTML and JavaScript of any page that you choose. Inspect and edit HTML, Tweak CSS to perfection, Visualize CSS metrics, Monitor network activity, Debug and profile JavaScript, Quickly find errors, Explore the DOM, Execute JavaScript on the fly, Logging for JavaScript. Best of all, every change that you make is done live and instantly, so you can quickly test out different changes and see the results of those changes instantly.
Permanent link to this article: https://blog.openshell.in/2010/11/firebug/
Nov 29
Make 3D buttons view in CSS
3D CSS buttons are easy to create. The trick is to give your elements borders with different colors. Lighter where the light source shines and darker where it doesn’t.
div#button {background: #888; border: 1px solid; border-color: #999 #777 #777 #999 }
The CSS above will create a button with the light source at the upper left. Usually one or two shades of color change is all that’s needed, but you can experiment for different effects.
Permanent link to this article: https://blog.openshell.in/2010/11/make-3d-button-view/
Nov 29
Accessing parent documents in Flex
It will achieved by Application and Doccument object
Application object has the following characteristics:
* Application objects are MXML files with an <mx:Application> tag.
* Most Flex applications have a single Application object.
* The Application file is the first file loaded.
* An Application object is also a Document object.
* You can refer to the Application object as mx.core.Application.application from anywhere in the Flex application.
* If you load multiple nested applications by using the SWFLoader control, you can access the scope of each higher application by parentApplication.parentApplication, and so on.
Document object has the following characteristics:
* All MXML files that a Flex application uses are Document objects, including the Application object’s file.
* Custom ActionScript component files are Document objects.
* The Flex compiler cannot compile a SWF file from a file that does not contain an <mx:Application> tag.
* Documents usually consist of MXML custom controls that you use in your Flex application.
* You can access the scope of a document’s parent document by using parentDocument, parentDocument.parentDocument, and so on.
* Flex provides a UIComponent.isDocument property so that you can detect if any given object is a Document object.
Accessing Document and Application object scopes
mx.core.Application.application The top-level Application object, regardless of where in the document tree your object executes.
mx.core.UIComponent.parentDocument The parent document of the current document. You can use parentDocument.parentDocument to walk up the tree of multiple documents.
mx.core.UIComponent.parentApplication The Application object in which the current object exist
EXAMPLE:
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”
xmlns:MyComps=”myComponents.*”
>
<mx:Script>
<![CDATA[
public function getSalutation():String {
return “Hi, ” + mylbl.text;
}
]]>
</mx:Script>
<mx:Label id=”mylbl” text=”Guys”/>
<!– Include the ButtonGetSalutation.mxml component. –>
<MyComps:ButtonGetSalutation/>
</mx:Application>
To access the mylbl(Label control) and call the getSalutation() method in your MXML components, you can use the application property, as the following example from the MyComponent.mxml component shows:
<?xml version=”1.0″?>
<!– containersapplicationmyComponentsButtonGetSalutation.mxml –>
<mx:VBox xmlns:mx=”http://www.adobe.com/2006/mxml” width=”100%” height=”100%”>
<mx:Script>
<![CDATA[
/* To refer to the members of the Application class,
you must import mx.core.Application. */
import mx.core.Application;
]]>
</mx:Script>
<mx:Label id=”myL”/>
<mx:Button label=”Click Me” click=”myL.text=Application.application.getSalutation();”/>
</mx:VBox>
Similarly use parentDocument.parentDocument.doSomething() for Document object.
Permanent link to this article: https://blog.openshell.in/2010/11/accessing-parent-documents-in-flex/
Nov 29
SAP BI
What is SAP BI?
SAP BusinessObjects business intelligence (BI) solutions can empower your users to make effective, informed decisions based on solid data and analysis. All users, from the high-end analyst to the casual business user, can leverage business intelligence solutions to access to the information they need – with minimal dependence on IT resources and developers.
Permanent link to this article: https://blog.openshell.in/2010/11/sap-bi/
Nov 28
Make use of toString() in Java
Every Java beginners must know about toString() method of java.lang.Object class. As you know java.lang.Object is the super most class in Java. Every pre-defined and user-defined class can override the methods available in the class java.lang.Object.
Of these, toString() method plays a vital role. See the following example:
int x = 100;
System.out.println(x);
This will print 100. Discuss the below example too:
class Student{
private String name;
public Student(String studentName){ name=studentName; }
private void setName(String name){ this.name=name; }
private String getName(){ return name; }
}
class ABC{
public static void main(String [] a){
Student s=new Student("Guru");
System.out.println(s);
}
}
Can you guess the output of the above program? Dirtily, it prints the object reference, not some meaningful information (such as student name, in this example). Now see this example:
class Student{
private String name;
public Student(String studentName){ name=studentName; }
private void setName(String name){ this.name=name; }
private String getName(){ return name; }
/** method overridden **/
public String toString(){ return name; }
}
class ABC{
public static void main(String [] a){
Student s=new Student("Guru");
System.out.println(s);
}
}
This prints Guru. So, overriding toString() method improves your object quality and very very helpful when you directly pass or print object.
Permanent link to this article: https://blog.openshell.in/2010/11/make-use-of-tostring-in-java/
Nov 28
Ruby Symbols Description
Matter related to the old and new Ruby programmer, and Ruby’s symbols are confusing sometimes or always. Smoothly before this, can not get used is pretty. People learn about the Ruby language is often Rubionreiruzu learn from the project. The Rubionreiruzu symbol is everywhere. There really is everywhere. So, pay attention to the concept of a symbol of ruby, it’s important to remember that.
Ruby is an instance of a symbol of class symbol. Put before the identifier symbol following the colon, “: name”, “: id” or “: user”. Ruby Symbol class includes a method of a class.
- all_symbols – Returns an array of all the symbols currently in Ruby’s symbol table.
- id2name – Returns the name or string corresponding to sym:, name.id2name the “name” back.
- inspect – Literally back to the symbol.
- to_i – Return a unique integer to each symbol. This method never raises an exception.
- to_s – id2name as same. Returns the string.
- to_sym – Returns the symbol corresponding to string.
Permanent link to this article: https://blog.openshell.in/2010/11/ruby-symbols-description/
Nov 28
Debugging Rails
You can always debug your application and get it back on the rails if ever it something goes wrong. You have to check the application log files. See to it that “tail –f” commands are running on the server.log and development.log. Rails will then show debugging and runtime information to these files and debugging information will also be displayed in the browser on requests from 127.0.0.1.
Using the Ruby logger class from inside your controllers, you can also log your own messages directly into the log file from your code like:
class ReportController < ActionController::Base
def destroy
@report = Report.find(params[:id])
@report.destroy
#Debug Log file
logger.info(“#{Time.now} Destroyed Report ID ##{@report.id}!”)
end
end
These are the available log levels, :debug, :info, :warn, :error, and :fatal, corresponding to the log level numbers from 0 up to 4 respectively.
Description:
logger.debug
The DEBUG level designates fine-grained informational events that are most useful to debug an application.
logger.info
The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.
logger.warn
The WARN level designates potentially harmful situations.
logger.error
The ERROR level designates error events that might still allow the application to continue running.
logger.fatal
The FATAL level designates very severe error events that would presumably lead the application to abort.
To write in the current log use the logger.(debug|info|warn|error|fatal) method from within a controller, model or mailer.
The default Rails log level is info in production mode and debug in development and test mode.
Permanent link to this article: https://blog.openshell.in/2010/11/debugging-rails/
Nov 28
Finders are great but be careful
Finders are very pleasant to use, enable you to write readable code and they don’t require in-depth SQL knowledge. But the nice high level abstraction come with a computational cost.
Follow these rules of thumb:
- Retrieve only the information that you need. A lot of execution time can be wasted by running selects for data that is not really needed. When using the various finders make sure to provide the right options to select only the fields required (:select), and if you only need a numbered subset of records from the resultset, opportunely specify a limit (with the :limit and :offset options).
- Don’t kill your database with too many queries, use eager loading of associations through the include option:
Avoid dynamic finders like MyModel.find_by_*. While using something like User.find_by_username is very readable and easy, it also can cost you a lot. In fact, ActiveRecord dynamically generates these methods within method_missing and this can be quite slow. In fact, once the method is defined and invoked, the mapping with the model attribute (username in our example) is ultimately achieved through a select query which is built before being sent to the database. Using MyModel.find_by_sql directly, or even MyModel.find, is much more efficient.- Be sure to use MyModel.find_by_sql whenever you need to run an optimized SQL query. Needless to say, even if the final SQL statement ends up being the same, find_by_sql is more efficient than the equivalent find (no need to build the actual SQL string from the various option passed to the method). If you are building a plugin that needs to be cross-platform though, verify that the SQL queries will run on all Rails supported databases, or just use find instead. In general, using find is more readable and leads to better maintainable code, so before starting to fill your application with find_by_sql, do some profiling and individuate slow queries which may need to be customized and optimized manually.
Permanent link to this article: https://blog.openshell.in/2010/11/finders-are-great-but-be-careful/