background preloader

Jmtobar

Facebook Twitter

José Miguel Tobar

Tricks with Direct Memory Access in Java « Highly Scalable Blog. Java was initially designed as a safe, managed environment. Nevertheless, Java HotSpot VM contains a “backdoor” that provides a number of low-level operations to manipulate memory and threads directly. This backdoor – sun.misc.Unsafe – is widely used by JDK itself in the packages like java.nio or java.util.concurrent. It is hard to imagine a Java developer who uses this backdoor in any regular development because this API is extremely dangerous, non portable, and volatile. Nevertheless, Unsafe provides an easy way to look into HotSpot JVM internals and do some tricks. Sometimes it is simply funny, sometimes it can be used to study VM internals without C++ code debugging, sometimes it can be leveraged for profiling and development tools. Obtaining Unsafe The sun.misc.Unsafe class is so unsafe that JDK developers added special checks to restrict access to it.

Fortunately there is theUnsafe field that can be used to retrieve Unsafe instance. Sizeof() Function Direct Memory Management. Tree List Recursion Abstract. Stanford CS Education Library: one of the neatest recursive pointer problems ever devised. This is an advanced recursive pointer problem that uses a binary tree and a doubly linked list. You should be comfortable with pointers and recursion to understand this problem. This article introduces the problem with a few memory diagrams, gives some hints, and provides solution code in both Java and C/C++.

Available in both HTML and PDF... See: TreeListRecursion.html Or as a PDF: TreeListRecursion.pdf -- the same content, but in PDF, so both the text and images are in the one file See also... Linked Lis tBasics -- introduction to linked lists Linked List Problems -- more advanced linked list problems Binary Trees -- introduction to binary trees Downloading help Up to the CS Education Library Home. Binary Trees. By Nick Parlante This article introduces the basic concepts of binary trees, and then works through a series of practice problems with solution code in C/C++ and Java. Binary trees have an elegant recursive pointer structure, so they are a good way to learn recursive pointer algorithms. Contents Section 1. Binary Tree Structure -- a quick introduction to binary trees and the code that operates on them Section 2. Binary Tree Problems -- practice problems in increasing order of difficulty Section 3. C Solutions -- solution code to the problems for C and C++ programmers Section 4.

Stanford CS Education Library -- #110 This is article #110 in the Stanford CS Education Library. Related CSLibrary Articles Section 1 -- Introduction To Binary Trees A binary tree is made of nodes, where each node contains a "left" pointer, a "right" pointer, and a data element. Binary Search Tree Niche Basically, binary search trees are fast at insert and lookup.

Strategy Typical Binary Tree Code in C/C++ Lookup() 15. RESTful web services with MongoDB. A few tutorials ago,in the tutorial about RestEasy and Hibernate, we saw how we could integrate RESTEasy with Hibernate.Now in this tutorial we will see how can we create Restful web services with RestEasy and MongoDB. As an example we will see how to expose the documents of collection named Categories.The service class will be: Since our service class is ready we now need to create the Application class: package com.javaonly.service; import java.util.HashSet; import java.util.Set; import javax.ws.rs.core.Application; public class CategoryApplication extends Application { private Set<Class<? >> classes=new HashSet<Class<? >>(); private Set<Object> singletons = new HashSet<Object>(); public TutorialApplication() { singletons.add(new CategoryService()); } public Set<Object> getSingletons() { return singletons; } } Finally, in order to configure RESTEasy we must add the following snippet in the web.xml: Now every DAO class will extend AbstractDAO class.So in the case of categoryDAO we will have:

IAmDann. PhantomJS: Headless WebKit with JavaScript API. Vimcasts - free screencasts about the text editor Vim. Java Anti-Patterns. This page collects some bad code that may not look so obviously bad to beginners. Beginners often struggle with the language syntax. They also have little knowledge about the standard JDK class library and how to make the best use of it. In fact I have collected all examples from everyday junior code. I have modified the original code to give it example character and such that it highlights the problems. Many of these problems can easily be detected by SonarQube. I strongly recommend this tool. Some of these may seem like micro-optimization, premature optimization without profiling or constant factor optimizations.

If you are interested in how to pogram compiler friendly, look at the JDK Performance Wiki. In the end a lot of your application's performance depends on the overall quality of your code. Compare these scenarios (assume 100MB young generation): In the slower scenario the transaction duration is 10 times longer. String concatenation This is a real memory waster. Char is not int.

The Startup Diet: How $99 and four hours every 2 weeks can provide rocket fuel to an Entrepreneur | Start-up Life.

Learning

