Rage of Demons: Session 2

In the previous session the group escaped from a prison of the drow in the Underdark. Now they were free, but more or less lost in an unfamiliar environment, with neither food nor drink, and limited equipment. And the drows were pursuing them. So apart from a few combat encounters this session was mostly about how to survive and travel in the Underdark.

A tabletop role-playing game always plays on two levels at once: The story level where the warrior chops off the head of the orc, and the game level, where a player rolls some dice. The art of Dungeon-mastering is to balance these two levels and to connect them. By treating travel and survival in the Underdark as a series of dice rolls, with modifiers based on player decisions, the players gain agency over the story. And unexpected dice rolls can add surprise to the story. The Out of the Abyss book, chapter 2, has some very good suggestions on how to handle travel and survival. I just needed to combine that with existing rules in the Player’s Handbook and Dungeon Master’s Guide to a “loop” of rolls to do every day: A roll for navigation in order to avoid becoming lost, a random encounter roll for during the day, another random encounter roll for camp at night, and a roll for foraging.

The trick to make all of that a bit more interesting is the drow pursuit: Players can choose to travel slow, normal speed, or fast. Traveling fast makes them gain more distance from the pursuers, but prevents them from foraging, and increases the difficulty of navigation and perceiving enemies. Traveling slower increases the risk from the pursuit, but makes everything else easier. In this session we played through that loop for 7 game days, which with several days traveled at high speed meant the group went from the drow outpost Velkynvelve to the kuo-toa village of Sloobludop.

To give the group some means of orientation I used the previous encounter of the cleric with Juiblex to give him a level 1 madness which made his face wounds burn whenever he looked in the north-western direction from Velkynvelve (towards Blingdenstone to be exact, for reasons that will become obvious much later). That gave him advantage on navigation rolls, and the group used a second character to help with navigation when they were traveling at fast speed, so they never got lost. After the first day the cleric also switched spells to have Create Water, which solved their thirst problem.

As encounters we first had one attack at night by goblins, which weren’t too hard to beat and provided the ranger of the group with a short bow and arrows. It also turned out that the players weren’t the squeamish kind, and they filleted the goblins, cooked them over magical fire, cast Purify Food & Drink on the meat and ate it. Later in the session they encountered a bunch of gnolls, which are larger than goblins, and thus ended up with more than enough food for their journey (although I ruled that meat wouldn’t keep longer than 2 days, because otherwise the whole foraging thing would become useless).

Then they came to the Silken Paths, an area of spider webs crossing a large chasm, connecting stalagmites and stalactites. Two non-aggressive goblins had created a business guiding people across, and the group agreed to pay them for passage. On the web they found a large chest, which of course turned out to be a mimic (that still works with new players). Then they were attacked by darkmantles, which after killing them they used to make waterskins out of. In fact this group is the first one I see in 5th edition which makes use of crafting skills from their background. Once over the chasm, the group decreased their pursuit level by burning the webs they had crossed, although of course they couldn’t burn the whole giant web.

The gnolls they met in an encounter which was supposed to have them come upon a hunt, with the gnolls chasing a pair of hook horrors. But the group just cast a fog spell to hide from the monsters and then traveled on. Then they came upon the second half of the hunters, and killed them. The group decided to rest there, but of course the first group of hunters came back before they were rested and they had to fight gnolls again.

At the end of the session the group arrived near Sloobludop, and gained level 4 from the xp for survival and the various encounters. Just like in other campaign books of Wizards of the Coast, level increase is at least twice as fast as what you’d get if you just gave out xp for monsters. I decided that was okay, as nobody wants to be low level for too long. I might have to slow that down a bit if I feel that the group is becoming too powerful for a dark themed adventure.

Former CIA Official Suggests Trump Campaign Team May Have ‘Welcomed’ Russian Election Interference

No one bothered to report an obviously relevant Trump Tower meeting.

Former CIA and U.S. Defense Department official Jeremy Bash told MSNBC host Nicolle Wallace that President Donald Trump’s actions after being cautioned by the FBI about Russia raise serious red flags.

Bash specifically noted that the Trump team’s disinterest in informing the FBI about a Trump Tower meeting with Russians following the bureau’s alert is suspicious.

“I think the fact that the campaign, the candidate was warned and that the candidate and the campaign did not then go back to the FBI after the Trump Tower meeting is a huge red flag that, not only were they unconcerned with this Russian overture,  but they welcomed it and in some ways want to conceal it,” he said. 

“To have warned the FBI would have been to expose their own conduct, the campaign’s own conduct, and that is something that Bob Mueller will be very, very interested in.”

Watch the segment below.

 

Related Stories

  • If Trump Fires Mueller, Is a Watergate Rerun Coming?
  • Robert Mueller Has the Trump Team Panicked, No Matter What the President Says
  • Intelligence Analyst Malcolm Nance Compares Fox News Rhetoric to ‘Psychological Warfare’

Robert Reich: American Oligarchs’ Day of Reckoning Is Nigh

The GOP tax bill is a triumph for the 1 percent, but recent election results suggest it won’t last.

 

The Republican tax plan to be voted on this week is likely to pass. “The American people have waited 31 long years to see our broken tax code overhauled,” the leaders of the Koch’s political network insisted in a letter to members of Congress, urging swift approval.

They added that the time had come to put “more money in the pockets of American families.”

Please. The Koch network doesn’t care a fig about the pockets of American families. It cares about the pockets of the Koch network. 

It has poured money into almost every state in an effort to convince Americans that the tax cut will be good for them. Yet most Americans don’t believe it. 

Polls shows only about a third of Americans favor the tax plan. The vast majority feel it’s heavily skewed to the rich and big businesses – which it is.  

In counties that Trump won but Obama carried in 2012, only 17 percent say they expect to pay less in taxes, according to a recent NBC News/Wall Street Journal poll. Another 25 percent say they expected their family would actually pay higher taxes.

Most Americans know that the tax plan is payback for major Republican donors. Gary Cohn, Trump’s lead economic advisor, even conceded in an interview that “the most excited group out there are big CEOs, about our tax plan.”

Republican Rep. Chris Collins admitted “my donors are basically saying, ‘Get it done or don’t ever call me again.’” Senator Lindsey Graham warned that if Republicans failed to pass the tax plan, “the financial contributions will stop.”

By passing it, Republican donors will save billions – paying a lower top tax rate, doubling the amount their heirs can receive tax-free, and treating themselves as “pass-through” businesses able to deduct 20 percent of their income (effectively allowing Trump to cut his tax rate in half, if and when he pays taxes).

They’ll make billions more as their stock portfolios soar because corporate taxes are slashed.

The biggest winners by far will be American oligarchs such as the Koch brothers; Peter Thiel, the Silicon Valley investor; Sheldon Adelson, the Las Vegas casino magnate; Woody Johnson, owner of the New York Jets football team and heir to the Johnson & Johnson fortune; and Carl Icahn, the activist investor.

The oligarchs are the richest of the richest 1 percent. They’ve poured hundreds of millions into the GOP and Trump. Half of all contributions to the first phase of the 2016 election came from just 158 families, along with the companies they own or control.

The giant tax cut has been their core demand from the start. They also want to slash regulations, repeal the Affordable Care Act, and cut everything else government does except for defense – including Medicaid, Medicare, and Social Security.

In return, they have agreed to finance Trump and the GOP, and mount expensive public relations campaigns that magnify their lies.

Trump has fulfilled his end of the bargain. He’s blinded much of his white working-class base to the reality of what’s happening by means of his racist, xenophobic rants and policies. 

The American oligarchs couldn’t care less about what all this will cost America. 

Within their gated estates and private jets, they’re well insulated from the hatefulness and divisiveness, 

