Tutorial by Examples: action

You can use engine.begin to open a connection and begin a transaction that will be rolled back if an exception is raised, or committed otherwise. This is an implicit way of using a transaction, since you don't have the option of rolling back manually. with engine.begin() as conn: conn.execute(...
Usually authentication&authorization processes are performed by built-in cookie and token supports in .net MVC. But if you decide to do it yourself with Session you can use below logic for both page requests and ajax requests. public class SessionControl : ActionFilterAttribute { public o...
Category theory is a modern mathematical theory and a branch of abstract algebra focused on the nature of connectedness and relation. It is useful for giving solid foundations and common language to many highly reusable programming abstractions. Haskell uses Category theory as inspiration for some o...
SP.SOD.executeOrDelayUntilScriptLoaded(showDialog,"sp.js"); function showDialog(){ var options = SP.UI.$create_DialogOptions(); options.url = "/mySite/lists/myList/NewForm.aspx"; options.dialogReturnValueCallback = myCallBackFunction; SP.UI.ModalDialog.show...
BEGIN TRANSACTION INSERT INTO DeletedEmployees(EmployeeID, DateDeleted, User) (SELECT 123, GetDate(), CURRENT_USER); DELETE FROM Employees WHERE EmployeeID = 123; COMMIT TRANSACTION
Dynamic scoping means that variable lookups occur in the scope where a function is called, not where it is defined. $ x=3 $ func1 () { echo "in func1: $x"; } $ func2 () { local x=9; func1; } $ func2 in func1: 9 $ func1 in func1: 3 In a lexically scoped language, func1 would alway...
Instead of the usual loosely typed: @Html.ActionLink("Log in", "UserController", "LogIn") You can now make action links strongly typed: @Html.ActionLink("Log in", @typeof(UserController), @nameof(UserController.LogIn)) Now if you want to refactor your ...
When something fails in your transaction code and you want to undo it, you can rollback your transaction: BEGIN TRY BEGIN TRANSACTION INSERT INTO Users(ID, Name, Age) VALUES(1, 'Bob', 24) DELETE FROM Users WHERE Name = 'Todd' COMMIT TRANSACTION END TRY...
Classic unit tests test state, but it can be impossible to properly test methods whose behavior depends on other classes through state. We test these methods through interaction tests, which verify that the system under test correctly calls its collaborators. Since the collaborators have their own...
The UIAlertController available since iOS8 allows you to use the same alert object for either Action sheets or more classic alerts. The only difference is the UIAlertControllerStyle passed as a parameter when creating. This line changes from an AlertView to an ActionSheet, compared to some other ex...
Func provides a holder for parameterised anonymous functions. The leading types are the inputs and the last type is always the return value. // square a number. Func<double, double> square = (x) => { return x * x; }; // get the square root. // note how the signature matches the built ...
string urlWebsite = "http://MyServer/sites/MySiteCollection"; ClientContext clientContext = new ClientContext(urlWebsite); Web oWebsite = clientContext.Web; List oList = oWebsite.Lists.GetByTitle("My List"); UserCustomActionCollection collUserCustomAction = oList.UserCustom...
string urlWebsite = "http://MyServer/sites/SiteCollection"; ClientContext clientContext = new ClientContext(urlWebsite); Web oWebsite = clientContext.Web; List oList = oWebsite.Lists.GetByTitle("My List"); UserCustomActionCollection collUserCustomAction = oList.UserCustomAc...
string urlWebsite = "http://MyServer/sites/MySiteCollection"; ClientContext clientContext = new ClientContext(urlWebsite); Web oWebsite = clientContext.Web; UserCustomActionCollection collUserCustomAction = oWebsite.UserCustomActions; UserCustomAction oUserCustomAction = collUserCu...
[HttpPost] public ActionResult ContactUs(ContactUsModel contactObject) { // This line checks to see if the Model is Valid by verifying each Property in the Model meets the data validation rules if(ModelState.IsValid) { } return View(contactObject); } The model class p...
add_action('init', 'process_post'); function process_post(){ if($_POST) var_dump($_POST); }
add_action('init' , function(){ echo 'i did something'; });
class sample{ public function __construct(){ add_action('init', array($this, 'samp') ); } public function samp(){ // must be public!! echo 'i did something'; } } new sample();
class sample{ public static function add_action_func(){ //note __CLASS__ will also include any namespacing add_action('init', array(__CLASS__, 'samp') ); } public static function samp(){ echo 'i did something'; } } sample::add_a...
repeat(10) { i -> println("This line will be printed 10 times") println("We are on the ${i + 1}. loop iteration") }

Page 2 of 8