Tutorial by Examples

Display all data files for all databases with size and growth info SELECT d.name AS 'Database', d.database_id, SF.fileid, SF.name AS 'LogicalFileName', CASE SF.status & 0x100000 WHEN 1048576 THEN 'Percentage' WHEN 0 THEN 'MB...
Once you've got all your settings, you'll want to use them in your code. To do so, add the following import to your file: from django.conf import settings You may then access your settings as attributes of the settings module, for example: if not settings.DEBUG: email_user(user, message) ...
It's a bad idea to hard code paths in your application. One should always use relative urls so that your code can work seamlessly across different machines. The best way to set this up is to define a variable like this import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) Then use th...
Using environment variables is a widely used way to setting an app's config depending on it environment, as stated in The Twelve-Factor App. As configurations are likely to change between deployment environments, this is a very interesting way to modify the configuration without having to dig in th...
public enum DayOfWeek { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday } // Enum to string string thursday = DayOfWeek.Thursday.ToString(); // "Thursday" string seventhDay = Enum.GetName(typeof(DayOfWeek), 6); // "Satur...
Joins can also be used in an UPDATE statement: CREATE TABLE Users ( UserId int NOT NULL, AccountId int NOT NULL, RealName nvarchar(200) NOT NULL ) CREATE TABLE Preferences ( UserId int NOT NULL, SomeSetting bit NOT NULL ) Update the SomeSetting column of the Prefere...
As Array conforms to SequenceType, we can use map(_:) to transform an array of A into an array of B using a closure of type (A) throws -> B. For example, we could use it to transform an array of Ints into an array of Strings like so: let numbers = [1, 2, 3, 4, 5] let words = numbers.map { Stri...
The things Array contains values of Any type. let things: [Any] = [1, "Hello", 2, true, false, "World", 3] We can extract values of a given type and create a new Array of that specific type. Let's say we want to extract all the Int(s) and put them into an Int Array in a safe ...
connection.Execute(@"some Query with @a,@b,@c", new {a=somevalueOfa,b=somevalueOfb,c=somevalueOfc});
python-requests is available on PyPI, the Python Package Index, which means it can be installed through pip: pip install requests Up-to-date source code can be found on the requests GitHub repository If you wish to install it from source, you can do this by either cloning the GitHub repository:...
This snippet will grab a JSON formatted resource, decode it and print it in PHP array format. // Fetch $response = wp_remote_get( 'http://www.example.com/resource.json' ); if ( ! is_wp_error( $response ) ) { $headers = wp_remote_retrieve_headers( $response ); if ( isset( $headers[ 'con...
Media Queries in Bootstrap allow you to move, show and hide content based on the viewport size. The following media queries are used in LESS files to create the key breakpoints in the Bootstrap grid system: /* Small devices (tablets, 768px and up) */ @media (min-width: @screen-sm-min) { ... } /...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-widt...
Jumping to characters f{char} - move to the next occurrence of {char} to the right of the cursor on the same line F{char} - move to the next occurrence of {char} to the left of the cursor on the same line t{char} - move to the left of the next occurrence of {char} to the right of the cursor on th...
You can create a new hash with the keys or values modified, indeed you can also add or delete keys, using inject (AKA, reduce). For example to produce a hash with stringified keys and upper case values: fruit = { name: 'apple', color: 'green', shape: 'round' } # => {:name=>"apple",...
ThenBy can only be used after a OrderBy clause allowing to order using multiple criteria var persons = new[] { new {Id = 1, Name = "Foo", Order = 1}, new {Id = 1, Name = "FooTwo", Order = 2}, new {Id = 2, Name = "Bar", Order = 2}, new {Id = 2, Nam...
The background property can be used to set one or more background related properties: ValueDescriptionCSS Ver.background-imageBackground image to use1+background-colorBackground color to apply1+background-positionBackground image's position1+background-sizeBackground image's size3+background-repeat...
You may add your new Seeder to the DatabaseSeeder class. /** * Run the database seeds. * * @return void */ public function run() { $this->call(UserTableSeeder::class); } To run a database seeder, use the Artisan command php artisan db:seed ...
Database seeds are stored in the /database/seeds directory. You can create a seed using an Artisan command. php artisan make:seed UserTableSeeder Alternatively you can create a new class which extends Illuminate\Database\Seeder. The class must a public function named run().
You can reference models in a seeder. use DB; use App\Models\User; class UserTableSeeder extends Illuminate\Database\Seeder{ public function run(){ # Remove all existing entrie DB::table('users')->delete() ; User::create([ 'name' => 'Admin', ...

Page 135 of 1336