Scenario: You've worked your tail off and *know* you're done with .. whatever you're working on, and can't be bothered to fixup/squash/commits properly to hide your work method to send upstream.
you have the most recent git fetch from upstream and you're ready to do a pull request.
git checkout upstream/master
(you get a warning that you're in headless mode. In this case, great, let's do what it says:)
git checkout -b mybranchforthispullrequest
Now you're basically looking at plain upstream/master.
you can either
git merge mylocalworkingbranch (but this keeps the commit history)
or, if you're *certain* you only want to add/replace files (hopefully, only add)
git checkout mylocalworkingbranch myfileiwanttoadd.ext
git add myfileiwanttoadd.ext
git commit -m "Added myfileiwanttoadd.ext"
and just send the branch to your origin or upstream
git push origin mybranchforthispullrequest
Optionally, go to github and do a pull request from mybranchforthispullrequest.
Showing posts with label howto. Show all posts
Showing posts with label howto. Show all posts
Saturday, April 20, 2013
Saturday, February 23, 2013
automysqlbackup error fix
You get this:
mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user 'debian-sys-maint'@'localhost' for table 'cond_instances' when using LOCK TABLES
to fix it:
edit /etc/default/automysqlbackup
change the DNAMES line to this:
mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user 'debian-sys-maint'@'localhost' for table 'cond_instances' when using LOCK TABLES
to fix it:
edit /etc/default/automysqlbackup
change the DNAMES line to this:
DBNAMES=`mysql --defaults-file=/etc/mysql/debian.cnf --execute="SHOW DATABASES" | awk '{print $1}' | grep -v ^Database$ | grep -v ^mysql$ | grep -v ^performance_schema$ | tr \\\r\\\n ,\ `
or, to be succinct:
add | grep -v ^performance_schema$into the list. If you're doing any different method of DBNAMES, just make sure to exclude performance_schema.
Why is this happening?automysqlbackup's default configuration attempts to lock tables before dumping. This error isn't specifically automysqlbackup's problem to fix, as much as it's a problem (or not) that performance_schema.cond_instances can't be locked [by debian-sys-maint] at the time of mysqldump, and mysqldump is what's throwing the error.
Is it a problem of backing up or not backing up performance_schema?I can't answer that for your situation, though if you understand what the table does and how to recreate it you can be better informed about whether the backup is necessary to you. (hint: probably not unless corporately you need to keep all diagnostic logs on everything.) Also, this is not related to the other databases which actually hold your data and which you do want to back up.
What does grep -v do?It says, "don't include this in the list". Note, while you're here, that this also includes the "mysql" table. If you need to keep your users and permissions for disaster recovery reasons, you may wish to consider not excluding that table.
What is "Database"? Why is that grep -v? I don't have a database called Database.Database is the column title of the result of "SHOW DATABASES" SQL query.
Labels:
automysqlbackup,
backup,
error,
fix,
howto,
mysql,
mysqlbackup
Friday, January 18, 2013
git branch before pull
Things are going well on your version of production/master and you'd like to pull the latest iteration. Oh, sure, you could tar your setup before doing that in case it breaks, but maybe you're stuck for time and too lazy. That's okay. Really it is. just
git branch before-pull-todaysdate
git pull
PANIC! bad stuff, things crashing, etc... maybe that pull isn't nice.
git checkout before-pull-todaysdate
whew... sanity restored. ... OK, it's off hours and you really want to get back to the latest iteration. Managers aren't on your back and you can fix this.
git checkout master
errors, etc. but at least you're at the latest iteration.
BETTER: don't pull. Just git fetch, then git merge when you're ready.
git branch before-pull-todaysdate
git pull
PANIC! bad stuff, things crashing, etc... maybe that pull isn't nice.
git checkout before-pull-todaysdate
whew... sanity restored. ... OK, it's off hours and you really want to get back to the latest iteration. Managers aren't on your back and you can fix this.
git checkout master
errors, etc. but at least you're at the latest iteration.
BETTER: don't pull. Just git fetch, then git merge when you're ready.
Monday, January 14, 2013
git branch change oops wrong branch
Specific case:
You're working on a feature but forgot to change branches. This feature is going to corrupt master, it seems, but you haven't committed yet.
alternative to stash,
git branch newbranchname
git checkout newbranchname
git add .
git commit -m "I needed a branch for this before killing master"
if you git checkout master, all these new previously uncommitted changes aren't there (whew) but git checkout newbranchname has the stuff you've been working on.
when you're ready to put them back, just merge back to master.
You're working on a feature but forgot to change branches. This feature is going to corrupt master, it seems, but you haven't committed yet.
alternative to stash,
git branch newbranchname
git checkout newbranchname
git add .
git commit -m "I needed a branch for this before killing master"
if you git checkout master, all these new previously uncommitted changes aren't there (whew) but git checkout newbranchname has the stuff you've been working on.
when you're ready to put them back, just merge back to master.
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.
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!
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.
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>
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.
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
Thursday, July 7, 2011
Can't send ctrl-alt-del via UVNC UltraVNC
well, it's not fun from the viewer, but let's say you've installed UltraVNC and rebooted the remote computer. Now you can't send Ctrl-Alt-Del to log in.
On screen keyboard can help for Windows 7 and (I think? Vista). You know that button in the bottom left? Turn on the on screen keyboard. Press the ctrl key, then the alt key, then the del key and you're in.
On screen keyboard can help for Windows 7 and (I think? Vista). You know that button in the bottom left? Turn on the on screen keyboard. Press the ctrl key, then the alt key, then the del key and you're in.
Tuesday, July 5, 2011
Captive portal follows you home
had an issue with a client where the hotel's captive portal followed him home with IE9. flushdns didn't work, neither cache and cookie delete. This was specifically an issue with onsite local connections, so I added the IP address to "local sites" in IE and it seemed to have resolved.
Subscribe to:
Posts (Atom)