This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Item | |
| { | |
| public ObjectId Id { get; set; } | |
| public string Sku { get; set; } | |
| [BsonDateTimeOptions(Representation = BsonType.Document)] | |
| public DateTime DateCreated { get; set; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Function / CmdLet that compares the MD5 hash of a file to a expected hash passed in via an argument | |
| # Put in powershell profile ($profile) if you want it as a global function, or put it into a module to be imported | |
| function Check-Hash ($file, $expectedHash) | |
| { | |
| $result = (Get-FileHash $file -Algorithm MD5).Hash.ToLower() -eq $expectedHash.Trim().ToLower() | |
| if ($result -eq $true) { | |
| Write-Host $result -ForegroundColor Green | |
| } else { | |
| Write-Host $result -ForegroundColor Red |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // From this URL: http://stackoverflow.com/questions/3642371/how-to-update-only-one-field-using-entity-framework | |
| public void ChangePassword(int userId, string password) | |
| { | |
| var user = new User() { Id = userId, Password = password }; | |
| using (var db = new MyEfContextName()) | |
| { | |
| db.Users.Attach(user); | |
| db.Entry(user).Property(x => x.Password).IsModified = true; | |
| db.SaveChanges(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var data = [ | |
| { name: 'item 1', status: 'Pending', qtyShipped: 0}, | |
| { name: 'item 2', status: 'Shipped', qtyShipped: 10}, | |
| { name: 'item 3', status: 'Pending', qtyShipped: 0}, | |
| { name: 'item 2', status: 'Shipped', qtyShipped: 5} | |
| ]; | |
| _.chain(data) | |
| .uniq(function (item) { return item.name; }) | |
| .countBy(function (item) { return item.status }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div ui-view="main" auto-scroll="false"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var data = [ | |
| { refNum: 'a1', items: [{name: 'item 1'}, {name: 'item 2'}] }, | |
| { refNum: 'b4', items: [{name: 'item 3'}, {name: 'item 4'}] } | |
| ]; | |
| var items = []; | |
| $scope.$watch('data',function ( nv, ov ) { | |
| angular.forEach(nv, function ( item ) { | |
| items.push(item); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Query teams and players in those teams, a relationship table between | |
| // Team << UserTeams >> User | |
| // Team.Id || UserTeam.TeamId, UserTeam.UserId || User.Id | |
| // Basic select | |
| var query = from x in Teams | |
| select x; | |
| // Inner Join (Give me teams that only have users in them) | |
| var query = from t in Teams |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var domainTeam = new Team() { Name = "Team 1", Description = "..." }; | |
| public class TeamRepository | |
| { | |
| public void Create(Team team) | |
| { | |
| var entityFrameworkTeam = new Entities.Team() { | |
| Name = team.Name, | |
| Description = team.Description | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var domainTeam = new Team() { Name = "Team 1", Description = "..." }; | |
| public class TeamRepository | |
| { | |
| public void Create(Team team) | |
| { | |
| // Don't forget to do your Mapper.Map<> in your bootstrap code in Global.asax or something or you'll get an unknown map error | |
| var entityFrameworkTeam = Mapper.Map<Entities.Team>(team); | |
| // db.add |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string dir = "c:\sites\app\Content\Images\Rank\1000\"; | |
| string fileName = "image1.jpg"; | |
| if (!Directory.Exists(dir)) | |
| Directory.CreateDirectory(dir); | |
| file.SaveAs(dir + fileName); |