let's say the application has a log output:
Overwrite:
wget -o logfilename.ext ...
Append:
wget -a logfilename.ext ...
Overwrite with a date log:
wget -o logfilename_`date +%Y-%m-%d`.ext ...
This gives you a daily log output.
Output goes to stdout:
Overwrite:
echo "something" > logfile
Append: (creates if not exist)
echo "something" >> logfile
Daily log:
echo "something" >> logfile_`date +%Y-%m-%d`
Output (errors) goes to stderr
include with your standard log:
echo "something" > logfile 2>&1
Thursday, November 1, 2012
Sunday, October 28, 2012
Javascript table red if negative
"How do I make a table show red in a cell if negative?"
There are likely a few things to watch out for (a minus in a text name or something like that.)
There are likely a few things to watch out for (a minus in a text name or something like that.)
//quick cheat red if negative.
var table = document.getElementById("my_table");
for (var j=0, row; row=table.rows[j]; j++) {
for (var i=0, cell; cell= row.cells[i]; i++) {
if (cell.innerText.indexOf("-")>-1) {
cell.style.color="red";
}
}
}
var table = document.getElementById("my_table");
for (var j=0, row; row=table.rows[j]; j++) {
for (var i=0, cell; cell= row.cells[i]; i++) {
if (cell.innerText.indexOf("-")>-1) {
cell.style.color="red";
}
}
}
Thursday, September 20, 2012
How do I add a value to a PHP array without a key?
$myarray = array(
'key1' => 'value',
'another value'
)
OK, so that works, but sometimes you just want to use bracket notation to add 'another value' entry without disturbing the array or including a key.
$myarray[]='another another value';
This adds a (hidden) key to the value. If you aren't using numbers in your index, it is likely that the hidden key might be zero. If not, it may be max integer key +1. You can't necessarily rely on the key number being consistent, but at least it's how to add a stand-alone value to an array without including a key.
'key1' => 'value',
'another value'
)
OK, so that works, but sometimes you just want to use bracket notation to add 'another value' entry without disturbing the array or including a key.
$myarray[]='another another value';
This adds a (hidden) key to the value. If you aren't using numbers in your index, it is likely that the hidden key might be zero. If not, it may be max integer key +1. You can't necessarily rely on the key number being consistent, but at least it's how to add a stand-alone value to an array without including a key.
Saturday, August 25, 2012
Office365 Hints
"How do I change the default domain?"
Click your Company name in the upper left. http://onlinehelp.microsoft.com/en-us/office365-enterprises/7aad2c2e-72ad-43cd-8efa-a241cc4cdc05#bkmk_default
"How do I stop a domain from handling email through office365? I'm getting NDR's!"
Make sure the domain is changed from "Hosted" to "Shared". http://support.microsoft.com/kb/2510049
"How do I change the UserPrincipalName on an Active Directory Sync environment?
Set-MSOLUserPrincipalName -UserPrincipalName badlyspelledname@mydomain.com -NewUserPrincipalName correctname@mydomain.com http://community.office365.com/en-us/forums/160/t/13854.aspx
"How do I change the UserPrincipalName (email domain) in an Active Directory Sync environment?
In the on-premises Active Directory Users and Computers you can change the UPN suffix for those synced users. http://support.microsoft.com/kb/2523192
"I changed my password/username for the global administrator of Office365, and now sync doesn't work."
Official response: Run Dirsync Config again. http://www.microsoft.com/online/help/en-us/helphowto/4a8ae818-5e4b-4438-a278-3de927ed5762.htm
"cheating" response: edit the credentials within miisclient for TargetWeb Services.
"How do I force a sync?"
Easiest: DirSyncConfigShell.psc1, Start-OnlineCoexistenceSync. http://onlinehelp.microsoft.com/en-us/office365-enterprises/ff652557.aspx
I *know* people are saying, "I don't recommend ILM/MIISCLIENT.EXE" and they're right to ward novices off, because you really can break your sync/delete data if you're not paying attention. But on the other hand, if you look at what miisclient.exe *does*, you're going to be able to see a lot more troubleshooting options that may help advanced users take better control over what's synced, including syncing certain OUs, forcing a full sync (this can be dangerous, as it can mass delete lots of users, but maybe that might be what you want in a fresh install, especially if you synced your entire domain and only want certain OUs to be synced.)
miisclient is important to know for troubleshooting, and if you know what you're doing, it can be used to great benefit or it can cause great grief.
Disclaimer: I can't help you and fully disclaim all responsibility (Don't blame me) if you break something with miisclient, and Microsoft may not necessarily support your tinkering, either. Document any changes with screenshots before and after. IMO, it's no scarier a tool than ADSIEdit or regedit. Use with appropriate caution.
Click your Company name in the upper left. http://onlinehelp.microsoft.com/en-us/office365-enterprises/7aad2c2e-72ad-43cd-8efa-a241cc4cdc05#bkmk_default
"How do I stop a domain from handling email through office365? I'm getting NDR's!"
Make sure the domain is changed from "Hosted" to "Shared". http://support.microsoft.com/kb/2510049
"How do I change the UserPrincipalName on an Active Directory Sync environment?
Set-MSOLUserPrincipalName -UserPrincipalName badlyspelledname@mydomain.com -NewUserPrincipalName correctname@mydomain.com http://community.office365.com/en-us/forums/160/t/13854.aspx
"How do I change the UserPrincipalName (email domain) in an Active Directory Sync environment?
In the on-premises Active Directory Users and Computers you can change the UPN suffix for those synced users. http://support.microsoft.com/kb/2523192
"I changed my password/username for the global administrator of Office365, and now sync doesn't work."
Official response: Run Dirsync Config again. http://www.microsoft.com/online/help/en-us/helphowto/4a8ae818-5e4b-4438-a278-3de927ed5762.htm
"cheating" response: edit the credentials within miisclient for TargetWeb Services.
"How do I force a sync?"
Easiest: DirSyncConfigShell.psc1, Start-OnlineCoexistenceSync. http://onlinehelp.microsoft.com/en-us/office365-enterprises/ff652557.aspx
I *know* people are saying, "I don't recommend ILM/MIISCLIENT.EXE" and they're right to ward novices off, because you really can break your sync/delete data if you're not paying attention. But on the other hand, if you look at what miisclient.exe *does*, you're going to be able to see a lot more troubleshooting options that may help advanced users take better control over what's synced, including syncing certain OUs, forcing a full sync (this can be dangerous, as it can mass delete lots of users, but maybe that might be what you want in a fresh install, especially if you synced your entire domain and only want certain OUs to be synced.)
miisclient is important to know for troubleshooting, and if you know what you're doing, it can be used to great benefit or it can cause great grief.
Disclaimer: I can't help you and fully disclaim all responsibility (Don't blame me) if you break something with miisclient, and Microsoft may not necessarily support your tinkering, either. Document any changes with screenshots before and after. IMO, it's no scarier a tool than ADSIEdit or regedit. Use with appropriate caution.
Insert Windows 2003 SP2 disk
Situation: You're providing remote support and installing a new role in an old environment (Windows 2003) ... well, this is over the Internet, and you may have that SP2 ISO locally, getting someone to install it or transfer it or download it may be a bit longer than you need.
If you have the ISO, you can try to mount/share through your rdp client, or you can (for Windows 2003) wait for the app to ask for the files you need and upload them one at a time.
If you have the ISO, you can try to mount/share through your rdp client, or you can (for Windows 2003) wait for the app to ask for the files you need and upload them one at a time.
Hey, but the ISO has the thing as a single .exe! There's no folder structure!It's true. But you can use, for instance, 7-Zip to extract the .exe to a folder locally, then continue with the install remotely, where it will ask for the files it needs, then you can upload just those files in an accessible location. Sure, it's probably better to download and extract on the remote server. But if you only need a couple of MB of files and you've already got the SP2 locally, why not take a look at this as an option?
Friday, August 17, 2012
VIM join every other line
I've received a long list of changed passwords for Office365 and they are delivered via email in the format:
User Name: xxxx
Temporary Password: xxxx
in HTML.
It's not very useful, but I could copy this list into vim. Now, how do I combine the username and password into a single row?
250 times Jj is kinda bad. what else can I do?
:g/User/j
Yeah, that's about it.
I suppose I could substitute all spaces for commas
:%s/ /,/
Nice, but now I don't really need User Name:, and Temporary Password:,
:%s/User Name:,//
:%s/Temporary Password:,//
Is there a trailing comma? Let's get rid of it
:%s/,$//
I should be able to save this as a .csv now!
User Name: xxxx
Temporary Password: xxxx
in HTML.
It's not very useful, but I could copy this list into vim. Now, how do I combine the username and password into a single row?
250 times Jj is kinda bad. what else can I do?
:g/User/j
Yeah, that's about it.
I suppose I could substitute all spaces for commas
:%s/ /,/
Nice, but now I don't really need User Name:, and Temporary Password:,
:%s/User Name:,//
:%s/Temporary Password:,//
Is there a trailing comma? Let's get rid of it
:%s/,$//
I should be able to save this as a .csv now!
Thursday, August 9, 2012
Searching excluding sites
Imagine that you're a prolific poster to a forum that's regularly indexed by a popular search engine and you'd like to find out if you're mentioned outside of that forum on other popular websites, but with respect to the content of the original forum.
You'd search, generally, for
yourname widget
and get a list of posts on that forum, likely. But you know about *those*. Where else?
search for
yourname widget -site:forumsite.domain.tld
note the prepended (-) which says, "Don't return results from that domain."
You'd search, generally, for
yourname widget
and get a list of posts on that forum, likely. But you know about *those*. Where else?
search for
yourname widget -site:forumsite.domain.tld
note the prepended (-) which says, "Don't return results from that domain."
Subscribe to:
Posts (Atom)