background preloader

Software and coding

Facebook Twitter

Peter Hirschberg - My Software. Holo Everywhere. [This post is by Adam Powell, an Android Framework engineer who cares about style. —Tim Bray] Android 4.0 showcases the Holo theme family, further refined since its debut in Android 3.0. But as most developers know, a new system theme for some Android devices isn’t a new or uncommon event. For developers new system themes mean more design targets for their apps. Using system themes means developers can take advantage of a user’s existing expectations and it can save a lot of production time, but only if an app designer can reliably predict the results.

Before Android 4.0 the variance in system themes from device to device could make it difficult to design an app with a single predictable look and feel. We set out to improve this situation for the developer community in Ice Cream Sandwich and beyond. Theme.Holo If you’re not already familiar with Android’s style and theme system, you should read Styles and Themes before continuing. Compatibility Standard In Android 4.0, Holo is different. Dev : Extensions : Example Code : Calling Java from Javascript. From MozillaZine Knowledge Base This page is currently notes of what I had to do to call Java from Javascript from Thunderbird. Here's an example from a blog: var cl = new Packages.java.net.URLClassLoader( [ new Packages.java.net.URL( ' ] ); var aClass = Packages.java.lang.Class.forName("HelloWorld", true, cl); var aStaticMethod = aClass.getMethod("getGreeting", []); var greeting = aStaticMethod.invoke(null, []); alert(greeting); In order to write to the file system, I had to add this to the javascript code: java.lang.System.setSecurityManager(null); I could read a jar from the filesystem without a problem.

Calling showJavaConsole is very useful for debugging: var jvm = Components.classes["@mozilla.org/oji/jvm-mgr;1"].getService(Components.interfaces.nsIJVMManager); jvm.showJavaConsole(); Here's the code I use to log exceptions. Function logExc(e) { try { while(e ! UCDetector. Java Programming Cheatsheet. This appendix summarizes the most commonly-used Java language features in the textbook.

Here are the APIs of the most common libraries. Hello, World. Editing, compiling, and executing. Built-in data types. Declaration and assignment statements. Integers. Floating-point numbers. Booleans. Comparison operators. Printing. Parsing command-line arguments. Math library. The full java.lang.Math API. Java library calls. Type conversion. Anatomy of an if statement. If and if-else statements. Nested if-else statement. Anatomy of a while loop. Anatomy of a for loop. Loops. Break statement. Do-while loop. Switch statement. Arrays. Inline array initialization. Typical array-processing code. Two-dimensional arrays. Inline initialization. Our standard output library. The full StdOut API. Our standard input library. The full StdIn API. Our standard drawing library. The full StdDraw API. Our standard audio library. The full StdAudio API. Command line. Redirection and piping. Functions. Libraries of functions.

Our standard random library. Crash course: Embedded programming with Arduino. December 20, 2011, 8:00 AM — Demand for embedded programming is growing like crazy, so anyone looking for some job security might consider becoming an ace embedded programmer. It helps to have some programming experience, but even raw beginners can get started inexpensively and learn on their own. One of the friendliest introductions to embedded coding is Arduino.

Arduino is a popular open embedded hardware and software platform with hundreds of howtos and projects to try out. Today we review the basics of both electronics and Arduino coding in a fun holiday project, Singing Holiday Snowman. Singing snowman I'm going to take my old plastic snowman (figure 1) and outfit him to sing holiday songs whenever anyone approaches within a few feet, and to blink some festive red and green LEDs. SolderingReading simple schematicsLoading and modifying Arduino programs Figure 1: Plastic snowman before his operation, mute and unlit Source: Carla Schroder Prerequisites Here is a handy hardware list. The Underhanded C Contest. Code.nasa.gov. 8 Free Sites to Learn Java Online. Java is a general-purpose, concurrent, class-based, object-oriented language that is specifically designed to have as few implementation dependencies as possible.

It is intended to let application developers “write once, run anywhere.” Java is currently one of the most popular programming languages in use, particularly for client-server web applications. And knowing Java can be a lucrative skill to possess in the current computer-and-Internet-focused marketplace. 1. Java2s.com provides with a wide variety of Java examples, organized by topics. 2. 3. 4. 5. 6. 7. 8. 30 free programming eBooks - citizen428.blog() Since this post got quite popular I decided to incorporate some of the excellent suggestions posted in the comments, so this list now has more than 50 books in it. BTW: I’m not very strict on the definition of “ebook”, some of them are really just HTML versions of books.

[UPDATED: 2012-01-18] Learning a new programming language always is fun and there are many great books legally available for free online. Here’s a selection of 30 of them: Lisp/Scheme:Common Lisp: A Gentle Introduction to Symbolic ComputationHow to Design ProgramsInterpreting Lisp (PDF, suggested by Gary Knott)Let Over LambdaOn LispPractical Common LispProgramming in Emacs LispProgramming Languages. Ruby:The Bastards Book of Ruby (suggested by Dan Nguyen)Clever Algorithms (suggested by Tales Arvelos)Data Structures and Algorithms with Object-Oriented Design Patterns in RubyLearn Ruby the Hard WayLearn to ProgramMacRuby: The Definitive GuideMr. Erlang:Concurrent Programming in ErlangLearn You Some Erlang for Great Good. Algorithm simplifies biological imaging and Sudoku puzzles. Veit Elser A Sudoku puzzle designed by Elser's difference map algorithm. The challenge is to fill in the missing cells of the table with letters A-Y so that there are no duplicates in any row, column or five-by-five block (outlined in red).