They don’t worry about whether Social Security or Medicare will be there for them in their retirement because they’ve put away huge fortunes.

Climate change doesn’t concern them because their estates are fully insured against hurricanes, floods, and wildfires.

They don’t care about public schools because their families don’t attend them. They don’t care about public transportation because they don’t use it. They don’t care about the poor because they don’t see them. 

They don’t worry about the rising budget deficit because they borrow directly from global capital markets. 

Truth to tell, they don’t even care that much about America because their personal and financial interests are global.

They are living in their own separate society, and they want Congress and the President to represent them, not the rest of us.

The Republican Party is their vehicle. Fox News is their voice. Trump is their champion. The new tax plan is their triumph.

But if polls showing most Americans against the tax cut are any guide, that triumph may be short lived. Americans are catching on. 

The recent electoral results in Virginia and Alabama offer further evidence. 

A tidal wave of public loathing is growing across the land – toward Trump, the GOP, and the oligarchs they serve; and to the deception, the wealth, and the power that underlies them.  

That wave could crash in the midterm elections of 2018. If so, the current triumph of the oligarchs will be the start of their undoing.

 

 

 

Related Stories

  • Donald Trump Jr. and Ted Cruz Mock Barack Obama with Bizarre Cookie
  • The One Scenario in Which Trump Would Risk Impeachment and Fire Robert Mueller
  • Sarah Palin’s Son Charged with Burglary and Assault in Domestic Dispute: Report

Working with Microsoft SQL Server


MS SQL Server


What is SQL Server Management Studio?

SQL Server Management Studio (SSMS) is the main administration console for SQL Server.


SSMS enables you to create database objects (such as databases, tables, stored procedures, views etc), view the data within your database, configure user accounts, perform backups, replication, transfer data between databases, and more.

Fig 3 : SSMS Console Window


User Login :


When creating a new user login, the administrator can assign that login to any number of roles and schemas. This will depend on what that particular login is entitled to.


Create a New Login

Step 1 :  Using SQL Server Management Studio, expand the Security option (at the
server level, not at the database level) and right click n Logins.

Step 2 :  Click on New Login.

Step 3 :   Complete the login properties in the General tab by providing a name for the login, choosing the Authentication method (providing a password if you choose SQL Server authentication), and selecting the database to use as a default.

Step 4 :   Click the Server Roles tab if you need to apply any server-wide security privileges.


Step 5 :
Click the User Mapping tab to specify which databases this user account is allowed to    access. By default, the login will be assigned to the Public role, which provides the login with basic access.
 If the login needs more access in one or more databases, it can be assigned to  another role with greater privileges. In this case, select Task Tracker database  and  db_owner role for that database.
Step 6 :  Click OK to create the login.


NOTE :
These roles are database roles and are different to the server roles in the previous tab. Server roles are for administering the SQL Server. Database roles are more limited. They are created within each database and specify what the login can do within that particular database.




Fig : Server Roles

Server Roles :


When we created a SQL Server login, we had the option of assigning the login one or more server roles. Server roles (not to be confused with database roles) are available to manage permissions on a server.


View the server roles in SSMS, from the Object Explorer, expand the Security folder







Database :

A database is a collection of information that is organized so that it can be easily accessed, managed and updated.
Creating a database can be done by running a SQL script or by “point and click”. 


System Databases

When you install SQL Server, the following four databases are created.
1.master
This database stores system level information such as user accounts, configuration settings, and info on all other databases.
2.model
This database is used as a template for all other databases that are created.
3.msdb
The msdb database is used by the SQL Server Agent for configuring alerts and scheduled jobs etc
4.tempdb


This one holds all temporary tables, temporary stored procedures, and any other temporary storage requirements generated by SQL Server.  


Create Database :

Fig 4 : Create DB 
The following steps demonstrate how to create a database in SQL Server 2014 using SQL Server Management Studio.

Step 1 : From the Object Explorer, right click on the Databases folder/icon and select New Database

Step 2 : 
Name your database and click OK:


Database with the Given Name will be created.

NOTE :
The new database is based on the Model database (System Database).
It already contains system functions, system views, system stored procedures, and (hidden) system tables. These are system objects which provide information about the database.


Create Table :

Fig 5 : Create Table
Steps to create a table in a database using SQL Server Management Studio (SSMS).

Step 1 :   Ensuring you have the correct database expanded (in our case, the TaskTracker database), right click on the Tables icon and select Table

Step 2 :   A new table will open in Design view. Fill in Column_name, Datatype & if(Null) checkbox for making column .
  ( for more options such as PRIMARY KEY, is Identity, etc. right click on left pane of  required tuple to add property )

Step 3 :   Save the table by selecting File > Save able_1 or by right-clicking on the Table’s  tab and selecting. 
Save Table_1  from the contextual menu:  





Insert Data :
There are many ways of getting data into your database. 



1.Manually: Type data directly into your table rows.


2.Copy/Paste: Similar to the previous option, but this one is where you copy data from another source, then paste it into a table in your database.

3.Import: You can use the Import and Export Wizard to import data from another source.

4.SQL Scripts: You can run a SQL script that contains all data to insert.

5.Application/Website: Users update the database via an application or website.





1. Manually


We can use the Edit Top 200 Rows option to manually type data directly into the table rows. Manually entering data is OK if you only have a little bit of data to enter.


Steps :
1. In the Object Explorer, right click on the table you wish to open, and select Edit Top 200 Rows:
2.You can now start entering the data directly into your table.


2. Copy/Paste


You could use a similar method to the above by copying from another datasource and pasting into your database table. This is OK for a small number of records but not for a lot of records.


Steps :

1. Select all required records from the datasource

2. In the destination database (i.e. the one you want to populate with data), right-click on the destination table and select Edit Top 200 Rows. 

3. Select an empty row by right-clicking in the left-most column (it’s more of a button to the left of your left-most column that allows you to select the whole row) and select Paste from the contextual menu:


3 (a). Import 
You can import data from another datasource. The end result is similar to the copy/paste method (i.e. data is copied across to the destination database), but importing the data is more flexible and could be more suitable on many occasions.

Steps :
To import data, right-click on the database and select Tasks > Import Data… and follow the Wizard from there.

The SQL Server Import and Export Wizard can copy data to and from any data source for which a managed .NET Framework data provider or a native OLE DB provider is available. These include:
•SQL Server
•Flat files
•Microsoft Office Access
•Microsoft Office Excel


Start the SQL Server Import and Export Wizard to import data from an Excel worksheet to a SQL Server database. Click Next to bypass the welcome screen. On the Choose a Data Source page (Figure 8), configure the following:

Fig 6: Import Wizard


Step 1 : (Data Source)
Choose Microsoft Excel from the drop-down menu.

Step 2 : (Excel File Path )
Specify the path of the Excel file from which you are importing data.

Step 3: (Excel Version)
Choose the Excel version where you created the Excel.

Click Next to go to the Choose a Destination page (Figure 9), and configure the following:



Step 4 : (Data Source)
Choose SQL Server Native Client 11.0 from the drop-down menu.

Step 5 : (Server Name )
Fig 7 : Import Wizard Client

Type the name of the destination database’s SQL Server instance.

Step 6 : (Authentication)
Choose the appropriate authentication mode for the data destination connection.

Step 7 : (Database )
Choose which database to copy the data into.








Fig 8 : Finish Import

Step 8 :
Click the Next button to go to the Save and Run Package page. Here, select the Run immediately option and click the Next button. 

This takes you to the Complete the Wizard page where you can view the choices you made.

Click Finish to run the package.




3 (b). Exporting data  (from a SQL Server DB to a Microsoft Excel worksheet) :

To export data, start the SQL Server Import and Export Wizard. Then, click the Next button to bypass the Welcome Screen. On the Choose a Data Source page configure the following:

