Fill Database with ActiveRecord
Rails ActiveRecord is a quite powerfull tool even without Rails itself. Since it gets all the needed information from the Database it can actually be used for all kinds of operations on the Database itself via scripting. In a current project there was the need to generate a lot of data on a table to use for testing, since the table was modified during the testing it made sense to write a script which auto generates the data based on the current table configuration.
This can be achieved by leveraging ActiveRecord, like this
https://gist.github.com/3017432.js?file=argen.rb
This can be expanded to all kinds of SQL types by extending the mapping hash, as well as the needed data generate methods. By doing so it can incoperate also database specific types like hashes by identifying the via their characteristic SQL type, i.e. md5 hash is char(40).
LocalStorage and PhoneGap persistance
Apple decided to store data from the localStorage of a WebView in Caches since iOS 5.1. Sadly those caches are purged from time to time so this does not really enable a persistence. After wrestle with that for some time today I found the solution in a BlogPost here.
The essence is changing the paths for localStorage, etc. in the AppDelegate.
Works great!
Coding Horror: Please Don’t Learn to Code
Link: Coding Horror: Please Don’t Learn to Code
The truth is that coding is associated with knowing about “computers” sadly. But just like Dijkstra said
“Computer science is no more about computers than astronomy is about telescopes.”
ShowMAC Cordova (once PhoneGAP) Plugin
Since UUID Access is deprecated in iOS I needed a method to access some Unique Identifier via
Cordova which was ok to use in the long run, so the MAC seems like a good choice here. Since it
is not exposed by default I wrote a small plugin to access it. Maybe I am not the only one looking
for this so I put it on github.
Enjoy
WordPress Plugin: WordPress Page Contact
Since WordPress does not provide any kind of author widget to go along with a post or page I decided to roll my own. I feel like it’s a nice thing to get the contact details for a person responsible for a specific section of the page right on this page, and a widget seemed like a perfect fit, so this is how WordPress Page Contact came into being, as my first listed WordPress plugin.
The structure is rather simple: create a database of contacts and associate them to a page or post via postmeta, which can be retrieved easily upon display. Rollup the information in a widget to display in the sidebar for any given entry and here we go.
Since I didn’t find anything similar I decided apply for it to be listed in the Plugin index so here we are. You can find it as WordPress Page Contact.
Enjoy!
You’re crap and paid too much for the little work you actually do – theregister
Link: You’re crap and paid too much for the little work you actually do – theregister
This is exactly what is wrong with the so called “big business” and the reason for me not wanting to work there . Nicely summed up…
MySQL Gem 2.8.1 on MacOSX Lion
Just because I keep googling it:
To install MySQL 2.8.1 on OS X Lion
1.
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
2.
env ARCHFLAGS="-arch x86_64" sudo gem install mysql -v='2.8.1' -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
Thanks Stackoverflow
How I learned to stop worrying and love REST
Link: How I learned to stop worrying and love REST
Providing the ways to traverse the API in the objects seems like such a basic thing but I guess it has just been a small revelation to me! It just explains the feeling about having a beautiful simple API vs a one feeling kind of clunky.
Give me my $_POST, or a JSON helper for CodeIgniter
In a current Project I’ve been working with a Cappucino frontend and a CodeIgniter Backend. Since Cappucino just loves JSON I decided this is the way to go, sadly PHP doesn’t provide a standard way to interact with a JSON POST but with a little helper this can be solved easily. I made a Gist out of it so it can be improved apon and reused.