The correctness of the solution should be immediately obvious to any Cornellian, as it will spell out the name of one of the university's founders. Solutions can be sent to Veit Elser, 524 Clark Hall, or ve10@cornell.edu. Chronicle Online will publish the solution later this month. Cornell physicist Veit Elser has been engrossed recently in resolving a pivotal question in biological imaging. But in discovering an algorithm critical for X-ray diffraction microscopy, Elser and colleagues solved two problems. Not just one puzzle. The Sudoku discovery appeals to Elser's whimsical side.

In X-ray diffraction microscopy, the constraints are more complex. The tricky part comes in using the diffraction pattern to reconstruct an image of the specimen. Why every Java field should have been final by default. « Javarizon. Introduction Note to clarify the post: by default I mean having to write something like ‘var’ to have the current behavior (fields can be reassigned), so that if you write nothing the field is automatically final. You still have the choice about being able to reassign or not by using some kind of keyword like ‘var’. I hope it is clearer now ! We all like freedom, but what is freedom when we talk about code ? You have a lot of freedom with mutable fields, too much, why not let the compiler help you by telling it that your data is immutable ?

Is it because you want more possibilities to write code that does not do what you want ? You sure do not want to, and please do not tell me the final keywords make your code hard to read, it does the exact opposite: it tells the compiler and the reader that your data will never change and this is important information. (Note: this post is NOT about the ‘other’ final keyword, the one used on classes and methods. When not to use final ? Conclusion Links: J2J development tool. J2J - Java to JavaScript integration ver. 1.5 What is this for ? It is a development tool lets you integrate Java classes and JavaScript within your HTML pages.

The main idea behind this product is how to call methods of Java classes right from JavaScript functions. Let us start from the some example. 1. <html> Our form:<br> <form> <input type="text" name="textField"><br> <input type="button" value="Click" onClick="updateField();"> </form> <script> function updateField() { document.forms[0].textField.value=java.dbConnection.getData('some_SQL_expr'); } </script> </html> So when user clicks on the button we can call method getData from the class dbConnection and use results in our JavaScript application. Suppose you are going to use browser's DOM and need to update some part of your page. <html> <p> current paragraph text </p> <script> function changeParagraph() { pp=document.all.tags("p"); pp(0).innerText=java.myClass.myFunc('give me new text, please'); } </script> </html> you can use: 1.

Java programming test, hands-on skills - BetterProgrammer.com. Learn Java by Examples - How do I create Hibernate's SessionFactory? When creating an application the use Hibernate to manage our application persistence object we’ll need a SessionFactory. This factory creates or open a session to talk to a database. To create a SessionFactory we can define the configuration in hibernate.properties, hibernate.cfg.xml or create it programatically.

In this example we’ll use the hibernate.cfg.xml configuration file, which is mostly use when creating Hibernate application. Below is our session configuration files. <? Now we have the configuration file done, let’s create a helper class that will configure and build the SessionFactory object. Package org.kodejava.example.hibernate.app; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class SessionFactoryHelper { private static final SessionFactory sessionFactory; static { try { // // Build a SessionFactory object from session-factory configuration // defined in the hibernate.cfg.xml file. About Wayan Saryada. Java Programming Cheatsheet. Wicked Cool Java. Canadian Mind Products Java & Internet Glossary. Seven Habits of Highly Effective Programmers | Technicat. As a software engineer, you might want any number of things out of your job - a steady paycheck, the opportunity to work on interesting projects, a springboard to the next better job, or maybe you just like hanging out with other programmers.

But by "effective", I mean the ability to complete projects in a timely manner with the expected quality. After working on dozens of software releases, I believe the following practices will bring you there, and while they may involve sticking your neck out, I'd like to think they will also advance your professional reputation, career longevity, and personal satisfaction. Understand Your Requirements The first step in becoming an effective programmer is to ensure that you are spending your time wisely. And there is no greater waste of time than in working on something that is not useful or never shipped. Build Early Get a demonstrable system working as early as possible.

This is not to say that design is unnecessary. Deliver Often Keep It Real. Poor, poor child. You have no idea. | Bryan Woods. It's harder than you think. Right now you're probably underestimating the amount of frustration and discomfort you're about to experience, without realizing that by doing so you're creating all sorts of subtle barriers to obtaining a deep understanding of programming. The problem is that while you've uncovered a wonderful world that makes coding seem so approachable and fun, you're unknowingly making a giant leap by thinking it's somehow also easy. This might not seem like a big deal, but it's huge.

Every single time (and this will happen constantly) you come across a concept that seems foreign or difficult or even just unintuitive, instead of thinking "It's OK. Programming is hard. " you're going to be thinking "This is supposed to be easy. What's wrong with me? Programming is not always intuitive, it's inherently complex, and it's challenging. Your first programming language provides you with a base vocabulary through which you begin to understand all other computer programs.

Libraries API - Developer's Guide - Google Libraries API - Google Code. Programming questions? Ask a programmer and get answers ASAP. Rosetta Code. Inc. Closure Templates - Google Code. Learn to code, get a job. Young programmers work at an IT company in Romania, where thousands of college graduates enter the tech field yearly. Douglas Rushkoff: Americans should be learning computer code the way we learn mathLearning to code teaches us what programs do, how they're used on us, he says A free Web-based interactive tutorial makes it possibleRushkoff: Programmers in demand; employers hire code-savvy workers from abroad Editor's note: Douglas Rushkoff, who writes regularly for CNN.com, is a media theorist and the author of "Program or Be Programmed: Ten Commands for a Digital Age" and "Life Inc: How Corporatism Conquered the World and How We Can Take it Back.

" (CNN) -- This week, New York's Mayor Michael Bloomberg tweeted his intent to learn computer code by the end of the year. He joined about 300,000 other people who have signed up at CodeYear to receive free interactive programming lessons each week from the Codecademy, a web-based tutorial. I am greatly relieved. Douglas Rushkoff. Advancing a Programming Career. Learn to code.