Step 1 : (Data Source )
Fig 9 : Export Wizard

 Choose SQL Server Native Client 11. from the drop-downmenu.

Step 2 : ( Server Name)
Type the name of the SQL Server instance that contains the source data.

Step 3 : (Authentication)
Choose authentication mode for the data source connection.

Step 4 : (Database)
 Choose the database that contains the source data.
Click Next to go to the Choose a Destination page (Figure 2). On this page, configure the following:





Fig 10 : Export Wizard Target

Step 5 : (Destination)
Choose Microsoft Excel from the drop-down menu.

Step 6: (Excel File Path)
Type in the Microsoft Excel worksheet operating system path.

Step 7 : (Excel Version)
Select the version of the Microsoft Excel worksheet.





Step 8:
Fig 11 : Finish Export 

Click the Next button to go to Review Data Type Mapping page. 

This is where you’ll see how different data types are mapped between the source and the destination and how any conversions issues will be handled.

Follow the wizard ahead.




4. SQL Scripts :
In many cases, you will find it more efficient to run a SQL script that contains the data you need to insert. You can use the SQL INSERT statement to insert just the data you specify in the statement.

Eg :
USE [Database_Name] 
GO
INSERT INTO Table_Name (column_name1,column_name2,column_name3) VALUES (‘val1’, ‘val2’, ‘val3’)
5. Application / Website


Server databases are the backend data storage for a front-end application. Users of the application are responsible for adding data to the database (as well as editing it). 
The Difference between these scripts and above scripts is, these scripts are dynamic. i.e Parameters are passed dynamically to the database.

T-SQL Scripts :

1. Create Database :
Creates a user defined database which can hold n number of user defined tables.

Syntax :
Create database

Query :
CREATE DATABASE SCTPL


2. Create Table :
Creates a user defined table which can hold n number of column with their respective constraints defined by user.

Syntax :
USE [DatabaseName]
GO
CREATE TABLE table_name
(
column_name1 Datatype,
column_name2 Datatype,
column_name3 Datatype
)

Query :
USE [SCTPL]
GO
CREATE TABLE Testdb
(
PrimaryID  int PRIMARY KEY IDENTITY,
Year  varchar(255)
)

3. Drop Table :
The SQL Server DROP TABLE statement is used to remove a table definition and all data, indexes, triggers, constraints, and permission specifications for that table.

Syntax :
USE [Database_Name]
GO
DROP TABLE table_name

Query :
USE [SCTPL]
GO
DROP TABLETEST


4. Insert Into :

The SQL Server INSERT INTO statement is used to add new rows of data to a table in the database.

Syntax :
USE [Database_Name]
GO
INSERT INTO Table_Name (column_name1,column_name2,column_name3) VALUES(‘val1’, ‘val2’, ‘val3’)

Query :
USE [Database_Name]
GO
INSERT INTO Table_Name (Year, Country, Location)
VALUES (‘1996′,’Nigeria’,’Akwa Ibom’)
4. Select :
SQL Server SELECT statement is used to fetch the data from a database table which returns data in the form of result table. These result tables are called result-sets.
Syntax :
/*For selecting all entries*/
USE [Database_Name]
GO
SELECT * FROM TEST
/*For selecting Specific entries*/
USE [Database_Name]
GO

SELECT column_name1, column_name2 FROM Table_name


Query :
/*For selecting all entries*/
USE [Database_Name]
GO
SELECT * FROM TEST
/*For selecting Specific entries*/
USE [SUVEN]
GO
SELECT Year, Country FROM TEST
5. Update :
The SQL Server UPDATE Query is used to modify the existing records in a table.
You can use WHERE clause with UPDATE query to update selected rows otherwise all the rows would be affected.

Syntax :
/* Type 1 */
Use [Database_Name]
GO
UPDATE table_name SET column1 = value1, column2 = value2…., columnN = value WHERE [condition]
/* Type 2 */
USE [Database_Name]
GO
UPDATE TABLE_NAME
SET COLUMN_NAME = ‘val1′, Column_name =val


Query :
/* Type 1 */
USE [SUVEN]
GO
UPDATE TEST
SET Location = ‘RenamedColumn Akwa-Ibom
WHERE Location = ‘Akwa Ibom
/* Type 2 */
UPDATE CUSTOMERS SET ADDRESS = Pune‘, SALARY = 1000.00



6. Delete :
The SQL Server DELETE Query is used to delete the existing records from a table.
You have to use WHERE clause with DELETE query to delete selected rows, otherwise all the records would be deleted.

Syntax :
/*For selecting specific entries*/
USE [Database_Name]
GO
DELETE FROM table_name WHERE [condition]
/*For selecting all entries*/
DELETE FROM column_name

Query :
/*For selecting specific entries*/
USE [SUVEN]
GO
DELETE FROM TEST
WHERE SALARY = 1000
/*For selecting all entries*/
DELETE FROM Location



Clauses

1. WHERE Clause:

The MS SQL Server WHERE clause is used to specify a condition while fetching the
data from single table or joining with multiple tables.

If the given condition is satisfied, only then it returns a specific value from the table. You will have to use WHERE clause to filter the records and fetch only necessary records.
The WHERE clause is not only used in SELECT statement, but it is also used in

UPDATE, DELETE statement, etc.


Syntax :
SELECT column1, column2, columnN FROM table_name WHERE [condition]

Query:
SELECT name FROM Stud WHERE id=1


2. LIKE  Clause:

The MS SQL Server LIKE clause is used to compare a value to similar values using wildcard operators. There are two wildcards used in conjunction with the LIKE operator 
  1. The percent sign (%)
  2. The underscore (_)
The percent sign represents zero, one, or multiple characters. 
The underscore represents a single number or character. The symbols can be used in combinations.

Syntax:


/* Type 1 */
SELECT *column-list FROM table_name WHERE column LIKE ‘%XXXX%’
/* Type 2 */
SELECT *column-list FROM table_name WHERE column LIKE ‘_XXXX_’

Query:

/* Type 1 */
SELECT name from Stud
WHERE sid LIKE ‘200%’
(Finds any values that start with 200)
/* Type 2 */
SELECT name from Stud
WHERE SALARYLIKE ‘_00_’
Finds any values that have 00 in the second and third positions & is of four characters. 


3. ORDER BY


The MS SQL Server ORDER BY clause is used to sort the data in ascending or descending order, based on one or more columns. Some database sort query results in ascending order by default.


Syntax :

Use DatabaseName
Go
SELECT columnlist FROM table_name [WHERE condition] [ORDER BY column1, column2, .. columnN] [ASC | DESC]

Query :

/*TYPE 1*/
Use SUVEN
Go
SELECT * FROM Stud ORDER BY NAME

/*TYPE 2*/

SELECT * FROM Stud ORDER BY NAME DES

4. GROUP BY Clause :

The SQL Server GROUP BY clause is used in collaboration with the SELECT statement to arrange identical data into groups.

The GROUP BY clause follows the WHERE clause in a SELECT statement and precedes the ORDER BY clause.

Syntax :

UseSUVEN
Go

SELECT column1, column2 FROM table_name WHERE [ conditions ] GROUP BY column1, column2 ORDER BY column1, column2

Query: 

UseSUVEN
Go
SELECT NAME, SUM(SALARY) as [sum of salary] FROM Stud GROUP BY NAME

6. DISTINCT

The MS SQL Server DISTINCT keyword is used in conjunction with SELECT statement to eliminate all the duplicate records and fetching only unique records.


There may be a situation when you have multiple duplicate records in a table. While fetching such records, it makes more sense to fetch only unique records instead of fetching duplicate records.


Syntax :

Use Suven
Go

SELECT DISTINCTcolumn1, column2,…..columnN FROM table_nameWHERE [condition]

