Posted: April 25th, 2013 | Author: Christopher Vigliotti | Filed under: ColdFusion, Frameworks, MVC | 2 Comments »
What does this ColdFusion developer do in his spare time? If you answered ‘write a custom MVC framework in two hours’ then you answered correctly. Initially I hesitated to share this, as it is nowhere close to finished (and probably never will be). But I decided to throw caution to the wind and offer it up for ridicule and scrutiny. Here’s a list of what I was able to accomplish in two hours…
- Create a spiffy directory structure
- Add model, view and controller logic
- integrate jquery, datatables.net and bootstrap (although I do get a warning when datatables loads)
- Create a controller layer that allows for persistant variables when forwarding to one action to the next (like the flash scope in Grails)
If I were to spend any more time on this project I would explore
- Moving the controller layer to cfcs
- Switching from a [url]?action=section.action convention to a [url]/section/ation/ convention
- Integrate ColdFusion’s built-in ORM goodness to the model
- Actually make the sample application to work (adding CRUD features for the ‘widget’ entity)
- Switching out the awesome Bootstrap front-end framework for the even more awesome Foundation front-end framework
If you are looking for a good ColdFusion framework I insist that you look elsewhere. ColdBox, CFWheels, FW/1 and Model Glue are all really good.
Without further rambling I present the 0.2 release of Widgets Ahoy!
Posted: February 28th, 2013 | Author: Christopher Vigliotti | Filed under: jQuery | No Comments »
I had a requirement pop up recently that had me fiddling with jqTree. I wanted to be able to add a new parent or sibling node to a tree. Thankfully the author of jqTree provided the addParentNode() and addNodeAfter() functions.
First I created a page that allowed me to add a new parent or sibling node to node id 1…
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
| <html>
<head>
<title>jqTree Example 1: adding a new parent node and/or a sibling node to node id 1</title>
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="scripts/tree.jquery.js"></script>
<link rel="stylesheet" href="jqtree.css">
<script>
$(document).ready(function() {
// get the data
var data = [
{
label: 'node1',
id: 1,
children: [
{
label: 'child1',
id: 2
},
{
label: 'child2',
id: 3
}
]
},
{
label: 'node2',
id: 4,
children: [
{
label: 'child3',
id: 5
}
]
}
];
// Create tree widget
$(function() {
$('#tree1').tree({
data: data,
autoOpen: true,
saveState: true
});
});
// add a listener for the addParent button
$("#addParent").click(function() {
// get the tree
var $tree = $('#tree1');
// get the node with id 1
var node = $tree.tree('getNodeById', 1);
// add a parent node to node id 1
$('#tree1').tree(
'addParentNode',
{
label: 'new parent added to node1',
id: 6
},
node
);
});
// add a listener for the addNodeAfter button
$("#addNodeAfter").click(function() {
// get the tree
var $tree = $('#tree1');
// get the node with id 1
var node = $tree.tree('getNodeById', 1);
// add a parent node to the node id 1
$('#tree1').tree(
'addNodeAfter',
{
label: 'new node added after node1',
id: 6
},
node
);
});
});
</script>
</head>
<body>
<input type="button" id="addParent" value="addParent" />
<input type="button" id="addNodeAfter" value="addNodeAfter" />
<div id="tree1"></div>
</body>
</html> |
Next I tweaked the code so that it created a new parent or sibling node for the last clicked node. The secret sauce here is to bind to tree.click so that I could store the last clicked node in a variable (for use in other functions).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
| <html>
<head>
<title>jqTree Example 2: adding a new parent node and/or a sibling node to the last node clicked</title>
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="scripts/tree.jquery.js"></script>
<link rel="stylesheet" href="jqtree.css">
<script>
// any time a node is clicked we will store it in this variable (see below)
var clickedNode = null;
$(document).ready(function() {
// get the data
var data = [
{
label: 'node1',
id: 1,
children: [
{
label: 'child1',
id: 2
},
{
label: 'child2',
id: 3
}
]
},
{
label: 'node2',
id: 4,
children: [
{
label: 'child3',
id: 5
}
]
}
];
// Create tree widget
$(function() {
$('#tree1').tree({
data: data,
autoOpen: true,
saveState: true
});
});
// add a listener for the addParent button
$("#addParent").click(function() {
// if at least one node has been clicked
if(clickedNode != null){
// add a new parent to the clicked node
$('#tree1').tree(
'addParentNode',
{
label: 'new parent added to node1',
id: 6
},
clickedNode
);
}
});
// add a listener for the addNodeAfter button
$("#addNodeAfter").click(function() {
// if at least one node has been clicked
if(clickedNode != null){
// add a new node after the clicked node
$('#tree1').tree(
'addNodeAfter',
{
label: 'new node added after node1',
id: 6
},
clickedNode
);
}
});
// bind the 'tree.click' event (fires each time the tree is clicked)
$('#tree1').bind(
'tree.click',
function(event) {
// write the clicked node to the variable, for use
// in the addParent and addNodeAfter listeners above
clickedNode = event.node;
}
);
});
</script>
</head>
<body>
<input type="button" id="addParent" value="add parent to selected item" />
<input type="button" id="addNodeAfter" value="add node after selected item" />
<div id="tree1"></div>
</body>
</html> |
Until next time, fellow code monkeys!
Posted: December 20th, 2012 | Author: Christopher Vigliotti | Filed under: ColdFusion | 2 Comments »
Hello once again ColdFusion fans. I wish I had more time to blog about my adventures over the last six months (there have been many), but alas I do not. I was able to take a few minutes to share this with you, hope you find it helpful…
One of the reasons why I love ColdFusion is that it allows me to solve problems quickly. Today I ran into an issue where we had to move to a new mail server. I had HUNDREDS of email messages in the undelivered folder that needed to be re-sent after the move was completed.
After moving to the new mail server and attempting to move the messages to the Spool folder the messages kept re-appearing in the undelivered folder. Even though I specified a new mail server in ColdFusion Administrator the old messages were still tied to the old server and were bouncing back.
So I wrote this code to solve the problem. Feel free to co-opt it, take full credit for it, add this feature to Ray Camden‘s SpoolMail project (I did swipe a few lines of his code from SpoolMail for this) or get a face tattoo of the source code.
<cfscript>
// declare variables
request.emailMessage = "";
request.maildir = server.coldfusion.rootdir & "/Mail/Undelivr/";
request.messagesListQuery = "";
request.newMailServerAndPort = "new.servername.goes.here:25";
request.oldMailServerAndPort = "old.servername.goes.here:25";
request.spooldir = server.coldfusion.rootdir & "/Mail/Spool/";
</cfscript>
<!--- get the undelivered messages --->
<cfdirectory action="list"
name="request.messagesListQuery"
directory="#request.maildir#"
filter="*.cfmail"
sort="datelastmodified desc">
<!--- loop through the list of messages --->
<cfoutput query="request.messagesListQuery">
<!--- read a message --->
<cffile action="read" file="#request.maildir#/#name#" variable="request.emailMessage">
<!--- if the old mail server is present in the email... --->
<cfif FindNoCase(request.oldMailServerAndPort,request.emailMessage)>
<!--- ...then swap it out with the new mail server --->
<cfset request.emailMessage =
ReplaceNoCase(request.emailMessage, request.oldMailServerAndPort, request.newMailServerAndPort) />
<!--- write the file to the spool directory + delete the old message --->
<cffile action="write" file="#request.spooldir#/#name#" output="#request.emailMessage#">
<cffile action="delete" file="#request.maildir#/#name#">
</cfif>
</cfoutput>
<!--- display the results --->
<cfoutput>
#request.messagesListQuery.recordcount# messages that were set to be delivered to server
#request.oldMailServerAndPort# have will now be re-sent using server
#request.newMailServerAndPort#. Have a nice day.
</cfoutput> |
Once again ColdFusion helped me to quickly solve a problem. Face tattoo sold separately.
Posted: October 9th, 2012 | Author: Christopher Vigliotti | Filed under: ColdFusion | No Comments »
UPDATE: We’re no longer accepting applications or other correspondence for this position.
The small, fast-paced educational startup where I work is hiring! We’re busy, we’re growing and are we’re looking for an exceptional developer who wants to build something great. I’m looking for a world-class senior-level ColdFusion and SQL Server Developer. Do you…
have 7+ years of solid experience with ColdFusion and SQL Server?
have experience with ColdFusion frameworks?
have the drive to work remotely?
have the skill to work with a small team on both on legacy and new ColdFusion-based systems?
If you answered yes to the above four questions and are interested in a change then please send your resume in Word format via email to cvigliotti@presassociates.com with the characters ‘CFJOB’ in the subject. At this point this is a contract-level position and I am not accepting resumes from third parties of any kind. Thanks!
Posted: July 23rd, 2012 | Author: Christopher Vigliotti | Filed under: ColdFusion | No Comments »
My quest to be the last developer to blog about ColdFusion 10 is over! This will come as news to nobody in the community, but ColdFusion 10 is here. I’m looking forward to checking it out, and am particularly interested in tinkering with the enhanced ORM goodness (which I have exposure to in Groovy/Grails). I’m also glad to see Adobe pair ColdFusion 10 up with Solr and Tomcat. Go ColdFusion!
Posted: July 23rd, 2012 | Author: Christopher Vigliotti | Filed under: Process Improvement, Software Quality | No Comments »
My friend and fellow ColdFusion developer Dave Leeds’ blog Hit The Bits! is fast becoming one of my favorite developer blogs. His recent post on Code Reviews is right on the money.
Posted: July 20th, 2012 | Author: Christopher Vigliotti | Filed under: Selenium | No Comments »
I’ve been following the comments on this blog post and am anxiously awaiting an upcoming release to Selenium IDE that will feature Selenium WebDriver playback. Stay tuned for a review and update.
Posted: July 3rd, 2012 | Author: Christopher Vigliotti | Filed under: Selenium | No Comments »
I recieved this note from Will the other day…
Hello, I am an intern for a retail company. I am currently working with selenium and I need to tell you that your guides are amazing.
Thanks for your note Will. I’m glad that you found my Learn Selenium series helpful. Good luck on the path to improving software quality.
Posted: May 1st, 2012 | Author: Christopher Vigliotti | Filed under: SQL | No Comments »
Restoring your SQL Server database using the GUI can leave your database stuck in the “restoring” state. One quick solution is to restore your database by using this simple SQL script.
RESTORE DATABASE your-database-name FROM DISK='c:\your\backup\file\and\path\backup.bak' WITH REPLACE |
7/20/2012 Update
Here’s an updated version of the script that I use. I’ve also included my backup script.
-- restore it
use master
ALTER DATABASE [your-database-name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE [your-database-name]
FROM DISK = 'c:\your\backup\file\and\path\backup-to-restore.bak'
WITH REPLACE
ALTER DATABASE [your-database-name] SET MULTI_USER
-- back it up
BACKUP DATABASE [your-database-name] TO
DISK = N'c:\your\backup\file\and\path\backup.bak'
WITH NOFORMAT, INIT, NAME = N'your-database-name',
SKIP, NOREWIND, NOUNLOAD, STATS = 10 |
Posted: March 27th, 2012 | Author: Christopher Vigliotti | Filed under: JavaScript | 2 Comments »
Here’s a Greasemonkey script that I whipped up in 30 seconds that banishes the Google Black Bar’s new Google Play link back to the hell from whence it came. You may want to remove line 13.
1
2
3
4
5
6
7
8
9
10
11
12
13
| // ==UserScript==
// @name Oi Vei, Google Play
// @namespace http://code.christophervigliotti.com
// @include http://*.google.*
// @include http://google.*
// @include https://*.google.*
// @include https://google.*
// @include https://accounts.google.*
// @description Fixes Google's Black Bar
// ==/UserScript==
document.getElementById('gb_78').parentNode.style.display = 'none';
alert('YOU SHALL NOT PASS'); |