programmer: a device to convert coffee into software
programmers: fixing other people's mistakes since 1908
programmer: are expected to know how to do things they've never done before
and estimate how long they will take
There are 10 types of people in this world. Those who know base 3, those who don't & those who expected a binary joke.
Mittwoch, 28. Dezember 2011
Install xfce4-power-manager Slackware 13.37 - shows no Battery status
http://goodies.xfce.org/projects/applications/xfce4-power-manager needs upower (http://slackbuilds.org/repository/13.37/system/upower/) - install upower, restart power-manager and battery state is fine.
Mittwoch, 21. Dezember 2011
setTimeout() && setInterval() scope problem solver
This is so handy from time to time:
setInterval(
function () {
var myVar = document.getElementById("givenID");
setTimeout(
function() {
// myVar is available because the inner closure
// gets the outer closures scope
myVar.innerHTML = "Junk";
},2000);
}, 10000);
Source: Stackoverflow
Dienstag, 20. Dezember 2011
Sencha Touch 1.1 - Adding a record and removing it doesn't work
I did the following and it worked well:
Add an entry - reload the app - delete that entry
I did the following and it didn't work:
Add an entry - delete that entry
Why?
I started to debug both cases paralelly. In both cases I found the new record in the object that is used to determine what has to be done, but for some strange reason in the case of adding and directly deleting that entry Sencha Touch doesn't find the entry.
What I did is really simple: After running the store.remove(record) method I check if there's a record in the store.removed property. If not, I add that record manually. You can as well fully remove the store.remove(record) method call and write the record directly into the property. It's up to you.
After you did that you just need to call store.destroy() to remove the record.
After you did that you just need to call store.destroy() to remove the record.
Sencha Touch 1.1 - CRUD actions & callbacks via REST proxy
CRUD actions
Methods without value param (update, destroy):
store.update({
callback: function(answer, object, success) {
if (success) { ... }
}
});
store.destroy({
callback: function(answer, object, success) {
if (success) { ... }
}
});
Methods with value param (create, load):
store.create(values, {
callback: function(answer, object, success) {
if (success) { ... }
}
});
store.load({
callback: function(answer, object, success) {
if (success) { ... }
}
});
CRUD action executes only once?
If you can run some of these functions once and after that no XHR is made, it may be because you encountered this bug: Bug @ Sencha Forum
I solved this bug by setting store.snapshot to false, so the function that engages the XHR is no longer looking for changes in the snapshot but in the store object.
Methods without value param (update, destroy):
store.update({
callback: function(answer, object, success) {
if (success) { ... }
}
});
store.destroy({
callback: function(answer, object, success) {
if (success) { ... }
}
});
Methods with value param (create, load):
store.create(values, {
callback: function(answer, object, success) {
if (success) { ... }
}
});
store.load({
callback: function(answer, object, success) {
if (success) { ... }
}
});
CRUD action executes only once?
If you can run some of these functions once and after that no XHR is made, it may be because you encountered this bug: Bug @ Sencha Forum
I solved this bug by setting store.snapshot to false, so the function that engages the XHR is no longer looking for changes in the snapshot but in the store object.
Sonntag, 11. Dezember 2011
Slackware local shutdown script (to wipe out /tmp etc.)
Doesn't exist, but according to rc.local it's ok to create & use it :)
/etc/rc.d/rc.local_shutdown
/etc/rc.d/rc.local_shutdown
Chrome 15 from Slackbuild.org
Install libevent:
http://slackbuilds.org/repository/13.37/libraries/libevent/
then chromium:
http://slackbuilds.org/repository/13.37/network/chromium/
http://slackbuilds.org/repository/13.37/libraries/libevent/
then chromium:
http://slackbuilds.org/repository/13.37/network/chromium/
Customize XFCE4 Menu
http://wiki.xfce.org/howto/customize-menu
Desktop files are located here: /usr/local/share/applications | /usr/share/applications/
Desktop files are located here: /usr/local/share/applications | /usr/share/applications/
Mittwoch, 7. Dezember 2011
Copy files recursively without keeping directory structure (Linux)
We had to copy many files that were located in a very complex directory structure. The following snippet searches the current directory and its subdirectories for *.xml files & executes the cp command on every file it finds (the braces {} represent the file):
find -type f -iname '*.xml' -exec cp {} /target/dir/for/all/xmls/ \;
The target dir now contains all *.xml files without directories.
find -type f -iname '*.xml' -exec cp {} /target/dir/for/all/xmls/ \;
The target dir now contains all *.xml files without directories.
All Methods from a Javascript Object
I wrote that little helper because webdeveloper toolbar didn't show all methods to me. Maybe it's useful for you too.
https://gist.github.com/1441816
https://gist.github.com/1441816
Donnerstag, 1. Dezember 2011
console.log & debug flag?
Instead of checking the DEBUG flag everytime you need a debug info, like this:
if (DEBUG) {
console.log("my debug output");
}
you can just check the DEBUG flag once and disable the console.log function, like this:
if (DEBUG === false) {
console = {
log: function() {}
};
}
This enables you to simply call:
console.log("my debug output")
in your application. If DEBUG is true, you'll get your output. If DEBUG is false, console.log() will be called but is an empty function and thus will produce no output / error.
if (DEBUG) {
console.log("my debug output");
}
you can just check the DEBUG flag once and disable the console.log function, like this:
if (DEBUG === false) {
console = {
log: function() {}
};
}
This enables you to simply call:
console.log("my debug output")
in your application. If DEBUG is true, you'll get your output. If DEBUG is false, console.log() will be called but is an empty function and thus will produce no output / error.
Abonnieren
Posts (Atom)