Tutorial by Examples: bac

pg_dump -Fc -f DATABASE.pgsql DATABASE The -Fc selects the "custom backup format" which gives you more power than raw SQL; see pg_restore for more details. If you want a vanilla SQL file, you can do this instead: pg_dump -f DATABASE.sql DATABASE or even pg_dump DATABASE > DATABA...
psql < backup.sql A safer alternative uses -1 to wrap the restore in a transaction. The -f specifies the filename rather than using shell redirection. psql -1f backup.sql Custom format files must be restored using pg_restore with the -d option to specify the database: pg_restore -d DATABA...
$ pg_dumpall -f backup.sql This works behind the scenes by making multiple connections to the server once for each database and executing pg_dump on it. Sometimes, you might be tempted to set this up as a cron job, so you want to see the date the backup was taken as part of the filename: $ post...
Callback-based: db.notification.email.find({subject: 'promisify callback'}, (error, result) => { if (error) { console.log(error); } // normal code here }); This uses bluebird's promisifyAll method to promisify what is conventionally callback-based code like above. blueb...
What if you want to rollback the latest migration i.e recent operation, you can use the awesome rollback command. But remember that this command rolls back only the last migration, which may include multiple migration files php artisan migrate:rollback If you are interested in rolling back all o...
Background pages are implicit pages which contain background scripts. A background script is a single long-running script to manage some task or state. It exists for the lifetime of your extension, and only one instance of it at a time is active. You can declare it like this in your manifest.json: ...
To create a background session // Swift: let mySessionID = "com.example.bgSession" let bgSessionConfig = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(mySessionID) let session = NSURLSession(configuration: bgSessionConfig) // add tasks here //...
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...
In CSS3, we can stack multiple background in the same element. #mydiv { background-image: url(img_1.png), /* top image */ url(img_2.png), /* middle image */ url(img_3.png); /* bottom image */ background-position: right bottom, ...
This example wraps the asynchronous method oauth2.client.getToken(callback) from the package NPM package simple-oauth2into a Fiber so that the method may be called synchronously. const oauth2 = require('simple-oauth2')(credentials); const credentials = { clientID: '#####', clientSecret...
String#replace can have a function as its second argument so you can provide a replacement based on some logic. "Some string Some".replace(/Some/g, (match, startIndex, wholeString) => { if(startIndex == 0){ return 'Start'; } else { return 'End'; } }); // will retur...
Using escaped brackets, you can define a capturing group in a pattern that can be backreferenced in the substitution string with \1: $ echo Hello world! | sed 's/\(Hello\) world!/\1 sed/' Hello sed With multiple groups: $ echo one two three | sed 's/\(one\) \(two\) \(three\)/\3 \2 \1/' three ...
Sometimes it might be necessary to manually promisify a callback function. This could be for a case where the callback does not follow the standard error-first format or if additional logic is needed to promisify: Example with fs.exists(path, callback): var fs = require('fs'); var existsAsync =...
Callbacks offer a way to extend the functionality of a function (or method) without changing its code. This approach is often used in modules (libraries / plugins), the code of which is not supposed to be changed. Suppose we have written the following function, calculating the sum of a given array ...
Most developers encounter backpressure when their application fails with MissingBackpressureException and the exception usually points to the observeOn operator. The actual cause is usually the non-backpressured use of PublishSubject, timer() or interval() or custom operators created via create(). ...
This is a normal function call: console.log("Hello World!"); When you call a normal function, it does its job and then returns control back to the caller. However, sometimes a function needs to return control back to the caller in order to do its job: [1,2,3].map(function double(x) {...
Dart has a robust async library, with Future, Stream, and more. However, sometimes you might run into an asynchronous API that uses callbacks instead of Futures. To bridge the gap between callbacks and Futures, Dart offers the Completer class. You can use a Completer to convert a callback into a Fut...
From Apple documentation: Use the CTCallCenter class to obtain a list of current cellular calls, and to respond to state changes for calls such as from a dialing state to a connected state. Such state changes are known as cellular call events. The purpose of CTCallCenter is to give the develop...
In contrast to segue that lets you pass data "forward" from current view controller to destination view controller: (VC1) -> (VC2) Using "unwind" you can do the opposite, pass data from the destination or current view controller to its presenting view controller: (VC1) <...
Creating backpressured data sources is the relatively easier task when dealing with backpressure in general because the library already offers static methods on Observable that handle backpressure for the developer. We can distinguish two kinds of factory methods: cold "generators" that ei...

Page 3 of 12