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 myObject = { | |
| property1: 'test', | |
| myFunc: function(arg) { | |
| // the 'this' object refers to the instance of the myObject variable | |
| this.property1 = arg; | |
| alert("Does this === myObject ? " + (this === myObject ? "yes" : "no") ); | |
| var a = function() { | |
| // inside a closure the 'this' object is now === window | |
| alert("Does this === window ? " + (this === window ? "yes" : "no")); |
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 twisted.internet import reactor, defer | |
| class Api: | |
| def __init__(self): | |
| self.domainObjects = None | |
| self.subscribers = [] | |
| def test(self, url): | |
| # code for doing the async stuff here |
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
| class EventHook(object): | |
| def __init__(self): | |
| self.__handlers = [] | |
| def addHandler(self, handler): | |
| self.__handlers.append(handler) | |
| def removeHandler(self, handler): | |
| self.__handlers.remove(handler) |
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
| /* | |
| Assuming you have JSON POSTed to your action in the form: | |
| { "id": 1, "name": "John Smith", "description": "Some description here" } | |
| */ | |
| // class for the POSTed data | |
| [Serializable] | |
| public class SomeJsonModelFormData |
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
| Day job: | |
| Software Developer by day...and night | |
| Favorite Python project: | |
| Twisted | |
| Favorite Conference: | |
| Haven't been to any *sad trombone* | |
| Python Experience Level: |
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 static class HtmlHelperExtensions | |
| { | |
| public static string ControllerName<TController>(this HtmlHelper helper) where TController : Controller | |
| { | |
| return typeof(TController).Name.Replace("Controller", string.Empty); | |
| } | |
| } |
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 orders = new [] { 1, 5, 7, 42 }; | |
| var customers = new [] { 1, 2, 3, 4, 5, 6, 7, 42 }; | |
| var customersWithOrdersCount = 0; | |
| foreach (var c in customers) { | |
| foreach (var o in orders) { | |
| if (c == o) { | |
| customersWithOrdersCount++; |
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 request = (HttpWebRequest)WebRequest.Create(this.Url); | |
| request.Accept = "application/json"; | |
| request.ContentType = "application/json"; | |
| request.Method = "POST"; | |
| using (var writer = new StreamWriter(request.GetRequestStream())) | |
| { | |
| writer.Write(this.PostBody); | |
| } | |
| var response = request.GetResponse(); | |
| string responseString = 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
| [Test] | |
| public void should_POST_to_RESTful_service() | |
| { | |
| // Arrange | |
| var myAwesomeRestfulConsumer = MockRepository.GenerateMock<AwesomeRestfulConsumer>(); | |
| // Act | |
| myAwesomeRestfulConsumer.ConsumeRestfulService(); | |
| // Assert |
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
| $ ls Foo\ -\ S1\ -\ * | |
| Foo - S1 - 02 Foo - S1 - 06 Foo - S1 - 10 | |
| Foo - S1 - 03 Foo - S1 - 07 Foo - S1 - 11 | |
| Foo - S1 - 04 Foo - S1 - 08 | |
| Foo - S1 - 05 Foo - S1 - 09 | |
| $ for f in Foo\ -\ S1\ -\ * | |
| do | |
| newFile=`echo $f | sed 's/Foo - S1 - /Foo_S01_/g'` |
OlderNewer