Sunday, 18 August 2013

New to PowerShell. Unfamiliar with scripts.

New to PowerShell. Unfamiliar with scripts.

I found several answers on this site about renaming files in Powershell so
I'm sorry if this is a repeat. I've spent a good 5 hours on google and
various websites trying to figure this out. I really have tried to explain
this well.I am not a programmer just someone that is meticulous about
their filing. I have 14,000 picture sorted into files by year and month
but taken with multiple cameras and I want the file name to reflect the
date taken. For example October 16, 1998 pictures are in a folder called
1998 subfolder 10 October subfolder 19981016. I want the all the pictures
to be named 19981016_0001 19981016_0002 etc. I tried multiple suggestions
but it hasn't worked. Probably due to my lack of programmer knowledge
haha. Could someone help me out and give me dummy instructions? I can get
to the point where it list the folder I want to change but I'm unable to
actually change it. All of my pictures are .jpg. I tried to attach a
screenshot of what I did but unfortunately I can't since I'm too new here.
Thanks in advance!
I created a temp file of copies in case I messed it up. I started by
typing cd "C:\Documents and Settings\Brooke LastName\Desktop\Temp" then
after successfully getting my file to load I used a formula I found on
this forum.
ls *jpg | Foreach {$i=1} {Rename-Item _ -NewName
("$($.19981016){0:00000000#} .jpg" -f $i++) -whatif}
The error I got said
Unexpected token ' .19981016' in expression or statement.
At line:1 char:12 + $.19981016 <<<<
The error repeated several times
I found several formulas on the web but most created files that would
number with parenthesis for example vacation (1).jpg I want a four digit
counter after an underscore at the end of my date. ie 19981016_0001

Android: Getting Current Location

Android: Getting Current Location

In my code I request for location updates (NETWORK_PROVIDER) and then wait
for 5 minutes before requesting for the lastKnownLocation. About 50% times
I get a fix and onLocationChanged is called. But in some cases I am
getting the lastKnownLocation which is as old as 7-8 hours and in some
cases I do not get any lastKnownLocation at all.
My question is that when I am constantly connected to the network provider
and even after waiting for 5 minutes post requesting for a fresh location,
why am I not able to get a fix.
I have tried almost everything which has been suggested in different
questions on SO but hasn't helped me much.
Rather than calling the requestLocationUpdates(), is there anything else
which might help me getting the current location. I mean some other API
dealing with cellular network which might give a clue about the network
provider tower location.
I have been trying to optimize the performance of the location fetching
exercise in my code since many days but have not been able to get over
this problem. Please help.

Get description from ExceptionCode

Get description from ExceptionCode

Is there an API for translating ExceptionCode:s in an ExceptionRecord to a
readable message like FormatMessage for regular errors.

secure html forms throw webAPI

secure html forms throw webAPI

I've spent the past week on surfing the internet and in books reading
about authentication and started to roll out Basic Authentication for my
WebAPI so that HTML clients can let users login/register/logout.
I work on a solution has several projects
Test.WebAPI (just a simple WebAPI)
Test.Website (pure html,JavaScript)
in the (Test.Website) i have html pages and a folder for
accountant(/Accountant) that they can enter the invoices records.
just i want to protect this folder only by giving a user name and password
for each accountant , i have a list of users that doesn't belong to this
role i want deny access for them even if there credential are correct.
is there a straight forward example to send the log in credential to the
WebAPI and store the log in info in (session,cookie,....) and retrieve
account info any where throw javascrip
Please suggest

Cannot Connect to SQL Server Express

Cannot Connect to SQL Server Express

I tried to connect to SQL Server 2012 Express through Visual Studio 2012.
It was working before until yesterday when it gave this error
TITLE: Connect to Server
Cannot connect to FRANCISPEDS\SQLEXPRESS.



ADDITIONAL INFORMATION:
The type initializer for 'System.Data.SqlClient.SqlConnection' threw an
exception. (System.Data)



Index not found. (Exception from HRESULT: 0x80131124) (System.Data)



I have no idea what happened, can someone help? thanks.

Saturday, 17 August 2013

how to create a more accurate log using unix date

how to create a more accurate log using unix date

How do I setup this log for accurate timing? I am trying to create log
file using date '+%Y%m%d-%H:%M'. What is happening with my output is that
the timestamp is the same.
RUN refresh proc ===> 20130817-21:05
Waiting for pid:24638 ===> 20130817-21:05
Run parallel scripts ===> 20130817-21:05
Waiting for pids: 24652 ===> 20130817-21:05
Waiting for pids: 24653 ===> 20130817-21:05
Waiting for pids: 24654 ===> 20130817-21:05
Waiting for pids: 24655 ===> 20130817-21:05
Running post process ===> 20130817-21:05
Process Complete ===> 20130817-21:05
I know time elapsed during this process. What am I doing wrong with
creating my log? Here's my working script:
# Setup job
TIMESTAMP=`date '+%Y%m%d-%H:%M'`;
MYLOG=$BASEDIR/mvhistory.log
#Run Procedures
echo "====================================================" >> $MYLOG 2>&1
echo "RUN refresh proc ===> $TIMESTAMP" >> $MYLOG 2>&1
STAGING.sql &
pid0=$!
wait $pid0
echo "Waiting for pid:$pid0 ===> $TIMESTAMP" >> $MYLOG 2>&1
echo "Run parallel scripts ===> $TIMESTAMP" >> $MYLOG 2>&1
1.sql &
pid1=$!
2.sql &
pid2=$!
3.sql &
pid3=$!
4.sql &
pid4=$!
wait $pid1 $pid2 $pid3 $pid4
echo "Waiting for pids: $pid1 ===> $TIMESTAMP" >> $MYLOG 2>&1
echo "Waiting for pids: $pid2 ===> $TIMESTAMP" >> $MYLOG 2>&1
echo "Waiting for pids: $pid3 ===> $TIMESTAMP" >> $MYLOG 2>&1
echo "Waiting for pids: $pid4 ===> $TIMESTAMP" >> $MYLOG 2>&1
echo "Running post process ===> $TIMESTAMP" >> $MYLOG 2>&1
run_CLEAN.sql
echo "Process Complete ===> $TIMESTAMP" >> $MYLOG 2>&1
exit 0

Categories and Sub Categories in custom taxonomies

Categories and Sub Categories in custom taxonomies

I find and use the following code to display sub categories for default
taxonomy 'category' on my site, but I created a custom taxonomy , and can
not alter the code so that he was doing the same thing for the new
taxonomy, help please
<?php
if(is_category()) {
$subcategories = get_terms('category', 'parent='.get_query_var('cat'));
if(empty($subcategories)) {
$thiscat = get_term(get_query_var('cat'),'category');
$subcategories = get_terms('category',
'parent='.$thiscat->parent.'');
}
if(empty($subcategories)) $subcategories = array();
if(!empty($subcategories)) {
echo '<ul>';
foreach($subcategories as $subcat) {
if(get_query_var('cat') == $subcat->term_id) $current = '
current-cat'; else $current = '';
echo '
<li class="cat-item cat-item-'.$subcat->term_id.$current.'">
<a href="'.get_category_link( $subcat->term_id ).'"
title="'.$subcat->description.'">'.$subcat->name.'</a>
</li>';
}
echo '</ul>';
}
}
else {
// If no current cat query, just get the top level ones using
wp_list_categories.
?>
<ul>
<?php wp_list_categories('title_li=&depth=1');?>
</ul>
<?php
}
?>