Tutorial by Examples

Dynamic queries are SET @sql = N'SELECT COUNT(*) FROM AppUsers WHERE Username = ''' + @user + ''' AND Password = ''' + @pass + '''' EXEC(@sql) If value of user variable is myusername'' OR 1=1 -- the following query will be executed: SELECT COUNT(*) FROM AppUsers WHERE Username = 'myusername...
In order to avoid injection and escaping problems, dynamic SQL queries should be executed with parameters, e.g.: SET @sql = N'SELECT COUNT(*) FROM AppUsers WHERE Username = @user AND Password = @pass EXEC sp_executesql @sql, '@user nvarchar(50), @pass nvarchar(50)', @username, @password Second ...
Django's built-in User model is not always appropiate for some kinds of projects. On some sites it might make more sense to use an email address instead of a username for instance. You can override the default User model adding your customized User model to the AUTH_USER_MODEL setting, in your proj...
Your code will not work in projects where you reference the User model (and where the AUTH_USER_MODEL setting has been changed) directly. For example: if you want to create Post model for a blog with a customized User model, you should specify the custom User model like this: from django.conf impo...
jQuery accepts a wide variety of parameters as "selectors", and one of them is an HTML string. Passing an HTML string to jQuery will cause the underlying array-like structure of the jQuery object to hold the resulting constructed HTML. jQuery uses regex to determine if the string being pa...
from scipy.stats import rv_continuous import numpy class Neg_exp(rv_continuous): def _cdf(self, x, lamda): return 1-numpy.exp(-lamda*x) neg_exp = Neg_exp(name="Negative exponential", a=0) print (neg_exp.pdf(0,.5)) print (neg_exp.pdf(5,.5)) print (neg_exp.cdf(5...
There are many reasons a write operation may fail. A frequent one is because your security rules reject the operation, for example because you're not authenticated (by default a database can only be accessed by an authenticated user). You can see these security rule violations in the output of your...
SQL Server 2008 The ROW_NUMBER function can assign an incrementing number to each row in a result set. Combined with a Common Table Expression that uses a BETWEEN operator, it is possible to create 'pages' of result sets. For example: page one containing results 1-10, page two containing results 11...
SQL Server 2012 The OFFSET FETCH clause implements pagination in a more concise manner. With it, it's possible to skip N1 rows (specified in OFFSET) and return the next N2 rows (specified in FETCH): SELECT * FROM sys.objects ORDER BY object_id OFFSET 40 ROWS FETCH NEXT 10 ROWS ONLY The ORDER...
In earlier versions of SQL Server, developers had to use double sorting combined with the TOP keyword to return rows in a page: SELECT TOP 10 * FROM ( SELECT TOP 50 object_id, name, type, create_date FROM sys.objects ORDER BY name ASC ) AS data ...
// It's possible to unpack tuples to assign their inner values to variables let tup = (0, 1, 2); // Unpack the tuple into variables a, b, and c let (a, b, c) = tup; assert_eq!(a, 0); assert_eq!(b, 1); // This works for nested data structures and other complex data types let complex = ((1,...
Writing a gzipped file To write a gzipped file, use the module IO::Compress::Gzip and create a filehandle by creating a new instance of IO::Compress::Gzip for the desired output file: use strict; use warnings; use open qw( :encoding(UTF-8) :std ); # Make UTF-8 default encoding use IO::Compres...
An template can be introduced with template. It can contain functions and classes and other constructs. template StaticArray(Type, size_t Length) { class StaticArray { Type content[Length]; size_t myLength() { return getLength(this); }...
HTML DOM is Expensive Each web page is represented internally as a tree of objects. This representation is called Document Object Model. Moreover, it is a language-neutral interface that allows programming languages (such as JavaScript) to access the HTML elements. In other words The HTML DOM...
Generating the minimum number of operations to transform one tree into another have a complexity in the order of O(n^3) where n is the number of nodes in the tree. React relies on two assumptions to solve this problem in a linear time - O(n) Two components of the same class will generate sim...
When two nodes are not of the same type, React doesn't try to match them - it just removes the first node from the DOM and inserts the second one. This is why the first tip says If you see yourself alternating between two components classes with very similar output, you may want to make it the sa...
There are two equivalent ways to calculate the amount of time unit between two LocalTime: (1) through until(Temporal, TemporalUnit) method and through (2) TemporalUnit.between(Temporal, Temporal). import java.time.LocalTime; import java.time.temporal.ChronoUnit; public class AmountOfTime { ...
Recommended way to install Slim framework is by using composer. Create an empty directory This directory will contain all required files for our Slim application to run. We call this directory root directory so we can address all other application files and directories relative to root directo...
ContactManager contactManager = Factory.CreateObject("tracking/contactManager", true) as ContactManager; Contact contact = contactManager.LoadContactReadOnly(userName); return contact;
This method doesn't require initialization of the tracker, which is handy if the state should be changed outside of the site context (for example in the shell). var stateManager = AutomationStateManager.Create(contact); automationStateManager.MoveToEngagementState(stateItem.ParentID, stateId); st...

Page 933 of 1336