<script data-main="/scripts/main" src="/scripts/require.js" type="text/javascript"></script>
main.js
(function(){
requirejs.config(
baseUrl: 'scripts',
paths:{
'jquery': 'jquery-1.7.2'
}
);
require(['alerter'],
function(alerter){
alerter.showMessage();
});
})();
alerter.js
define('alerter',
['jquery', 'dataservice'],
function($, dataservice){
var name = 'John',
showMessage = function(){
var msg = dataservice.getMessage();
$('#messagebox').text(msg + ', ' + name);
};
return{
showMessage: showMessage
};
});
dataservice.js
define('dataservice',
[],
function(){
var
msg = 'Welcome to Code Camp',
getMessage = function(){
return msg;
};
return{
getMessage: getMessage
};
});
Wednesday, September 26, 2012
Modular Javascript Without RequireJS
dataservice.js
var dataservice = (function(){
var
msg = 'Welcome to Code Camp',
getMessage = function(){
return msg;
};
return{
getMessage: getMessage
};
})();
alerter.js
var alerter = (function (dataservice){
var
name = 'John',
showMessage = function(){
var msg = dataservice.getMessage();
alert(msg + ', ' + name);
};
return{
showMessage: showMessage
};
})(dataservice);
main.js
(function (alerter){
alerter.showMessage();
})(alerter);
var dataservice = (function(){
var
msg = 'Welcome to Code Camp',
getMessage = function(){
return msg;
};
return{
getMessage: getMessage
};
})();
alerter.js
var alerter = (function (dataservice){
var
name = 'John',
showMessage = function(){
var msg = dataservice.getMessage();
alert(msg + ', ' + name);
};
return{
showMessage: showMessage
};
})(dataservice);
main.js
(function (alerter){
alerter.showMessage();
})(alerter);
Wednesday, September 19, 2012
Issue: Nuget.Config is corrupted
Issue: C:\Users\Administrator\AppData\Roaming\NuGet\Nuget.Config is corrupted.
Solution: Edit the Nuget.Config with the following text.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="NuGet official package source" value="https://go.microsoft.com/fwlink/?LinkID=230477" />
</packageSources>
<activePackageSource>
<add key="NuGet official package source" value="https://go.microsoft.com/fwlink/?LinkID=230477" />
</activePackageSource>
</configuration>
Solution: Edit the Nuget.Config with the following text.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="NuGet official package source" value="https://go.microsoft.com/fwlink/?LinkID=230477" />
</packageSources>
<activePackageSource>
<add key="NuGet official package source" value="https://go.microsoft.com/fwlink/?LinkID=230477" />
</activePackageSource>
</configuration>
Friday, September 7, 2012
Issue: No implicit conversion between int and null
Issue: No implicit conversion between int and null
Solution:
int value = 999999;
int? result;
result = (value > 0) ? (int?)value : null;
Solution:
int value = 999999;
int? result;
result = (value > 0) ? (int?)value : null;
Thursday, September 6, 2012
LINQ .ToArray().Aggregate() Function
Method 1 (OLD):
var stringVar = new StringBuilder();
foreach (var item in itemsCollection)
{
stringVar.Append(item.PROPERTY + ", ");
}
if (codes.Length > 0)
{
stringVar.Remove(item.PROPERTY - 2, 2);
}
else
{
stringVar.Append("None");
}
return stringVar.ToString();
Method 2 (PREFERRED):
return itemsCollection.Any() ? itemsCollection.ToArray().Aggregate((first, second) => first + ", " + second) : "None";
var stringVar = new StringBuilder();
foreach (var item in itemsCollection)
{
stringVar.Append(item.PROPERTY + ", ");
}
if (codes.Length > 0)
{
stringVar.Remove(item.PROPERTY - 2, 2);
}
else
{
stringVar.Append("None");
}
return stringVar.ToString();
Method 2 (PREFERRED):
return itemsCollection.Any() ? itemsCollection.ToArray().Aggregate((first, second) => first + ", " + second) : "None";
Issue: Unable to cast the type 'System.Int32' to type 'System.Object'. LINQ to Entities only supports casting Entity Data Model primitive types.
Issue:
Unable to cast the type 'System.Int32' to type 'System.Object'. LINQ to Entities only supports casting Entity Data Model primitive types.
Solution:
Use .AsEnumerable() before .Select()
For example:
Table.Where(x=>...)
.AsEnumerable()
.Select(x=>...);
Unable to cast the type 'System.Int32' to type 'System.Object'. LINQ to Entities only supports casting Entity Data Model primitive types.
Solution:
Use .AsEnumerable() before .Select()
For example:
Table.Where(x=>...)
.AsEnumerable()
.Select(x=>...);
Wednesday, September 5, 2012
T-SQL Drop and Re-create Unique Constraint
ALTER TABLE [dbo].[TABLE_NAME]
DROP CONSTRAINT [UNIQUE_KEY_NAME]
GO
ALTER TABLE [dbo].[TABLE_NAME]
ADD CONSTRAINT [UNIQUE_KEY_NAME] UNIQUE NONCLUSTERED
(
[COLUMN_ID_1] ASC,
[COLUMN_ID_2] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
DROP CONSTRAINT [UNIQUE_KEY_NAME]
GO
ALTER TABLE [dbo].[TABLE_NAME]
ADD CONSTRAINT [UNIQUE_KEY_NAME] UNIQUE NONCLUSTERED
(
[COLUMN_ID_1] ASC,
[COLUMN_ID_2] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
Saturday, September 1, 2012
Move SQL Server 2008 Databases
use master
go
sp_detach_db 'mydb'
go
sp_attach_db 'ShowsTix',
'C:\Data\mydb_log.ldf',
'C:\Data\mydb.mdf'
go
use mydb
go
sp_helpfile
go
Subscribe to:
Posts (Atom)