knowing what PowerShell can do on a command line I have never learned how to write GUIs with it. Should I?
Or just go back to the good old HTA / VBScript?
I have been trying to modify this log4bash implementation but I cannot manage to make it work. Here's a sample:
#!/bin/bash
TRUE=1
FALSE=0
############### Added for testing
log4bash_LOG_ENABLED=$TRUE
log4bash_rootLogger=$TRACE,f,s
log4bash_appender_f=file
log4bash_appender_f_dir=$(pwd)
log4bash_appender_f_file=test.log
log4bash_appender_f_roll_format=%Y%m
log4bash_appender_f_roll=$TRUE
log4bash_appender_f_maxBackupIndex=10
####################################
log4bash_abs(){
if [ "${1:0:1}" == "." ]; then
builtin echo ${rootDir}/${1}
else
builtin echo ${1}
fi
}
log4bash_check_app_dir(){
if [ "$log4bash_LOG_ENABLED" -eq $TRUE ]; then
dir=$(log4bash_abs $1)
if [ ! -d ${dir} ]; then
#log a seperation line
mkdir $dir
fi
fi
}
# Delete old log files
# $1 Log directory
# $2 Log filename
# $3 Log filename suffix
# $4 Max backup index
log4bash_delete_old_files(){
##### Added for testing
builtin echo "Running log4bash_delete_old_files $@" &2
#####
if [ "$log4bash_LOG_ENABLED" -eq $TRUE ] && [ -n "$3" ] && [ "$4" -gt 0 ]; then
local directory=$(log4bash_abs $1)
local filename=$2
local maxBackupIndex=$4
local suffix=$(echo "${3}" | sed -re 's/[^.]/?/g')
local logFileList=$(find "${directory}" -mindepth 1 -maxdepth 1 -name "${filename}${suffix}" -type f | xargs ls -1rt)
local fileCnt=$(builtin echo -e "${logFileList}" | wc -l)
local fileToDeleteCnt=$(($fileCnt-$maxBackupIndex))
local fileToDelete=($(builtin echo -e "${logFileList}" | head -n "${fileToDeleteCnt}" | sed ':a;N;$!ba;s/\n/ /g'))
##### Added for testing
builtin echo "log4bash_delete_old_files About to start deletion ${fileToDelete[@]}" &2
#####
if [ ${fileToDeleteCnt} -gt 0 ]; then
for f in "${fileToDelete[@]}"; do
#### Added for testing
builtin echo "Removing file ${f}" &2
####
builtin eval rm -f ${f}
done
fi
fi
}
#Appender
# $1 Log directory
# $2 Log file
# $3 Log file roll ?
# $4 Appender Name
log4bash_filename(){
builtin echo "Running log4bash_filename $@" &2
local format
local filename
log4bash_check_app_dir "${1}"
if [ ${3} -eq 1 ];then
local formatProp=${4}_roll_format
format=${!formatProp}
if [ -z ${format} ]; then
format=$log4bash_appender_file_format
fi
local suffix=.`date "+${format}"`
filename=${1}/${2}${suffix}
# Old log files deletion
local previousFilenameVar=int_${4}_file_previous
local maxBackupIndexVar=${4}_maxBackupIndex
if [ -n "${!maxBackupIndexVar}" ] && [ "${!previousFilenameVar}" != "${filename}" ]; then
builtin eval export $previousFilenameVar=$filename
log4bash_delete_old_files "${1}" "${2}" "${suffix}" "${!maxBackupIndexVar}"
else
builtin echo "log4bash_filename $previousFilenameVar = ${!previousFilenameVar}"
fi
else
filename=${1}/${2}
fi
builtin echo $filename
}
######################## Added for testing
filename_caller(){
builtin echo "filename_caller Call $1"
output=$(log4bash_abs $(log4bash_filename "${log4bash_appender_f_dir}" "${log4bash_appender_f_file}" "1" "log4bash_appender_f" ))
builtin echo ${output}
}
#### Previous logs generation
for i in {1101..1120}; do
file="${log4bash_appender_f_file}.2012${i:2:3}"
builtin echo "${file} $i"
touch -m -t "2012${i}0000" ${log4bash_appender_f_dir}/$file
done
for i in {1..4}; do
filename_caller $i
done
I expect log4bash_filename function to step into the following if only when the calculated log filename is different from the previous one:
if [ -n "${!maxBackupIndexVar}" ] && [ "${!previousFilenameVar}" != "${filename}" ]; then
For this scenario to apply, I'd need ${!previousFilenameVar} to be correctly set, but it's not the case, so log4bash_filename steps into this if all the time which is really not necessary...
It looks like the issue is due to the following line not working properly:
builtin eval export $previousFilenameVar=$filename
I have a some theories to explain why:
in the original code, functions are declared and exported as readonly which makes them unable to modify global variable. I removed readonly declarations in the above sample, but probleme persists.
Function calls are performed in $() which should make them run into seperated shell instances so variable modified are not exported to the main shell
But I cannot manage to find a workaround to this issue...
Any help is appreciated, thanks in advance!
From what I read, PHP 6 will break a lot of php scripts. I understand the reasons why it may break but why don't they just keep the PHP 5 and simply call PHP 6 as a different language based on PHP syntax? Like for example, why not just call php 6 scripts with an extension, "p6"- why are they trying so hard to make it backward compatible for old scripts when the extension can be used to call a specific interpreter?
So I've spent a lot of time making an iPhone game and have recently realized that I don't have to limit myself to just Apple - I know there are app stores for Palm and Android, but does anybody know of a good "app store" for the plain old PC? I would like to have one where individual developers can publish an app and not have to worry about all the billing and piracy issues!
My table structure looks like this:
create table rankings (
id IDENTITY NOT NULL,
user_id INT NOT NULL,
game_poule_id INT NOT NULL,
rank INT NOT NULL,
insertDate DATETIME NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (game_poule_id) REFERENCES game_poules(id) ON DELETE CASCADE
);
All old rankings of users per game are saved in this table. Now I want to have the last but one rank in the table for all users in a gamepoule.
Has someone an idea how to achive this? Thanks
Im building an automatic refreshing comment section for my website using jQuery .load. So I am using a javascript 'setTimeout' timer to check for new comments.
But after doing some stuff like changing comment pages or deleting (all using ajax), a few old timers keep running, even though I used clearTimeout before loading new ajax content.
Is there some way to clear ALL javascript timers when I load new ajax content?
I am developing an app that relies heavily on an external dll, my app needs to support new versions of the dll as well as being backwards compatible with the old ones.
Are there any good ways to have my unit tests target all of these different dll versions without the need to rewrite the tests as soon as a new version of the api is released? How is this best handled?
Thanks!
I have read this question.
My question is whether WPF Unleashed is still the most recommended (since the question is over a year old)?
Also, what do you think about WPF Recipes or Pro WPF?
Are there any tools available for converting a desktop vista machine into a virtual machine to run with MS Virtual PC? I am buying a new workstation and would like to virtualize my old machine onto the new one. I know of the tools for Hyper-V, but i'll be running Win7 on the new machine, not Hyper-V server.
Follow is my trigger of Sybase ASA 8.0 script:
Create trigger dba.test after insert,delete,update order 1 on
DBA.tb_press
referencing old as _old new as _new
for each row
begin
--How to detect deleteOperate,updateOperate?
if deleteOperate then
insert into syncLog(tableName,keyId,version,operate)
select tb_press,_old.id,1,'delete'
end if;
end
how to determine whether to insert ,update,delete operate.
I have a large web app, and I think there are a bunch of old files that are no longer being used, is there an app which can tell me what these files are?
Is there a way to change password to value same as the previous password?
when I try this:
[mrbean@wwwserver ~]$ passwd
Changing password for user mrbean.
Changing password for mrbean
(current) UNIX password:
New UNIX password: -- here i typed same password
BAD PASSWORD: is too similar to the old one.
I try to move my old logfiles to a yyyy\MM\dd folder structure by
Get-ChildItem . -Recurse -Include *.log |
Move-Item -Dest {"D:\Archive\{0:yyyy\\MM\\dd}\{1}" -f $_.LastWriteTime, $_.Name} -Force
but i get a path-not-found error.
update
I suspect the problem originates from the fact that the source path contains Program Files.
sub question: Could the same be done without Get-ChildItem?
Is there any equivalent of the VS7/8/9/10 Edit - Advanced - Format Document (Ctrl+K,Ctrl+D) function in the Visual Basic 6 IDE?
I've inherited an old codebase and it is messy in places so I'd like to tidy it up.
Is there any equivalent of the VS7/8/9/10 Edit - Advanced - Format Document (Ctrl+K,Ctrl+D) function in Visual Studio 6 (specifically VB6)?
I've inherited an old codebase and it is messy in places so I'd like to tidy it up.
Hi,
Iam using
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String bestProvider = locationManager.getBestProvider(criteria, true);
locationManager.requestLocationUpdates(bestProvider, 0, 0, this);
location = locationManager.getLastKnownLocation(bestProvider);
but first time it is not giving location object.Always giving me null.I read in developer.android.com ,
"Cached Location is dismissed if it is
too old"
But second time it is giving location updates.How to solve my problem.
Regards,
Android Developer
Is there a way to make a popup window maximised as soon as it is opened? If not that, at least make it screen-sized? This:
window.open(src, fullscreen="yes")
apparently only worked for old version of IE.
Hi guys.
First I want to say is that I am 37 years old and not from programer background (actualy from biology). And my question is should I start learning java? I have coded in php and javascript for a year and a half. Every answer would be appreciated
Thanks in advance
Bobi.
i have this querystring that shall open up my page.
http://www.a1-one.com/[email protected]&stuid=123456
Now when this page loads, on page_load, I want to pick up email and stuid in two different variables. So I can use them to insert into my database (sql server)
how can this be done in vb.net
(EDIT: I made it a community wiki as it is more suited to a collaborative format.)
There are a plethora of ways to access SQL Server and other databases from .NET. All have their pros and cons and it will never be a simple question of which is "best" - the answer will always be "it depends".
However, I am looking for a comparison at a high level of the different approaches and frameworks in the context of different levels of systems. For example, I would imagine that for a quick-and-dirty Web 2.0 application the answer would be very different from an in-house Enterprise-level CRUD application.
I am aware that there are numerous questions on Stack Overflow dealing with subsets of this question, but I think it would be useful to try to build a summary comparison. I will endeavour to update the question with corrections and clarifications as we go.
So far, this is my understanding at a high level - but I am sure it is wrong...
I am primarily focusing on the Microsoft approaches to keep this focused.
ADO.NET Entity Framework
Database agnostic
Good because it allows swapping backends in and out
Bad because it can hit performance and database vendors are not too happy about it
Seems to be MS's preferred route for the future
Complicated to learn (though, see 267357)
It is accessed through LINQ to Entities so provides ORM, thus allowing abstraction in your code
LINQ to SQL
Uncertain future (see Is LINQ to SQL truly dead?)
Easy to learn (?)
Only works with MS SQL Server
See also Pros and cons of LINQ
"Standard" ADO.NET
No ORM
No abstraction so you are back to "roll your own" and play with dynamically generated SQL
Direct access, allows potentially better performance
This ties in to the age-old debate of whether to focus on objects or relational data, to which the answer of course is "it depends on where the bulk of the work is" and since that is an unanswerable question hopefully we don't have to go in to that too much. IMHO, if your application is primarily manipulating large amounts of data, it does not make sense to abstract it too much into objects in the front-end code, you are better off using stored procedures and dynamic SQL to do as much of the work as possible on the back-end. Whereas, if you primarily have user interaction which causes database interaction at the level of tens or hundreds of rows then ORM makes complete sense. So, I guess my argument for good old-fashioned ADO.NET would be in the case where you manipulate and modify large datasets, in which case you will benefit from the direct access to the backend.
Another case, of course, is where you have to access a legacy database that is already guarded by stored procedures.
ASP.NET Data Source Controls
Are these something altogether different or just a layer over standard ADO.NET?
- Would you really use these if you had a DAL or if you implemented LINQ or Entities?
NHibernate
Seems to be a very powerful and powerful ORM?
Open source
Some other relevant links;
NHibernate or LINQ to SQL
Entity Framework vs LINQ to SQL
I need to change upgrade the PHP version to at least 5.2.0 for my new magento OS Commerce installation, but would it mess up my current store which runs on 4.4.9 (PHPCart)?
The real question is, can I upgrade without harming the old cart?
I'm trying to learn the Microsoft data / service stack. I want to build a database in SQL Azure and expose it to a c# client application.
I've never worked with any SQL database technology.
Looking online, everything just seems so confusing -- too many technologies, hard to tell what's new vs what's old.
What's the latest technologies to look at, and what (books?) should I be reading?
I'm working with an old windows app in visual studio 2005. A webserviced referenced in the original app has 2 functions and when i peak inside the auto-generated reference.cs file I notice a couple of other functions to allow async calls have been geenrated i.e. BeginWhateverFunctionNameIsCalled and EndWhateverFunctionNameIsCalled.
My problem is that I've created a new windows app and added the same web references but the Begin and End functions are not generated in my reference.cs proxy class. Anyone know whats going on?