Query :
Use SUVEN
Go
SELECT DISTINCT SALARY FROM CUSTOMERS ORDER BY SALARY 


Joins :

The MS SQL Server Joins clause is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each.

MS SQL Server Join Types −

There are different types of joins available in MS SQL Server −

INNER JOIN         −  Returns rows when there is a match in both tables.

LEFT JOIN            −  Returns all rows from the left table, even if there are no matches in the  
                                  right table.

RIGHT JOIN         −  Returns all rows from the right table, even if there are no matches in the 
                                  left  table.

FULL JOIN            −  Returns rows when there is a match in one of the tables.

SELF JOIN             − This is used to join a table to itself as if the table were two tables, 
                                 temporarily renaming at least one table in the MS SQL Server statement.

CARTESIAN JOIN − Returns the Cartesian product of the sets of records from the two or 
                                  more joined tables.

NOTE :

The join is performed in the WHERE clause. Several operators can be used to join tables, such as =, <, >, <>, <=, >=, !=, BETWEEN, LIKE, and NOT; they can all be used to join tables. However, the most common operator is the equal symbol.


Query Designer :

The query designer is a graphical user interface that assists in building queries for your SQL Server database. This can be particularly useful when building complex queries that involves many tables, views etc.

The Query Designer can also be beneficial for those who are learning how to write SQL. By using the Query Designer to generate the SQL, you can study the SQL and learn the syntax as you go.

Step 1 :  Open a new query by clicking New Query on the toolbar


Step 2 :  Open the Query Designer by selecting Query > Design Query in Editor. from the top menu:

Step 3 : Select the tables you want to run the query against (in this case, we will add both tables), click Add, and close the box by clicking Close:


Step 4 :  
Select the column/s you want to display in your query by checking the checkbox next to the column name. In the middle pane, you can deselect an Output checkbox to hide that field from being displayed when the query is run (but the field will still be involved in the query).

 Add a value under Filter to narrow the results down to only those you’re interested in (in this example, it is creating a WHERE clause to select only those records with a StatusId of “1” – which is “To Do”):

Step 5 :
Click OK once you’re happy with your query. Query will be automatically  Generated by query designer. Execute it using f5 key.


Views :

In SQL Server, a view is a pre-written query that is stored on the database. A view consists of a SELECT statement, and when you run the view, you see the results of it like you would when opening a table. 

Some people like to think of a view as a virtual table. This is because a view can pull together data from multiple tables, as well as aggregate data, and present it as though it is a single table.
Syntax :

CREATE VIEW ViewName AS
SELECT …

Query :

CREATE VIEW ToDoList AS
SELECT  Tasks.TaskName, Tasks.Description
FROM  Status INNER JOIN
Tasks ON
Status.StatusId = Tasks.StatusId
WHERE  (Status.StatusId = 1)
NOTE : Tasks & Status are two different Tables in a single database.


To execute a View  : 

Syntax : select * from View_name


NOTE :
The view will return upto date data. If the data in the table changes, the results of the view will change too. So if you were to add a new task with a status of “To Do”, next time you run the view, it will include the new record in the result set.


Stored Procedures :

A stored procedure will typically contain some business logic. For example, a stored procedure can accept parameters that are passed to it and test against those parameters using IF statements. Eg, if the parameter is one value, do this, if it’s another value, do that.

Benefits of Stored Procedures :

1. Modular programming
You can write a stored procedure once, then call it again and again, from different parts of an application (and even from multiple applications).

2. Performance
Stored procedures provide faster code execution and reduce network traffic.

3. Security
Users can execute a stored procedure without needing to execute any of the statements directly. Therefore, a stored procedure can provide advanced database functionality for users who wouldn’t normally have access to these tasks, but this functionality is made available in a tightly controlled way.

Create a Stored Procedure :

To create a stored procedure, you need to use the CREATE PROCEDURE statement, followed by the code that makes up the stored procedure. If your stored procedure is going to accept parameters, they need to be included after the name.

Syntax :

CREATE PROCEDURE myStoredProcedure AS
OR
CREATE PROCEDURE myStoredProcedure @{Parameter Name} {data type} AS

Query :

CREATE PROCEDURE
LatestTasks @Count int
AS
SET ROWCOUNT @Count
SELECT TaskName AS LatestTasks, DateCreated
FROM Tasks

ORDER BY DateCreated DESC


Execute a Stored Procedure

1. T-Sql Script :

Now that you’ve created your stored procedure, any time you want to execute it, you need to call it using either EXECUTE or EXEC. If the stored procedure requires parameters you provide those after the procedure name. 


Syntax :
EXECUTE LatestTasks
EXEC LatestTasks
OR
EXEC LatestTasks @Count = 5





2. Using The GUI

Step 1 : Using the Object Explorer, navigate to the stored procedure.

Step 2 : Right click on the stored procedure and select Execute Stored Procedure.

Step 3 : A dialog will appear. Enter your parameter values.

Step 4 : Click OK. SQL Server will generate the SQL code and execute the stored 




System Stored Procedures :

SQL Server includes a large number of system stored procedures to assist in database administration tasks. Many of the tasks you can perform via the GUI can be done via a system stored procedure. For example, some of the things you can do with system stored procedures include:
  • Configure security accounts
  • Set up linked servers
  • Create a database maintenance plan
  • Create full text search catalogs
  • Add remote login
  • Configure replication
  • Set up scheduled jobs
  • and much more…
NOTE :
System Stored Procedure has a prefix sp_ as naming convention.
It is a good idea to develop a consistent naming convention for your stored procedures, like usp_,  select_ , etc.

Don’t want to battle for Azeroth

World of Warcraft announced a 7th expansion called Battle for Azeroth. At this point in time I don’t feel any interest in that expansion. If it came out today, I wouldn’t buy it. As it is coming out in a year, there is still time for me to change my mind. But there is a greater than zero probability that this will be the first World of Warcraft expansion I’m opting out of.

Best GPS running watches (December 2017)

There are plenty of great fitness trackers on the market right now, each of which cater to different users with different needs. Just need to keep an eye on your daily activity levels? Maybe the Fitbit Charge 2 or Garmin vívosport will suit your needs. Looking for something even cheaper than that? Garmin’s vívofit 3 or Xiaomi’s Mi Band 2 might do the trick. But if you’re a more serious athlete that needs something a bit more powerful—something that can track your long runs and not skimp on the handy watch features—what are your options? Today, we’re going to walk you through our list of the best GPS running watches on the market.

Related: The best fitness trackers | Which Fitbit is right for you?

If you’re a serious runner and need something that will accurately track your routes, has a big, easy-to-read screen, a built-in heart rate monitor, and of course, a GPS, this list is for you. Some of the options on here are a bit pricey, but that’s par for the course in this segment of wearables.

Without any further delay, let’s get started!

Editor’s Note: We will update this list as more devices hit the market.

Best GPS running watch

Garmin fenix 5

Garmin’s fenix 5 lineup is finally here, and these are the best GPS running watches on the market right now.

All three fenix 5 models come with preloaded multisport functionality for running, hiking, swimming, biking, and more. They all feature Garmin’s impressive Elevate heart rate trackers, built-in GPS (of course), water resistance up to 100 meters, as well as navigation features with a 3-axis compass, gyroscope, and barometric altimeter.

They all also feature a variety of connected features that make these devices true smartwatches. Users can get call, text and email smartphone notifications. All Sapphire models are also Wi-Fi enabled, so users will be able to connect with their home network and upload statistics even if their smartphones aren’t around.

