sure, you know about s/foo/bar/ which replaces bar where foo exists.
Let's say you want to find foo but only when it comes before bar, and you want to replace some but not all of it.
s/\(foo\)bar/\1goo/
Will replace foobar with foogoo
will keep foodoo as is.
You can use this to, for instance, insert something before a comma:
s/\([a-z]\),/\1 = 0,/
foo, is now foo = 0,
or insert something between foo and bar
s/\(foo\)\(bar\)/\1 nutty \2/
changes foobar to foo nutty bar
Thursday, December 20, 2012
Saturday, December 1, 2012
Windows update error 80070005 quick resolution
If you've been infected by malware that "hides everything", don't forget to unhide the folders under c:\windows\SoftwareDistribution\
open an administrative level command prompt and type this:
cd \windows\SoftwareDistribution
attrib -r -s -h /s /d *.*
if you want to open the firehose (somewhat) safely, you might try this from c:\windows:
attrib -r -h /s /d *.*
You won't be able to unhide system files, but you will unhide everything that you otherwise have access to.
(Be very certain you're in the SoftwareDistribution folder prior to runnning the attrib command line, otherwise you just unhid/unreadonly/unsystem the entire folder you're in.)
This should quickly fix the WindowsUpdate_80070005 error and allow you to download Windows Updates as well as Microsoft Security Essentials updates if you're encountering 0x80070005 error.
There's no warranty about whether you try this stuff. It may make things work, but you should at least consider whether you're comfortable with this.
open an administrative level command prompt and type this:
cd \windows\SoftwareDistribution
attrib -r -s -h /s /d *.*
if you want to open the firehose (somewhat) safely, you might try this from c:\windows:
attrib -r -h /s /d *.*
You won't be able to unhide system files, but you will unhide everything that you otherwise have access to.
(Be very certain you're in the SoftwareDistribution folder prior to runnning the attrib command line, otherwise you just unhid/unreadonly/unsystem the entire folder you're in.)
This should quickly fix the WindowsUpdate_80070005 error and allow you to download Windows Updates as well as Microsoft Security Essentials updates if you're encountering 0x80070005 error.
There's no warranty about whether you try this stuff. It may make things work, but you should at least consider whether you're comfortable with this.
Thursday, November 15, 2012
Windows 7 NAS Shares can't connect
Thanks to this post, I implemented a GPO that disabled the requirements of Microsoft signatures for network shares and the NAS (LaCIE, et al) I couldn't see from Windows 7 x64bit now could be seen (after reboot of workstation).
Monday, November 5, 2012
mysql cheat to check is number
Is that value a number or a string?
select cast("2apple" AS UNSIGNED), cast("3 bananas" AS UNSIGNED), cast(0+ "4 cars" AS UNSIGNED), cast("100" AS UNSIGNED), cast("BAR" AS UNSIGNED), "5 bears" regexp "[A-Za-z]", "6" regexp "[A-Za-z]"
Returns:
2, 3, 4, 100, 0, 1, 0
Summary: Best way to check if the value is (only) a number is to check if it doesn't contain letters (assuming that letters are adequate for this detection. If you're expecting symbols but no letters, you'll need to test for the symbols).But, if you want to get the "Value" of the string (numbers before letters), CAST it as unsigned.If you know there will *never* be numbers before characters, you can use the CAST and test if greater than zero.
select cast("2apple" AS UNSIGNED), cast("3 bananas" AS UNSIGNED), cast(0+ "4 cars" AS UNSIGNED), cast("100" AS UNSIGNED), cast("BAR" AS UNSIGNED), "5 bears" regexp "[A-Za-z]", "6" regexp "[A-Za-z]"
Returns:
2, 3, 4, 100, 0, 1, 0
Summary: Best way to check if the value is (only) a number is to check if it doesn't contain letters (assuming that letters are adequate for this detection. If you're expecting symbols but no letters, you'll need to test for the symbols).But, if you want to get the "Value" of the string (numbers before letters), CAST it as unsigned.If you know there will *never* be numbers before characters, you can use the CAST and test if greater than zero.
Thursday, November 1, 2012
Linux log files various ways to log
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
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
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."
Friday, August 3, 2012
What if a company used its workstations to store data redundantly?
Oh, you know those small companies with a shared folder? Not exactly what I'm talking about.
So, let's see... large multinational company with several thousand deployed computers running 4GB RAM and 1TB hard drive apiece and the money is spent on the centralized management of servers to hold the data?
OK, you got me. ... But what if it were possible to leverage all the machines for encrypted, distributed data storage and processing power? It's not just data on your servers, it's data on your network.
What if you didn't really need a server?
But how would you back up?
Same way as normal, probably.
The key is that the data is redundantly distributed, a kind of hybrid of both RAID and torrent, but the workstations don't have to hold *all* the data apiece, just enough of the data to help complete the request if they're a part of the network, with the centralized repository being the key. Of interest, perhaps, is that if the server dies, the data should be aggregately recoverable from the workstations. In theory, if the server dies, the data is still accessible from the workstations, and likely the server's downtime would be unnoticed by the users.
I'm sure someone has thought of this, but if not, something I'm thinking about.
What if, further, the "server" floated CPU between the machines? I mean that the server is a virtual machine in the workstation cloud.
So, let's see... large multinational company with several thousand deployed computers running 4GB RAM and 1TB hard drive apiece and the money is spent on the centralized management of servers to hold the data?
OK, you got me. ... But what if it were possible to leverage all the machines for encrypted, distributed data storage and processing power? It's not just data on your servers, it's data on your network.
What if you didn't really need a server?
But how would you back up?
Same way as normal, probably.
The key is that the data is redundantly distributed, a kind of hybrid of both RAID and torrent, but the workstations don't have to hold *all* the data apiece, just enough of the data to help complete the request if they're a part of the network, with the centralized repository being the key. Of interest, perhaps, is that if the server dies, the data should be aggregately recoverable from the workstations. In theory, if the server dies, the data is still accessible from the workstations, and likely the server's downtime would be unnoticed by the users.
I'm sure someone has thought of this, but if not, something I'm thinking about.
What if, further, the "server" floated CPU between the machines? I mean that the server is a virtual machine in the workstation cloud.
Monday, July 16, 2012
cakephp success is red?
"Why is all setFlash red? Can't we do a success in green?"
Well, yes, just change the successful to look like this.
$this->Session->setFlash(__('The information has been saved'), 'default', array('class' => 'success'));
This assumes you're using cake's default css.
If, incidentally, you want to bake it ...
copy lib/Cake/Console/Templates/default/actions/controller_actions.ctp to app/Console/Templates/default/actions/controller_actions.ctp and make similar changes to "has been saved" entries (there are two?)
$this->Session->setFlash(__('The has been saved'), 'default', array('class' => 'success'));
Well, yes, just change the successful to look like this.
$this->Session->setFlash(__('The information has been saved'), 'default', array('class' => 'success'));
This assumes you're using cake's default css.
If, incidentally, you want to bake it ...
copy lib/Cake/Console/Templates/default/actions/controller_actions.ctp to app/Console/Templates/default/actions/controller_actions.ctp and make similar changes to "has been saved" entries (there are two?)
$this->Session->setFlash(__('The has been saved'), 'default', array('class' => 'success'));
incidentally, setting up this custom will break other bakes. If you want to keep the functionality, you can either copy "default/classes" and default/views" or
ln -s /path/to/lib/Cake/Console/Templates/default/classes app/Console/Templates/default/classes
ln -s /path/to/lib/Cake/Console/Templates/default/views app/Console/Templates/default/views
(I recommend symlinks if possible just in case updates in the templates from source need to trickle down.)
YMMV, hope it helps someone.
Thursday, July 12, 2012
htaccess to stop rewrite
If you want a .htaccess set in apache to stop rewrite redirect for a certain folder, turn off rewrite.
No, that's it. As long as override is enabled, .htaccess just needs the following:
<IfModule mod_rewrite.c>
RewriteEngine off
</IfModule>
No, that's it. As long as override is enabled, .htaccess just needs the following:
<IfModule mod_rewrite.c>
RewriteEngine off
</IfModule>
Monday, July 9, 2012
Managing Virtualbox Headless
I just copied a virtual machine from a Windows 7 host to an Ubuntu host. It was rather painless:
Stop the original guest vm, copy the folder, set up a new vm, use existing hard drive, and you're up (generally). I was using smoothwall, so I needed to mimic my network configuration, but otherwise, that's about it.
The fun part was the creation of the destination vm on a headless host. Sure, I could learn some command line, but I wanted a GUI. I added Cygwin-X to my Windows 7 box,
startx (opens X)
xhost+ (allows connections to X)
Opened putty with X11 forwarding to my linux box, then in putty
VirtualBox
tweak tweak tweak
back in putty
vboxheadless -s vmName &
close everything, go on with life.
Stop the original guest vm, copy the folder, set up a new vm, use existing hard drive, and you're up (generally). I was using smoothwall, so I needed to mimic my network configuration, but otherwise, that's about it.
The fun part was the creation of the destination vm on a headless host. Sure, I could learn some command line, but I wanted a GUI. I added Cygwin-X to my Windows 7 box,
startx (opens X)
xhost+ (allows connections to X)
Opened putty with X11 forwarding to my linux box, then in putty
VirtualBox
tweak tweak tweak
back in putty
vboxheadless -s vmName &
close everything, go on with life.
Saturday, July 7, 2012
Change RGB to a specific luminance
Perl code to create an RGB from a word/text entry (this is NOT the same as RGB "word colors", such as "blue" or "white")
use Digest::MD5 qw(md5_hex);
my $str = substr( md5_hex("test"), 0, 6);
print "RGB: " . $str."\n";
print "luminance:" . (0.2126*hex(substr($str,0,2)) + 0.7152*hex(substr($str,2,2)) +0.0722*hex(substr($str,4,2)));
This luminance scale is 0-255 (black to white). Divide by 256 for the percentage that you see in online color pickers.
What's with the luminance?
Ideally, you should have 3:1 or even 5:1 contrast to read text, but what do you do when the color is (somewhat) randomly generated and you want to be sure text is legible on the color?
For my purposes, I'm choosing white text on color.
A good cutoff for luminance is about a value of 85.
Based upon the above ratios, if you want to keep the same color (ish), for every 1 point change in green, you'll change red 3.364 (or about 3) points and change blue 9.9058 (or about 10) points. The change in luminance for this iteration is 0.2126*3.3640+0.7152*1+0.0722*9.9058 or 2.14558516 (roughly, 2) luminance units.
Given a luminance x (if given in percent, multiply 256), to achieve luminance y, a way to accomplish that is to take the luminance difference (y-x) and divide by 2.1456 to obtain the change in value of green.
Multiply the resulting change in green by 3.364 to get the change in red and by 9.9058 to get the change in blue to achieve the color with the new luminance.
The code below only executes in your browser and does not send to anyone.
It implements javascript md5
What color is your name?
In my trials, the results seem to be mostly green. If you don't like a given pallet for words, just change your offset for md5. I'm starting on the first character, but it can be shifted practically anywhere down the 32-character MD5 result.
Why MD5? Because it's reasonably assumed to be unique *enough* between random sources. I'm not using it for cryptography, here. This is just used for hex number generation.
<script language="JavaScript" type="text/javascript">
<!--
function sc(el) {
var dest=document.getElementById('colorme');
var dest2=document.getElementById('colorme2');
dest.style.backgroundColor='#'+el;
dest2.style.backgroundColor='#'+el;
var lum = 0.2126*parseInt(el.substring(0,2), 16) + 0.7152*parseInt(el.substring(2,4),16) + 0.0722*parseInt(el.substring(4,6),16);
dest.value=el + " lum:" + lum;
dest2.value=el + " lum:" + lum;
}
//-->
</script>
<form>
<input type="text" style="width:18em;" onclick="this.value=''" onchange="sc(hex_md5(this.value).substring(0,6))" value="type something and click outside">
<input type="text" id="colorme">
<input type="text" style="color:white" id="colorme2">
</form>
<!--
function sc(el) {
var dest=document.getElementById('colorme');
var dest2=document.getElementById('colorme2');
dest.style.backgroundColor='#'+el;
dest2.style.backgroundColor='#'+el;
var lum = 0.2126*parseInt(el.substring(0,2), 16) + 0.7152*parseInt(el.substring(2,4),16) + 0.0722*parseInt(el.substring(4,6),16);
dest.value=el + " lum:" + lum;
dest2.value=el + " lum:" + lum;
}
//-->
</script>
<form>
<input type="text" style="width:18em;" onclick="this.value=''" onchange="sc(hex_md5(this.value).substring(0,6))" value="type something and click outside">
<input type="text" id="colorme">
<input type="text" style="color:white" id="colorme2">
</form>
Wednesday, June 27, 2012
Check All Check None Javascript
A checkall/check none javascript implementation that doesn't care about ASP.
You ready?
You ready?
<script type="text/javascript">
function checkall(id,value) {
var form = document.getElementById(id);
for (var n=0; n< form.length; n++)
if (form.elements[n].type == 'checkbox')
form.elements[n].checked = value;
return false;
}
</script>
<form id="myForm">
<ul>
<li><input type="checkbox" onclick="checkall('myForm', this.checked)">Check all</li>
<li><input type="checkbox">Check me!</li>
<li><input type="checkbox">Check me, too!</li>
<li><input type="checkbox">Check this third box.</li>
</ul>
</form>
Code markup via quickhighlighter.com
function checkall(id,value) {
var form = document.getElementById(id);
for (var n=0; n< form.length; n++)
if (form.elements[n].type == 'checkbox')
form.elements[n].checked = value;
return false;
}
</script>
<form id="myForm">
<ul>
<li><input type="checkbox" onclick="checkall('myForm', this.checked)">Check all</li>
<li><input type="checkbox">Check me!</li>
<li><input type="checkbox">Check me, too!</li>
<li><input type="checkbox">Check this third box.</li>
</ul>
</form>
Labels:
check all,
check none,
code,
howto,
Javascript,
onclick
Tuesday, June 26, 2012
Pass a previous value in a select box
Renamed: Set a default select option when normal default is blank.
Let's say you want to do an event on a select onclick ... maybe something like a select with a blank as default, but if it's clicked, you want to change it to some other default (today's month?) ... but you also want that original blank to be selectable to "erase" the entry. This does not require jQuery or ASP. No need for a library to do this. Use it how you want.
Let's say you want to do an event on a select onclick ... maybe something like a select with a blank as default, but if it's clicked, you want to change it to some other default (today's month?) ... but you also want that original blank to be selectable to "erase" the entry. This does not require jQuery or ASP. No need for a library to do this. Use it how you want.
<script type="text/javascript">
function setDefault(el) {
if (el.previousValue != "") {
return;
}
if (el.value) {
return;
}
if (el.value == "") {
el.value = "choose me"
}
}
</script>
<select onclick="setDefault(this)" onfocus="this.previousValue=this.value">
<option value=""></option>
<option value="skip me">skip me</option>
<option value="choose me">choose me</option>
</select>
Code marked up with quickhighlighter.com
function setDefault(el) {
if (el.previousValue != "") {
return;
}
if (el.value) {
return;
}
if (el.value == "") {
el.value = "choose me"
}
}
</script>
<select onclick="setDefault(this)" onfocus="this.previousValue=this.value">
<option value=""></option>
<option value="skip me">skip me</option>
<option value="choose me">choose me</option>
</select>
Thursday, May 17, 2012
Fun with git
mkdir gittest cd gittestedit hello.txt
Hello, World!exit
cat hello.txtshould be the same
git init git add . git commit -m "First commit!" git branch update git checkout update cat hello.txtshould be the same
edit hello.txt
Hello, world! Don't leave me!save, exit
git add . git commit -m "Update hello.txt 1"Hmm. I don't like that. I've already committed!
git checkout HEAD~1 -- hello.txtIt's back!
edit hello.txt
Hello, world! I love you!save and exit
git commit -m "Love never dies" git checkout master cat hello.txtIt's gone?
git checkout update cat hello.txtIt's back!
git logI need that entry n commits ago, but just for hello.txt
git checkout HEAD~n -- hello.txt
Thursday, May 3, 2012
Converted my cell to Google Voice
First, this is a Sprint phone that has been used to convert the voicemail to Google Voice, not the same *exact* thing as port-your-number, so if your experience differs, that may be why.
Now, my experience.
Current impression: Why the heck didn't I do this before? No, really.
My phone calls can come in through Google Chat.
I can send and receive text messages through email, chat, or Google Voice and know about them.
Since I'm mostly working from home, I basically don't need to use my cell phone as much, and even if it's dead, I'm still able to send or receive phone calls *from my number* with a headset on my laptop, desktop ... basically any where.
It's really an interesting issue for me because there are so many different ways to communicate I don't even need a cell phone for that it does make me seriously consider whether the smart phone is necessary for me.
So far, so good, and it probably won't be worth switching back.
Monday, April 16, 2012
What's your preferred IDE?
Currently, still, it appears to be screen/byobu plus vim.
Probably I am missing all the niceties of something like netbeans, but here's how I set up a cakephp environment:
create a file that contains paths to sections...
---BEGIN FILE ---
cd /path/to/app/Controller
screen -t Controller
cd /path/to/app/Model
screen -t Model
cd /path/to/app/View
screen -t View
cd /path/to/app
screen -t app
cd /path/to/app/webroot/js
screen -t js
cd /path/to/app/webroot/css
screen -t css
cd /path/to/app/webroot/tmp/logs
screen -t logs
---END FILE ---
If you're using tmux instead of screen:
---BEGIN FILE---
cd /path/to/app/Controller
tmux new-window -n Controller
cd /path/to/app/Model
tmux new-window -n Model
cd /path/to/app/View
tmux new-window -n View
cd /path/to/app/
tmux new-window -n approot
cd /path/to/app/webroot/js
tmux new-window -n js
cd /path/to/app/webroot/css
tmux new-window -n css
cd /path/to/app/tmp/logs
tmux new-window -n log
then simply source the file when you want create the screens for our application
To change between screens, the default mappings of ctrl-a, number will get you there.
I also use :split within vim to work on multiple documents within a given structure. I find this *generally* gives me a quick and easy way to handle the substructures I need and keeps me organized. The few other things most IDEs also have (like class trees and completion) I haven't yet had to use, but I figure I could also macro that as I need. On the logs screen, I can tail -f debug.log.
Probably I am missing all the niceties of something like netbeans, but here's how I set up a cakephp environment:
create a file that contains paths to sections...
---BEGIN FILE ---
cd /path/to/app/Controller
screen -t Controller
cd /path/to/app/Model
screen -t Model
cd /path/to/app/View
screen -t View
cd /path/to/app
screen -t app
cd /path/to/app/webroot/js
screen -t js
cd /path/to/app/webroot/css
screen -t css
cd /path/to/app/webroot/tmp/logs
screen -t logs
---END FILE ---
If you're using tmux instead of screen:
---BEGIN FILE---
cd /path/to/app/Controller
tmux new-window -n Controller
cd /path/to/app/Model
tmux new-window -n Model
cd /path/to/app/View
tmux new-window -n View
cd /path/to/app/
tmux new-window -n approot
cd /path/to/app/webroot/js
tmux new-window -n js
cd /path/to/app/webroot/css
tmux new-window -n css
cd /path/to/app/tmp/logs
tmux new-window -n log
---END FILE---
then simply source the file when you want create the screens for our application
To change between screens, the default mappings of ctrl-a, number will get you there.
I also use :split within vim to work on multiple documents within a given structure. I find this *generally* gives me a quick and easy way to handle the substructures I need and keeps me organized. The few other things most IDEs also have (like class trees and completion) I haven't yet had to use, but I figure I could also macro that as I need. On the logs screen, I can tail -f debug.log.
Tuesday, April 3, 2012
CakePHP helper to suggest input
What's it do?
makes it easier to make a gray suggest input box. Just use drop it as InputHelper.pm in View/Helper/ and call it where and how you need it. call it just like Form->input but add a sample text for the box.
$this->Input->input(fieldname, options array, 'sample text');
As an example, see what happens when you click in , click out, and change the content this box.
What's with the hidden? If you want to know what the original content was, you can test against this in your Controller to see if fieldname value is equal to fieldname_hidden value and don't store if it matches.
makes it easier to make a gray suggest input box. Just use drop it as InputHelper.pm in View/Helper/ and call it where and how you need it. call it just like Form->input but add a sample text for the box.
$this->Input->input(fieldname, options array, 'sample text');
As an example, see what happens when you click in , click out, and change the content this box.
<?php App::uses('FormHelper', 'View/Helper');
/* helper to make default input help that disappears when clicked */
/* usage: $this--->Input->input */
class InputHelper extends FormHelper {
public function input($fieldname, $options=array(null), $fill) {
$options['class'] = ' dimmed';
$options['value'] = $fill;
$options['onClick'] = "if (this.value=='".$fill."') {this.value='';this.style.color='black'}";
$options['onBlur'] = "if (this.value=='') {this.value = '".$fill."'; this.style.color='gray'}";
$out = parent::input($fieldname, $options);
$out .= parent::hidden($fieldname . "_hidden", array('value' => $fill));
return $out;
}
}
?>
What's with the hidden? If you want to know what the original content was, you can test against this in your Controller to see if fieldname value is equal to fieldname_hidden value and don't store if it matches.
Friday, March 23, 2012
Apology
I made a post on another website and it went pretty bad.
It was a huge error in judgment, and all I have left that I can do is to post an apology.
I truly, deeply, honestly apologize for the post. It was all kinds of wrong, and indeed I made things worse trying to defend an indefensible position.
If such a thing can be in your heart to forgive, please do. If I could take it back, I would. But I realize it was wrong.
I'm sorry.
It was a huge error in judgment, and all I have left that I can do is to post an apology.
I truly, deeply, honestly apologize for the post. It was all kinds of wrong, and indeed I made things worse trying to defend an indefensible position.
If such a thing can be in your heart to forgive, please do. If I could take it back, I would. But I realize it was wrong.
I'm sorry.
Thursday, February 2, 2012
Find out what services need credentials
Symptom: You need to adapt to a changing environment where certain Windows services may have been enabled under the credentials of a user who no longer has access to anything.
How do you get a list of servers, service, and credentials quickly?
wmic /node:server1,server2,server3,"server-4" services get DisplayName,StartName /Format:csv
How do you get a list of servers, service, and credentials quickly?
wmic /node:server1,server2,server3,"server-4" services get DisplayName,StartName /Format:csv
Wednesday, January 18, 2012
Outlook Fast Search doesn't return results
Symptom: You're in outlook, and the search results aren't as expected, or not returning anything.
Check here: http://office.microsoft.com/en-us/outlook-help/instant-search-is-not-finding-items-HA010198085.aspx
While you're looking at the checkboxes for what is supposed to be indexed, if you would like to start from scratch, clear the box[es] and OK through to exit the index search. Then go back and check them again, and OK out. This is what will take a few hours, but it will now index your email as if it never had done it before. Verify on occasion. The numbers should increase for a while, then decrease back to zero. Once completed, your index has been rebuilt.
Check here: http://office.microsoft.com/en-us/outlook-help/instant-search-is-not-finding-items-HA010198085.aspx
VERIFY THAT YOUR OUTLOOK DATA FILES CAN BE INDEXED
Outlook indexes the following data files:
Personal Folders files (.pst)
Offline Folder files (.ost)
This includes Microsoft Windows Live Mail, IMAP, and POP e-mail accounts. If you use a Microsoft Exchange account (much more common in business e-mail systems than in a home or personal account), you must be connected to the server running Exchange and use Cached Exchange Mode for Instant Search to index your messages. Cached Exchange Mode uses an Offline Folders file (.ost) to save your information on your computer. To verify which data files are being indexed, do the following:
On the Tools menu, point to Instant Search, and then click Search Options.
Alternatively, click the arrow in the Instant Search pane, and then click Search Options on the menu.
Under Indexing, verify that the data files that you want to include in your search are selected in the Index messages in these data files list.
VERIFY THAT INDEXING IS COMPLETE
To verify the indexing status, do the following:
On the Tools menu, point to Instant Search, and then click Indexing Status.
Alternatively, click the arrow in the Instant Search pane, and then click Indexing Status on the menu.
Verify that the dialog box reports 0 items remaining. If not, indexing is not complete and needs to finish before all of your Outlook items can be searched.
INDEXING STATUS REPORTS "0 ITEMS REMAINING," HOWEVER, SEARCH RESULTS ARE NOT CORRECT
If the Indexing Status reports 0 items remaining and Instant Search is still not returning the correct search results, exit Outlook and restart your computer. When you start Outlook again, verify that Outlook is indexing your items properly by doing the following:
On the Tools menu, point to Instant Search, and then click Indexing Status.
Alternatively, click the arrow in the Instant Search pane, and then click Indexing Status on the menu.
Verify that the number of items in the Indexing Status dialog box has increased. If the number has not increased, you must wait until indexing is complete for the results.
While you're looking at the checkboxes for what is supposed to be indexed, if you would like to start from scratch, clear the box[es] and OK through to exit the index search. Then go back and check them again, and OK out. This is what will take a few hours, but it will now index your email as if it never had done it before. Verify on occasion. The numbers should increase for a while, then decrease back to zero. Once completed, your index has been rebuilt.
Subscribe to:
Posts (Atom)