Reflections on the Eiffel Tower Isn't it romantic? What could be more perfect than a beautiful sunset here in Paris? There was a big storm all day long, but I could see the clouds were beginning to break up a little to the west, and I knew there was a pos. $ cheat git. Blog :: Joseph Perla. Don't write on the whiteboard :: Joseph Perla. I recently interviewed at a major technology company. I won't mention the name because, honestly, I can't remember whether I signed an NDA, much less how strong it was. I did well. Mostly because of luck. I normally step over myself when I interview. 1. When I interviewed at Palantir around 5 years ago, I had a lot of trouble with this.

Most people think you have to write on the whiteboard. The interviewer started by asking me to code up a simple recursive calculation, using any language I wanted. The interviewers don't care. 2. So I asked for some paper and a pen. You should always have paper and pen anyway to write down ideas. Some of the best programmers figure out the high-level overview on paper before they write a single line of new code. 3. Even if you are a C++ systems guru. You will waste a lot of time writing string manipulation code and initialization code that you can do in one line of Python. All I had was a post-it note, a tiny amount of space. 4. 5. 6. 7. 8. 9. 10. 11.

Oauth

Learn.knockoutjs.com. In this first tutorial you'll experience some of the basics of building a web UI with the Model-View-ViewModel (MVVM) pattern using knockout.js. You'll learn how to define a UI's appearance using views and declarative bindings, its data and behavior using viewmodels and observables, and how everything stays in sync automatically thanks to Knockout's dependency tracking (even with arbitrary cascading chains of data). Using bindings in the view In the bottom-right corner, you've got a viewmodel containing data about a person. In the top-right corner, you've got a view that's supposed to display the person data. Modify the two <strong> elements in the view, adding data-bind attributes to display the person's name: <p>First name: <strong data-bind="text: firstName"></strong></p><p>Last name: <strong data-bind="text: lastName"></strong></p> data-bind attributes are how Knockout lets you declaratively associate viewmodel properties with DOM elements.

Running the code Having trouble? Vim: revisited. I’ve had an off/on relationship with Vim for the past many years. Before, I never felt like we understood each other properly. I felt that the kind of programming I’m doing is not easily done without plugins and some essential settings in .vimrc, but fiddling with all the knobs and installing all the plugins that I thought I needed was a process that in the end stretched out from few hours to weeks, months even; and it the end it just caused frustration instead of making me a happier coder. Recently, I decided to give Vim another shot. This time around it was different – something in my brain switched and now for the first time in my life I’m proud of my knowledge of Vim.

My philosophy of it has changed to “less is more”, my approach was more disciplined and my motivation stronger. Start with a basic setup – but not zero This is a good starting point for your .vimrc: Guidelines for expanding your vim settings later on: You can view my personal vim configuration here. Make it pretty ctags Ack. Infographics & Data Visualizations - Visual.ly. The TILT: The Coolest Cooling Stand for the MacBook Pro by madMINDS. Hey Kickstarters thanks for checking out The TILT for MacBook Pro. We are just two brothers with one bold idea...to put the "cool" back in cooling stands. As proud aluminum unibody MacBook Pro owners, we grew tired of the cooling options currently in the marketplace. Generic cooling stands & pads do not reach or target the hottest areas of the MacBook Pro and with their ugly and bulky design, these stands and pads ruin the sleek Apple design we all appreciate.

The TILT is about to change all that. We have worked over a year on this with multiple prototypes, field testing, feeding off of Gatorade, Chicken McNuggets and tons of research. We believe in The TILT and with your support we know it can be a game changer. The TILT is the first cooling stand specifically designed & engineered for the aluminum unibody MacBook Pro. The TILT embraces the philosophy of the Apple brand – simple, sleek, smart, and slim. For those who value design and style. Don't have another USB port to spare? iLounge. Ejemplo simple con Ibatis - ChuWiki. Vamos a hacer aquí un pequeño ejemplo con Ibatis. No voy a poner código completo, pero sí todo lo necesario para hacerlo. Veremos como hacer INSERT, UPDATE, DELETE y SELECT. La base de datos Como base de datos usaré MySQL y en la base de datos "prueba" tengo la siguiente tabla mysql> use prueba; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> describe COCHE; +-----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+--------------+------+-----+---------+----------------+ | ID_COCHE | int(11) | NO | PRI | NULL | auto_increment | | MARCA | varchar(255) | YES | | NULL | | | MATRICULA | varchar(255) | YES | | NULL | | | FECHA_MATRICULA | date | YES | | NULL | | | ID_PROPIETARIO | int(11) | NO | | | | +-----------------+--------------+------+-----+---------+----------------+ 5 rows in set (0.00 sec) <?

Recomendation