Not crazy about the regular fenix 5? The smaller fenix 5S might be for you. It has all the same specs as the fenix 5, though it’s built for people with smaller wrists and has a slightly smaller battery. Looking for something even more beefy than the fenix 5? The fenix 5X is much larger and comes with preloaded with TOPO U.S. mapping, routable cycling maps and other navigation features like Round Trip Run and Round Trip Ride. The 5X will even display guidance cues for upcoming turns.

Read more

  • Garmin fenix 5 review
  • Wrists-on with Garmin’s new fenix 5 line at CES 2017
Buy now from Amazon
Buy now from Garmin

Runner-up

Garmin vívoactive 3

best fitness trackers

Garmin’s vívoactive 3 is a huge step up from its predecessor, the vívoactive HR.

For starters, the vívoactive 3 actually looks like a watch this time around, and it will look nice on your wrist whether you’re at the gym or the office. It’s comfortable too, and has a bright, colorful touchscreen display.

There are a total of 15 activity tracking profiles built in, so most athletes will be covered here. It also has a super accurate GPS and heart rate monitor, a battery that will last around five days on a single charge, and plenty of great smartwatch features built in.

If you don’t mind spending close to $249 on a GPS running watch, you should definitely consider the vívoactive 3.

Read more

  • Garmin vívoactive 3 review
Buy now from Amazon

Honorable mention

TomTom Spark 3 Cardio + Music

TomTom’s Spark 3 Cardio + Music is a great option if you aren’t interested in the Garmin vívoactive HR.

It has everything you need in a GPS running watch – an accurate heart rate monitor, a built-in GPS (of course) and support for a ton of different running applications. Plus, this model comes with a Route Exploration feature that not only lets you track where you’ve run, but also lets you get routes from any website and upload them to your watch if you’re interested in trying out a new route.

It’s worth noting there are a few different models in the Spark 3 lineup: the TomTom Spark 3, Spark 3 Music, Spark 3 Cardio and our pick, the Spark 3 Cardio + Music. Though less expensive, the Spark 3 and Spark 3 Music unfortunately don’t offer a heart rate monitor. The Spark 3 Cardio certainly offers a lot for the money, though we believe the onboard music storage and pair of Bluetooth headphones that come with the Spark 3 Cardio + Music provide a better value overall. The Cardio + Music model only costs $60 more.

Buy now from Amazon
Buy now from TomTom

Also read: The dark side of fitness trackers: how to avoid common mistakes that could hurt your fitness goals

Best budget GPS running watch

Polar M200

If you’re on a budget, you can’t go wrong with the Polar M200.

This is a waterproof running watch with a built-in heart rate sensor and GPS that will track your speed, distance and route during a run, and will also keep tabs on your daily activity, steps, calories burned, sleep time and quality. This is also a sleek-looking device. In our opinion, it’s much better looking than its predecessor, the Polar M400.

Plus, this device also comes with Polar’s Running Index, which will show you how your running performance is improving overtime. In the Polar Flow app, you’ll get a Running Index score that’s automatically calculated after every run, based on your heart rate and speed data.

Buy now from Amazon
Buy now from Polar

Best smartwatch for running

Polar M600

See more Polar M600 photos

Polar’s M600 sport watch is by far the best GPS running smartwatch on the market.

With a built-in GPS, IPX8 water resistance rating, optical heart rate monitor and 4GB of on-board storage, the M600 is quite the feature-packed watch. It also comes with support for Polar’s wonderful Flow app, allowing you to track just about any activity you can think of – rowing, skiing, hiking and much more. You’ll also be able to squeeze about two days of battery life out of this thing, which is impressive for an Android Wear watch.

You can certainly find Android Wear devices for less than the $300 asking price, but the M600 provides much more than other devices.

Read more

  • Polar M600 review
  • Polar M600 specs, price release date and everything else you should know
Buy now from Amazon
Buy now from Polar

So there you have it – our list of the best GPS running watches on the market! Did we miss anything? Let us know your thoughts in the comments below!

Next: How to use your fitness tracker to actually get fit – a comprehensive guide

Are You Suffering from Selfitis?

A new study has identified the taking of too many selfies as an actual illness. But how do you know if you’ve got it?

Name: Selfitis.

Age:Three years old.

Appearance: Chin up, lips out, zero attention span.

This sounds like it might be an illness. Correct, it absolutely is. A joint study by Nottingham Trent University and Thiagarajar School of Management has proved it beyond all doubt.

But what is it?A condition that causes people to post too many selfies on the internet.

I mean, that hardly sounds like cholera. But it might be just as dangerous. Did you know that 36 people have genuinely died from taking selfies this year alone? Some fell in rivers and drowned, others were hit by trains. One was trampled by an elephant.

What does that have to do with selfitis? Maybe if these people had spent less time taking selfies and more time looking around for rampaging elephants, they would still be with us.

Now I’m scared. Give it to me straight: do I have selfitis? I’m pleased you asked. The study has developed the Selfitis Behaviour Scale to help diagnose those who think they might suffer from selfitis. All you have to do is assign the following statements with a value between one and five.

OK, shoot. “I feel more popular when I post my selfies on social media.”

Five. “By posting selfies, I expect my friends to appraise me.”

Five. “When I don’t take selfies, I feel detached from my peer group.” “Taking different selfie poses helps increase my social status.” “I use photo-editing tools to enhance my selfie to look better than others.”

Five five five. Oh boy, sounds like you might just be a chronic case.

What does that mean? According to the research, it means that you’re likely to balance low self-confidence with obsessive attention-seeking, and you hope that by compulsively detailing the minutiae of your life online, you will somehow feel like part of a larger group that doesn’t necessarily exist.

Well duh.Yeah, I know, me too.

Is there any treatment available? Not yet, but I suppose we could just put our phones down for a second and experience the real world in the moment. Ha, no, just kidding.

Do say:“I can’t come to work today. As you can see on Instagram, I’m suffering from a nasty bout of selfitis.”

Don’t say: “Finally, proof that anyone who owns a selfie stick is unwell.”

 

Related Stories

  • Uber Stole Trade Secrets, Bribed Foreign Officials and Spied on Rivals, Filing Says
  • Dustin Hoffman Faces Disturbing New Allegations of Sexual Misconduct
  • Trump Is a Master Game-Changer, but Not the Kind You May Think

Not Just Inauguration Protesters: Medics, Observers and a Journalist Face 50 Years in Prison

The prosecution somehow saw medics’ bringing of first aid gear to the January 20 protest as being “prepared for war” and “aiding and abetting the riot.”

Final arguments are underway today in Washington, D.C., in a case that could shape the future of free speech and the right to protest in the United States: the first trial of the nearly 200 people arrested during President Donald Trump’s inauguration. As demonstrators, journalists and observers gathered in Northwest D.C. after the inauguration on January 20, some separated from the group and vandalized nearby businesses and vehicles. Police officers then swept hundreds of people in the vicinity into a blockaded corner in a process known as “kettling,” where they carried out mass arrests of everyone in the area. The first so-called J20 trial could go to a jury as early as today, and involves six people, including one journalist, Alexei Wood, a freelance photojournalist. The defendants face multiple felony and misdemeanor charges, including multiple counts of destruction of property. Evidence against the defendants has been scant. We get an update from Jude Ortiz, a member of the organizing crew of Defend J20 and the Mass Defense Committee chair for the National Lawyers Guild. He’s been in court throughout the first J20 trial.

Transcript

This is a rush transcript. Copy may not be in its final form.

AMY GOODMAN: We begin today’s show with an update on a case that could shape the future of free speech and the right to protest in the United States. Final arguments are underway today in Washington, D.C., for the first trial of the nearly 200 people arrested during President Trump’s inauguration. As demonstrators, journalists and observers gathered in Northwest D.C. after the inauguration, on January 20th, some separated from the group and broke windows of nearby businesses and damaged cars. Police officers then swept hundreds of people in the vicinity into a blockaded corner in a process known as “kettling,” where they carried out mass arrests of everyone in the area.

