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
| // Source - http://social.msdn.microsoft.com/Forums/en-US/a967b44b-c85c-4afd-a499-f6ff604e2139/how-to-cloneduplicate-an-entity?forum=adodotnetentityframework | |
| private static T DataContractSerialization<T>(T obj) { | |
| DataContractSerializer dcSer = new DataContractSerializer(obj.GetType()); | |
| MemoryStream memoryStream = new MemoryStream(); | |
| dcSer.WriteObject(memoryStream, obj); | |
| memoryStream.Position = 0; | |
| T newObject = (T)dcSer.ReadObject(memoryStream); | |
| return newObject; |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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
| // $watch inside a service | |
| // Source: http://stackoverflow.com/questions/17806600/angularjs-watch-inside-a-service | |
| $rootScope.$watch(function() { | |
| return //value to be watched; | |
| }, function watchCallback(newValue, oldValue) { | |
| //react on value change here | |
| }, true); // true if you want it to watch object properties | |
| // Refreshing your current state. Such as you are in the ItemView state, and you are $state.go('ItemView') | |
| $state.go($state.current, {}, {reload: true}); |
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
| // Execute javascript function on postback | |
| // Source: http://stackoverflow.com/questions/4223837/run-javascript-function-after-postback | |
| ClientScriptManager.RegisterStartupScript(this.GetType(), "AKey", "MyFunction();", true); | |
| <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> | |
| <ItemTemplate > | |
| <asp:HyperLink ID="HyperLink2" runat=server NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "YourField", "Reply.aspx?query={0}") %>'>Reply</asp:HyperLink> | |
| <asp:HyperLink ID="HyperLink1" runat=server NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "YourField", "Desc.aspx?query={0}") %>'>Desc</asp:HyperLink> | |
| </ItemTemplate> | |
| </asp:Repeater> |
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
| // Source: http://msdn.microsoft.com/en-us/library/vstudio/ms229064(v=vs.100).aspx | |
| public class NewException : BaseException, ISerializable | |
| { | |
| public NewException() { } | |
| public NewException(string message) { } | |
| public NewException(string message, Exception inner) { } | |
| // This constructor is needed for serialization. | |
| protected NewException(SerializationInfo info, StreamingContext context) { } |
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
| // Some data | |
| { "_id" : 4, "grades" : [ { grade: 80, mean: 75, std: 8 }, | |
| { grade: 85, mean: 90, std: 5 }, | |
| { grade: 90, mean: 85, std: 3 } ] } | |
| // Update records based on multiple field matches | |
| db.studenst.update( | |
| grades: { | |
| $elemMatch: { | |
| 'grade': { |
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
| -- Update statement with join | |
| UPDATE Table1 | |
| SET Table1.LastName = 'DR. XXXXXX' | |
| FROM Table1 T1, Table2 T2 | |
| WHERE T1.id = T2.id | |
| and T1.id = '010008' | |
| -- Alter column on existing table | |
| ALTER TABLE {TABLENAME} | |
| ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} |
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
| predicate.create('Price', '==', parseFloat(engineSize)); |
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
| <!-- Source: https://github.com/michaelhue/keyscss --> | |
| <link rel="stylesheet" href="styles/keys.css" /> | |
| <!-- Dark keys: --> | |
| <kbd>ctrl</kbd> + <kbd>S</kbd> | |
| <!-- ...or... --> | |
| <kbd class="dark">ctrl</kbd> + <kbd class="dark">S</kbd> | |
| <!-- ...or... --> | |
| <span class="dark-keys"> | |
| <kbd>ctrl</kbd> + <kbd>S</kbd> |
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 BaseController : System.Web.Mvc.Controller | |
| { | |
| public BaseController() | |
| { | |
| Initialize(); | |
| } | |
| protected void Initialize() | |
| { | |
| // ... |