How to get the version and build details
Created by Alin Brindusescu on 2011-12-12 15:22:40If you use to develop for iOS with Xcode you noticed that in the project settings page you have a version and build number. I was wondering how could I get them in my code to format a string for the about message. Here is how I manage to get this:
NSDictionary *projectInfo = [[NSBundle mainBundle] infoDictionary];
NSString *appName = [projectInfo objectForKey:@"CFBundleDisplayName"];
NSString *appVersion = [projectInfo objectForKey:@"CFBundleShortVersionString"];
NSString *appBuild = [projectInfo objectForKey:@"CFBundleVersion"];
NSString *appVersionStr = [NSString stringWithFormat:@"%@ V%@ R%@", appName, appVersion, appBuild];
See more in ENG ROMBackground mode issues with pjsip for iOS and freeSwitch
Created by Alin Brindusescu on 2011-12-08 08:06:05Last week I had some problems keeping the connection open between my iPhone app and the freeSwitch sip server.
After a lot of changes I figured out that I have to add to the configuration of the freeSwitch user/extension ($FREESWITCH_INSTAL_FOLDER/conf/directory/default/user.xml) this line:
<variable name="sip-force-contact" value="NDLB-connectile-dysfunction"/>
All of this are needed because freeSwitch should contact the iOS app on the same TCP port he got the registration request.
See more in ENG ROM
Ksh file name substitution
Created by Alin Brindusescu on 2011-02-23 04:22:55| ? | match any single character |
| * | match zero or more characters, including null |
| [abc] | match any character or characters between the brackets |
| [x-z] | match any character or characters in the range x to z |
| [a-ce-g] | match any character or characters in the range a to c, e to g |
| [!abc] | match any character or characters not between the brackets |
| [!x-z] | match any character or characters not in the range x to z |
| . | strings starting with . must be explicitly matched |
| ?(pattern-list) | match zero or one occurrence of any pattern |
| *(pattern-list) | match zero or more occurrences of any pattern |
| +(pattern-list) | match one or more occurrence of any pattern |
| @(pattern-list) | match exactly one occurrence of any pattern |
| !(pattern-list) | match anything except any pattern |
| | | multiple patterns must be separated with a | character |
See more in ENG
Executing a sequence of commands in unix shell
Created by Alin Brindusescu on 2011-02-21 03:36:59Last week I was arguing with a work colleague about how a sequence of commands is executed. And since I haven't upgrade my memory to a 64 bits system I had a look on the internet to see if I'm right or not and then update this here as an extension to my memory.
So what is the difference between:
# ./configure; make; make install and # ./configure && make && make installand when we have to use the first or the second one.
When using ; the commands are executed one after each other without taking into account the result of the run of the previous one. So if the execution of configure fail make and make install will still be executed. So, use ; into a sequence of commands if you want all commands to be executed. For our case this dosen't make to much sense, because if configure fails then we have no reason to run make.
When using && the commands are executed one after each other but if one of the commands fail then the next on the sequence will not be executed anymore. So if the execution of configure fail then make and make install will not be executed.
So, use && into a sequence of commands if there is some logical flow to be considered. For our case this make sense, because if configure fails then we have no reason to run make, or if make fails then we have no reason to run make install even if the configure ended with success.
There is one more operand ||, using this operand will cause the execution of the right side command only if the first command fails. For example
# ./configure || echo "Configure Fail"
here the echo command is executed only if the return status of configure is non zero.
All this 3 can be combined in one line but some rules should be considered otherwise the results would be unexpected.
In the following example:
# ./configure || echo "Configure Fail" ; cat error_log
the cat command is executed even if the configure command it dose not fail.Now let's try to add the cat to our configure make sequence:
# ./configure && make && make install || cat error_log
In this sequence if configure fails then cat is executed, if configure is successful and make fails cat will still be executed and so on. If all the commands return 0 then cat will not be executed. I found this sequence very usefulThe commands and the logical operators can be grouped to form more complex execution flows using {} or ().
When using {} to group the commands the commands will be executed in the current shell and when grouping with () the commands will be executed in a subshell.
See more in ENG ROM
Vînt la pupa!?
Created by Alin Brindusescu on 2011-02-10 04:17:18
Au vre-un efect parcurile eoliene asupra vînturilor din zonă? Vor avea și peste 10 sau 20 de ani aceleași caracteristici?
Iată cîteva întrebări care ar părea că nu au nevoie de răspuns. Nu prea ne putem imagina cum cîteva turbine eoliene ar putea modifica caracteristicile mișcărilor aerului ce par a exista de cînd lumea și pămînul.
Un studiu publicat în "Journal of Renewable and Sustainable Energy" de către Diandong Ren ne spune însă altceva. El estimează că în o scădere a puterii vîntului în următoarele decade, putere ce ar avea un impact de pînă la 12% asupra cantității de energie electrică produsă în anumite parcuri eoliene din China.
Comparînd valorile raportate de anemometre în ultimi 2 ani se pot observa diferențe majore față de valorile înregistrate în ani '50-'60 ai secolului trecut. Aceste diferențe sînt vizibile nu doar în China ci și în Europa sau America de Nord.
Cu toate acestea există posibilitatea ca parcurile eoliene să nu fie afectate deoarece anemometrele din stațiile meteo se află instalate la nivelul solului pe cînd turbinele eoliene sînt instalate la înălțimi variind între 60 și 100 de metri.
Oare să fim capabili să modificăm și viteza vînturilor? Pe mine chestia asta mă sperie și îmi aduce aminte de nopțile de vară petrecute în Cipru, cînd nici măcar o boare de vînt nu adia.
Sursa originală: IEEE Spectrum, Ianuarie 2011.
Articol apărut pe site-ul stiinta.info.
See more in ROM