The first so-called J20 trial could go to a jury as early as today, and involves six people, including one journalist, Alexei Wood, a freelance photojournalist. The defendants face multiple felony and misdemeanor charges, including multiple counts of destruction of property. Evidence against the defendants has been scant from the moment of their arrest. Earlier this week, Superior Court Judge Lynn Leibovitz threw out the felony charge of inciting a riot for the six people on trial now, meaning they now face up to 50 years in prison instead of up to 60.

This comes as police conduct on Inauguration Day has come under scrutiny by the ACLU, and the chief detective in this case is a police union official who tweeted that police showed great restraint during the inauguration.

Well, for more, we go to Washington, D.C. We’re joined by Jude Ortiz, a member of the organizing crew of Defend J20 and the Mass Defense Committee chair for National Lawyers Guild. He’s been in court throughout this first J20 trial.

Jude, welcome back to Democracy Now! Explain what has happened so far and the significance of the judge throwing out the charge.

JUDE ORTIZ: Right. Thank you so much for having me on again.

So, since I was on last, the prosecutor has rested their entire case with all the so-called evidence against the defendants, and then the defense has also put on their witnesses to—like as part of their right to have witnesses come and testify on their behalf. That process for the defense was very short, about only about half a day in court. And then, now it’s into the like final arguments stage. So the prosecutors had their argument first, and then each of the defense attorneys for the defendants are putting on their arguments. This morning at 9:30, there will be the final two defendants, will have their closing arguments, and then the prosecutor will do a rebuttal. Then there will be some more kind of like legal housekeeping to do, before it goes to the jury.

So, the judge throwing out the inciting a riot charge was a huge development in the case. It’s something that after the prosecutor rests their case, defense attorneys will almost always file a motion to have the charges dismissed. In D.C., it’s called a motion for judgment of acquittal. And it’s a formality, for the most part. It’s rarely ever successful. So it was really notable that one of the most significant charges against the defendants, not only in this trial bloc, but also in the case as a whole, was found, in this case, at least, to have no evidentiary basis at all. So, basically, the judge said that the state did not meet the burden of proof, and that charge therefore was dismissed, and the jury will not have to deliberate on that one at all.

AMY GOODMAN: So, but explain what that means, because we’re talking about numerous cases that will follow this one. Does this judge preside over all of these cases if the inciting to riot remains in the other cases?

JUDE ORTIZ: At this point, the judge is assigned to all the other cases. It’s important to note that there’s another case that is scheduled for this coming Monday for seven defendants, but that one probably will not be happening on Monday, because the jury will still be deliberating on this case. So, it’s unclear when the second trial will begin. It’s looking like it might be in January. And then, on March 5th of next year, all the way through October of next year, are all the remaining trials. And starting in May, there’s a trial scheduled for every single week. But the judge has indicated that her rotation, her job assignment, is switching from criminal court to family court as of January 2nd, so there will be a new judge or judges beginning in 2018.

AMY GOODMAN: Why do you see this case as so significant for free speech in the United States?

JUDE ORTIZ: So, on January 20th, the police rounded up everyone who they can get a hold of in this vicinity. The police commander who testified at the beginning of the trial, or towards the beginning of trial, was very clear, both in his testimony as well as recordings from the police radio, that they were interested in the protest—it was an anti-fascist, anti-capitalist march—and they responded to that kind of preemptively by having around a hundred riot cops and their like lieutenants and sergeants, whatnot, there at Logan Circle, where the protest was scheduled to depart from and begin. And that commander said that rather than doing what is typical in D.C., where they do rolling road closures to facilitate the exercise of free speech, instead they showed up with numerous vans full of riot police, and then they followed the march and began, pretty much immediately, to start to crack down on the march. That commander repeatedly used the word “anarchist” to describe everybody who was there. And that officer—or, that commander and other officers talked about everybody being like one group with nefarious intent.

So, from the outset, because of the alleged politics of the march and of the people who were there, the police responded in this very heavy-handed manner that culminated in them rounding everybody up and mass-arresting people. And the prosecutor has continued that by going forward with these charges against everyone. So, when that is the kind of method of operations, for the police going hand in hand with the prosecutor, that sends a very chilling message to anybody who’s interested in going out in the streets and voicing dissent, especially dissent to Trump, dissent to the rise of fascism, dissent to white supremacy, heteropatriarchy, like all these other like very devastating systems of oppression.

AMY GOODMAN: Jude, Assistant U.S. Attorney Qureshi, the second-ranking prosecutor, who made closing arguments, said, in those arguments, a street medic was guilty by being present, and asked, “What do you need a medic with gauze for? She was aiding and abetting the riot. That was her role,” Qureshi said. Respond to that.

JUDE ORTIZ: So, that’s an entirely ludicrous claim. Medics have been at protests across the country for decades to be able to provide first aid type of care to people who are injured in various ways. One of the most notable ways people get injured at protests, as your listeners and viewers know, is by actions from the police. On January 20th, there was a massive amount of pepper spray deployed by police on people, sometimes directly in the face, sometimes on the side or from behind. And we saw this in trial through body cam—body-worn camera videos. There’s also a lot of body-worn camera videos of police knocking people down from behind with their batons. One of the officers who testified ran his bike directly into a protester. And so, there’s all these different ways that the people who are out there like in the streets can get injured very easily. There’s also the elements to deal with. In January, it was very cold, for the January 20th inauguration protest. Lots of different reasons why you’d have medics there in order to like render aid to people who get injured.

That prosecutor said that the supplies that were there kind of show that the medics, in general, were kind of like prepared for war, which is a—it’s as insulting as it is ludicrous to say that people who were out there in the streets were prepared for war, especially when you saw the Department of Homeland Security helicopter video showing all the police operations that were happening there on Inauguration Day, how the police took this like paramilitary approach, that was also supported by the National Guard in order to like corral people and use chemical and projectile weapons against people. So, if there was any kind of warlike conditions, that was coming from the police and from the government, and not from people who were there to render aid.

AMY GOODMAN: I want to ask you about some of the videos submitted as evidence in this case by federal prosecutors. This includes video by the Canadian YouTuber Lauren Southern, who the Southern Poverty Law Center describes as, quote, “tiptoe[ing] at the precipice of outright white nationalism.” Southern was there on January 20th, Inauguration Day, and was kettled during the protest, but was allowed to leave without being arrested. Prosecutors also submitted video evidence from the right-wing militia group Oath Keepers, who infiltrated protest planning meetings and secretly recorded them. Prosecutors also presented video from the discredited far-right group Project Veritas, just one day after The Washington Post reported Project Veritas had tried to dupe them with a false story of sexual misconduct by a woman undercover pretending to be a victim of Roy Moore. Go into this and why this matters, Jude Ortiz.

JUDE ORTIZ: It’s appalling to see so much of the state’s—the prosecution’s case and their so-called like evidence coming from overtly far-right sources. So, the Project Veritas video that you mention, it did come out in the courtroom as like a main piece of evidence, exactly like one day after that story broke. And one would think that that would kind of discredit or like cast into doubt like the kind of truthfulness or the usefulness of that evidence. The prosecutor and the police officer who was testifying about it gave no indication that the source of it was at all even a question mark or some cause of concern. The state, through various witnesses, the detectives who like testified about the video and whatnot, admitted that they did no kind of forensic investigation or examination of the tape to make sure that it wasn’t doctored in some way. Project Veritas, of course, is notorious for doctoring in the editing of their videos. And they were presented to the jury as one of their main pieces of evidence, and especially with the idea of conspiracy.

