This code selects data out of a table:
SELECT Column1, Column2, Column3 FROM MySourceTable;
This code creates a new table called MyNewTable and puts that data into it
SELECT Column1, Column2, Column3
INTO MyNewTable
FROM MySourceTable;
You can use the CONVERT function to cast a datetime datatype to a formatted string.
SELECT GETDATE() AS [Result] -- 2016-07-21 07:56:10.927
You can also use some built-in codes to convert into a specific format. Here are the options built into SQL Server:
DECLARE @convert_code INT = 100 -- See ...
Bear in mind that declaring a destructor inhibits the compiler from generating implicit move constructors and move assignment operators. If you declare a destructor, remember to also add appropriate definitions for the move operations.
Furthermore, declaring move operations will suppress the genera...
When creating a recyclerview with a gridlayout layout manager you have to specify the span count in the constructor. Span count refers to the number of columns. This is fairly clunky and doesn't take into account larger screen sizes or screen orientation. One approach is to create multiple layouts f...
The idea is to use HttpContext.Response.OnStarting callback, as this is the last event that is fired before the headers are sent. Add the following to your middleware Invoke method.
public async Task Invoke(HttpContext context)
{
context.Response.OnStarting((state) =>
{
if ...
Comparable is one of the most popular modules in Ruby. Its purpose is to provide with convenience comparison methods.
To use it, you have to include Comparable and define the space-ship operator (<=>):
class Rectangle
include Comparable
def initialize(a, b)
@a = a
@b = b
...
Controller class names are pluralized. The reason is the controller controls multiple instances of object instance.
For Example: OrdersController would be the controller for an orders table. Rails will then look for the class definition in a file called orders_controller.rb in the /app/controllers ...
app/assets/javascripts/channels/notifications.coffee
App.notifications = App.cable.subscriptions.create "NotificationsChannel",
connected: ->
# Called when the subscription is ready for use on the server
$(document).on "change", "input", (e)=>
...
To avoid verbose null checking, the ?. operator has been introduced in the language.
The old verbose syntax:
If myObject IsNot Nothing AndAlso myObject.Value >= 10 Then
Can be now replaced by the concise:
If myObject?.Value >= 10 Then
The ? operator is particularly powerful when you...
The number of seconds from the current date and time for the new date. Use a negative value to specify a date before the current date.
For doing this we have a method named dateWithTimerIntervalSinceNow(seconds: NSTimeInterval) -> NSDate (Swift) or + (NSDate*)dateWithTimeIntervalSinceNow:(NSTime...
Swift
let alert = UIAlertController(title: "Hello",
message: "Welcome to the world of iOS",
preferredStyle: UIAlertControllerStyle.alert)
let defaultAction = UIAlertAction(title: "OK", style: UIAlertActionS...
With UIAlertController, action sheets like the deprecated UIActionSheet are created with the same API as you use for AlertViews.
Simple Action Sheet with two buttons
Swift
let alertController = UIAlertController(title: "Demo", message: "A demo with two buttons", preferredStyle...
To get your most recent stash after running git stash, use
git stash apply
To see a list of your stashes, use
git stash list
You will get a list that looks something like this
stash@{0}: WIP on master: 67a4e01 Merge tests into develop
stash@{1}: WIP on master: 70f0d95 Add user role to loca...
To spawn a new process in which you need unbuffered output (e.g. long-running processes which might print output over a period of time rather than printing and exiting immediately), use child_process.spawn().
This method spawns a new process using a given command and an array of arguments. The retu...
<p contenteditable>This is an editable paragraph.</p>
Upon clicking on the paragraph, the content of it can be edited similar to an input text field.
When the contenteditable attribute is not set on an element, the element will inherit it from its parent. So all child text of a conte...
You can compare BigIntegers same as you compare String or other objects in Java.
For example:
BigInteger one = BigInteger.valueOf(1);
BigInteger two = BigInteger.valueOf(2);
if(one.equals(two)){
System.out.println("Equal");
}
else{
System.out.println("Not Equal"...
Post::find()->all();
// SELECT * FROM post
or the shorthand
(Returns an active record model instance by a primary key or an array of column values.)
Post::findAll(condition);
returns an array of ActiveRecord instances.
Find All with where Condition
$model = User::find()
->w...