And so, when so much of the so-called evidence against these defendants and the defendants at large depends on this kind of so-called like investigative work of far-right actors, it really shows how the state itself, but with their police investigators, undercover cops infiltrating political protest planning meetings, the undercover and plainclothes police who were present on the march and like in the streets that day—all of these different like state actors were not able to find the evidence that would substantiate the charges the prosecutor has been so ferociously pursuing, and so they have to supplement that and really kind of create the evidentiary base through drawing on the far right.

AMY GOODMAN: I wanted to ask you about the main detective working full time on the J20 case, Greggory Pemberton. On Inauguration Day, January 20th, he tweeted D.C. police officers used a, quote, “inspiring amount of restraint” and showed “professionalism.” Last November, he also tweeted about, quote, “disingenuous ‘activists’ who peddle lies and falsehood.” During the J20 trial, defense lawyers played this clip of an interview Pemberton gave to the far-right media outlet One America News Network, praising President Trump.

GREGGORY PEMBERTON: He certainly has a message of law and order, and he really is appealing to a lot of police officers. … Police officers want to hear that someone is going to come in and not allow this divisive, vitriolic rhetoric of this false narrative that all police officers are inherently criminal racists that are out here committing crimes against the citizens, and that they’re going to come in and put a stop to that.

AMY GOODMAN: Jude Ortiz, as we wrap up, can you respond to the significance of his involvement with the case and what he’s saying here?

JUDE ORTIZ: Yes. The detective, Pemberton, has claimed that he has looked through hundreds of hours of videos, hundreds of times, since January 21st. It’s been his full-time job, his only assignment. He was able, through that review, to present various compilation boards of photographs, as well as videos and PowerPoints, to give to the jury for their deliberations, that claims to have documentation of the location of each of the defendants all throughout the march, and presenting this as if that’s something that, like, being present like in the streets is a sign of guilt and is evidence of guilt of all these charges.

So it’s a tremendous amount of work that is like put in for these like very politically motivated way—or, reasons. And those political motivations are pretty clear when you look at his Twitter feed, with all of the far-right and pro-Trump things that he has promoted, like through retweets and through likes and through his own comments on Twitter. He claimed on the stand that that was only in the kind of exercise of his position as a board member of the police union. But whether that’s true or whether it’s his own personal opinions, those opinions that are put forward are very much in favor of like right-wing causes and very much against liberal or progressive, like radical-left causes and movements. And he’s even done very inflammatory and insulting things, like saying “black lies matter”—L-I-E-S—instead of “Black Lives Matter,” and discounting that entire movement, that has been so prominent in responding to police violence and brutality across the country.

AMY GOODMAN: Finally, shortly after winning the 2016 presidential election, Donald Trump tweeted his thoughts on dissent. He tweeted, “Nobody should be allowed to burn the American flag–if they do, there must be consequences–perhaps loss of citizenship or year in jail!” Your final comment, Jude Ortiz?

JUDE ORTIZ: I think comments like that show the kind of concerted effort and nature of repression of social movements in the United States. I want to clarify that: I mean like left social movements. The right social movements, that have become more prominent and public under Trump, have been facilitated by the state. We’re seeing that in places like Charlottesville. We’re seeing that in places like St. Louis and all across the country. People need to recognize like how things are shifting, and be ready to be out in resistance, to dissent and to not be scared away. And this case is a very important part of that.

AMY GOODMAN: Jude Ortiz, I want to thank you for being with us, member of the organizing crew of Defend J20 and the Mass Defense Committee chair for the National Lawyers Guild. He’s been in court throughout this first J20 trial. And we’ll keep you updated on this and other trials as they go on.

 

Related Stories

  • Trials Begin for 200 Anti-Trump Protesters and Journalists Who Were Arrested en Masse
  • The FCC Just Voted to End the Internet as We Know It—Now What?
  • Doug Jones Would Have Won by Tens of Thousands More Votes If Participation Hadn’t Been Blocked and Undermined

10 JavaScript Methods For DOM Manipulation for Web Developers : JavaScript

JS logo
To Specify the logical structure of the web pages, we web developers need to manipulate the DOM of the web page. Using this structure we could render HTML elements on the web page. 
HTML defines the DOM structure. But in many cases we need to disturb this DOM structure to get the required output. We can JavaScript to manipulate this DOM structure.to add more functionalities to it.
HTML DOM structure
HTML DOM STRUCTURE
Here are some functions using which you can manipulate the HTML DOM structure.

< 1 > querySelectore()

The querySelecor() methods returns the first element that matches with the mentioned name. If no match found it returns null.
Although getElementById() is a useful method, querySelector() and querySelectorAll() methods are used to target element based on any CSS selector freely which makes it more flexible.

Syntax:

var ele = document.querySelector(selector);

  • ele – First matching element or null (if no element matches the selectors)
  • selector – one or more CSS selectors,  such as #fooid, .fooClassName, .Class1.Class2, or .class1, .class2

Code Example:

In this example, first < Div > gets selected with the querySelector() and its colour gets changed. Test the querySelector() method in the following interactive demo. Just type a selector matching the ones you can find inside the blue boxes (e.g. #three ) and click the select button. Note that if you type .block then only first element will get selected.

See the Pen &amp;amp;amp;amp;amp;amp;amp;lt;a href=’https://codepen.io/kjuvekar/pen/MobqMP/’&amp;amp;amp;amp;amp;amp;amp;gt;MobqMP&amp;amp;amp;amp;amp;amp;amp;lt;/a&amp;amp;amp;amp;amp;amp;amp;gt; by kalpesh juvekar (&amp;amp;amp;amp;amp;amp;amp;lt;a href=’https://codepen.io/kjuvekar’&amp;amp;amp;amp;amp;amp;amp;gt;@kjuvekar&amp;amp;amp;amp;amp;amp;amp;lt;/a&amp;amp;amp;amp;amp;amp;amp;gt;) on &amp;amp;amp;amp;amp;amp;amp;lt;a href=’https://codepen.io’&amp;amp;amp;amp;amp;amp;amp;gt;CodePen&amp;amp;amp;amp;amp;amp;amp;lt;/a&amp;amp;amp;amp;amp;amp;amp;gt;.&amp;amp;amp;amp;amp;amp;amp;lt;br /&amp;amp;amp;amp;amp;amp;amp;gt;

< 2 > querySelectorAll()

Unlike querySelector() that returns only the first instance of all matching elements, querySelectorAll() returns all elements that match. those elements are returned as NodeList object that will be an empty object is no matching elements are found.

Syntax:

var eles = document.querySelectorAll(selector);

  • eles  – A NodeList object with all matching elements as property values. 

Code Example:

HTML:

<p>paragraph one</p>
<p>paragraph two</p>
<div>div one</div>
<p>paragraph three</p>
<div>div two</div>

JavaScript:

var paragraphs = document.querySelectorAll(‘p‘);for(
for(var p of paragraphs)p.style.color = ‘
p.style.color = ‘blue‘;

 < 3 > addEventListener()

Events refer to what happens to an HTML element, such as clicking, focusing, or loading, to which we can react with JavaScript. We can assign JS functions to listen for these events in elements and do something when the event had occurred.
There are three ways you can assign a function to a certain event.
If foo() is a custom function, you can register it as a click event listener (call it when the button element is clicked) in three ways:

HTML

           <button onclick=foo>Alert</button>

JavaScript

           var btn = document.querySelector(‘button‘);
           btn.onclick=foo;

JavaScript

           var btn = document.querySelector(‘button‘);
           btn.addEventListener(‘click‘, foo);

Syntax:

ele.removeEventListener(evtlistener, [options]);
  • evt – The targeted event. 
  • listener – Typically, a JavaScript function.
  • option – (Optional) An object with a set of Boolean properties.

Code Example:

Assign the foo() custom function as an event listener to any of the following events: input, click or mouseover  & trigger the chosen event in the bottom input field by hovering, clicking or typing in it. 

See the Pen &amp;amp;amp;amp;lt;a href=’https://codepen.io/kjuvekar/pen/jwVeoo/’&amp;amp;amp;amp;gt;add event listner&amp;amp;amp;amp;lt;/a&amp;amp;amp;amp;gt; by kalpesh juvekar (&amp;amp;amp;amp;lt;a href=’https://codepen.io/kjuvekar’&amp;amp;amp;amp;gt;@kjuvekar&amp;amp;amp;amp;lt;/a&amp;amp;amp;amp;gt;) on &amp;amp;amp;amp;lt;a href=’https://codepen.io’&amp;amp;amp;amp;gt;CodePen&amp;amp;amp;amp;lt;/a&amp;amp;amp;amp;gt;.&amp;amp;amp;amp;lt;br /&amp;amp;amp;amp;gt;

< 4 > removeEventListener()

The removeEventListener() method detaches an event listener previously added with the addEventListener() method from the event it is listening for.

Syntax

ele.removeEventListener(evt, listener, [options]);

Code Example:

Following the Code Example we used at addEventListener(), here we remove the click event listener called foo from the <button&gt; element.

JavaScript

btn.removeEventListener(‘click‘,foo);

< 5 > createElement()

The createElement() method creates a new HTML element using the name of the HTML tag to be created, such as ‘p‘ or ‘div‘.
You can later add this element to the web page by using different methods for DOM insertion, such as AppendChild().

Syntax

document.createElement(tagName);

  • tagName – The name of the HTML tag you want to create.

Code Example:

To create a new paragraph element:
var pEle = document.createElement(‘p‘);

 < 6 > appendChild()

The appendChild() method adds an element as the last child to the HTML element that invokes this method.
The child to be inserted can be either a newly created element, or an already existing one. In the latter case, it will be moved from its previous position to the position of the last child.

Syntax:

ele.appendChild(childEle);

  • childEle – The HTML element added as the last child of ele.

Code Example:

Letters from #a to #r are the child elements of the #parent-one, #parent-two, and #parent-three id selectors.
Check out how the appendChild() method works by typing one parent and one child selector name into the input fields below. You can choose children belonging to another parent as well.

See the Pen &amp;lt;a href=’https://codepen.io/kjuvekar/pen/BZQvpK/’&amp;gt;appendChild()&amp;lt;/a&amp;gt; by kalpesh juvekar (&amp;lt;a href=’https://codepen.io/kjuvekar’&amp;gt;@kjuvekar&amp;lt;/a&amp;gt;) on &amp;lt;a href=’https://codepen.io’&amp;gt;CodePen&amp;lt;/a&amp;gt;.&amp;lt;br /&amp;gt;

< 7 > removeChild() 

The removeChild() method removes a specified child element from the HTML element that calls this method.

Syntax:

ele.removeChild(childEle);

  • childEle – The child element of ele.

Code Example:

Here we remove the <strong> element we added as a child to the <div> tag at the Code Example for the previous appendChild() method.
div.removeChild(strong);

< 8 > replaceChild()

The replaceChild() method replaces a child element with another one belonging to the parent element that calls this method.

Syntax:

ele.replaceChild(newChildEle, oldChileEle)

  • newChildEle – Child element of ele that will replace oldChildEle.
  • oldChildEle – Child element of ele, that will be replaced by newChildEle.

Code Example:

Here the child element <strong> belonging to the <div> parent element is replaced with a newly created <em> tag.

HTML

<div>
<strong>hello</strong>
</div>

JavaScript

var em = document.createElement(‘em‘);
var strong = document.querySelector(‘strong‘);
var div = document.querySelector(‘div‘);
em.textContent = ‘hi‘;
div.replaceChild(em, strong);

< 9 > setAttribute()

The setAttribute() method either adds a new attribute to an HTML element, or updates the value of an attribute that already exists.

Syntax:

ele.setAttribute(name, value);

  • name – The name of the attribute.
  • value – The value of the attribute.

Code Example:

Here we add the contenteditable attribute to a <div> by making use of the setAttribute() method, which will turn its content editable.

HTML

<div>hello</div>

JavaScript

var div = document.querySelector(‘div‘);
div.setAttribute(‘
contenteditable‘, ”)

< 10 > getAttribute()

The getAttribute() method returns the value of a specified attribute belonging to a certain HTML element.

Syntax:

ele.getAttribute(name);

  • name – The name of the attribute.

Code Example:

Here we alert the value of the contenteditable attribute belonging to the <div> element with the help of the getAttribute() method.

HTML

<div contenteditable=true>hello</div>

JavaScript

var div = document.querySelector(‘div‘);

alert(div.getAttribute(‘contenteditable‘));

Learn Web Technology!

Some cool things you can do with Python: pyThOn – fastEst Growing LaNgUage

python logo


Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.

Python interpreters are available for many operating systems, allowing Python code to run on a wide variety of systems.
So what are some of the cool things you can do with Python?

1. Python Web Development

python web development


Web development is the umbrella term for conceptualizing, creating, deploying and operating web applications and application programming interfaces for the Web.
Python is object oriented programming language. It can be used to build server-side web applications. Python is not used in a web browser. The language executed in browsers such as Chrome, Firefox and Internet Explorer is JavaScript.
However, most web applications build using a combination of Python and JavaScript. Python is executed on the server side while JavaScript is downloaded to the client and run by the web browser.

So you can build a cool website from scratch without feeling overwhelmed. You can also take advantage of micro-frameworks like Flask and Bottle.

Advanced content management is also possible with systems like Django CMS and Plone. Further, Python’s standard library supports several internet protocols like HTML, XML, and JSON.

2. Scientific and Numeric Computing
Python is an increasingly popular tool for Data Analysis. Data analytics falls under scientific and numeric computing. So we can take advantage of many libraries which python provides for scientific and Numeric computing. Such as SciPy library which includes modules for linear algebra, optimization, integration, special functions, signal and image processing, statistics, genetic algorithms, ODE solvers, and others. Numba which is specifically suited for scientific codes and Pandas is a data analysis and modeling library, so there’s a lot going on with Python within data science.

3. Function Decorators Allow Enhanced Functionality
Function decorators allow you to enhance the functionality of existing functions. In context of design patterns, decorators dynamically alter the functionality of a function, method or class without having to directly use subclasses. You can implement the decorator pattern anywhere, but Python facilitates the implementation by providing much more expressive features and syntax for that.

4.Machine Learning

machine-learning-python


Machine learning is a type of artificial intelligence (AI) that provides computers with the ability to learn without being explicitly programmed. Machine learning focuses on the development of computer programs that can change when exposed to new data. 
Python has a great library called scikit-learn that is specialized in machine learning. The availability of scikit-learn makes it easy to implement machine learning algorithms in python.

5.Browser Automation

browser-automation-python


You can also use Python to do cool things like automating your browser to do social media posts,download files and web pages. This can be done by using Selenium with Python. Selenium is able to fill in forms and simulate mouse clicks in this browser.

6.Robotics

robotics-python

Python is a core language of ROS (Robot Operating System), meaning the full power of a distributed robotics system and all its libraries/tools are available to you via Python. Python can be used to code a Raspberry Pi to function as the brain of a robot. By doing this you can get the robot to react to its environment and perform multiple actions.

These six cool things made possible by this programming language is just a fraction of what you can do with it. Python’s recent 3.6 release has new features in the asyncio module (which is no longer provisional with a surprisingly stable API), formatted string literals, and the addition of a file system path protocol.
The language is also evolving fast within the data science space. The Python ecosystem is now full of data science tools, so a lot of the data science work that’s currently taking place is being done with open-source tools like Python.

Learn Python with Django