Tutorial by Examples: and

PHP lacks a build-in function to encrypt and decrypt large files. openssl_encrypt can be used to encrypt strings, but loading a huge file into memory is a bad idea. So we have to write a userland function doing that. This example uses the symmetric AES-128-CBC algorithm to encrypt smaller chunks of...
Suppose you have two views ViewA and ViewB Instance of ViewB is created inside ViewA, so ViewA can send message to ViewB's instance, but for the reverse to happen we need to implement delegation (so that using delegate ViewB's instance could send message to ViewA) Follow these steps to implement t...
The ClassLoader needs to provide a ProtectionDomain identifying the source of the code: public class PluginClassLoader extends ClassLoader { private final ClassProvider provider; private final ProtectionDomain pd; public PluginClassLoader(ClassProvider provider) { this...
Let say you want to build your API to comply jsonapi.org specification and the result should look like: { "article": { "id": "305", "type": "articles", "attributes": { "title": "Asking Alexandria&q...
In your Maven project, add the following to your pom.xml file. The following versions are for Cassandra 3.x. <dependency> <groupId>com.datastax.cassandra</groupId> <artifactId>cassandra-driver-core</artifactId> <version>3.1.0</ve...
Connecting to Cassandra is very similar to connecting to other datasources. With Cassandra, credentials are not required. String cassandraIPAddress = "127.0.0.1"; String cassandraKeyspace = "myKeyspace"; String username = "foo"; String password = "bar"; ...
This fetches the value of NOW() in local time, in India Standard Time, and then again in UTC. SELECT NOW(); SET time_zone='Asia/Kolkata'; SELECT NOW(); SET time_zone='UTC'; SELECT NOW();
Here's an example of a React component with a "managed" input field. Whenever the value of the input field changes, an event handler is called which updates the state of the component with the new value of the input field. The call to setState in the event handler will trigger a call to ...
grant all privileges on schema_name.* to 'new_user_name'@'%' identified by 'newpassword'; Attention: This can be used to create new root user
variables this local arguments
You can also use Laravel Artisan commands from your routes or controllers. To run a command using PHP code: Artisan::call('command-name'); For example, Artisan::call('db:seed');
import {User} from 'backend/user'; // import custom class import {inject} from 'aurelia-framework'; // allows us to inject @inject(User) // inject custom class export class ProfileView { constructor(user) { // use instance of custom class as a parameter to the constructor this.user = us...
The subprocess method that allows running commands needs the command in form of a list (at least using shell_mode=True). The rules to create the list are not always straightforward to follow, especially with complex commands. Fortunately, there is a very helpful tool that allows doing that: shlex. ...
var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var app = express(); app.use(favicon(__dirname + '/public/img/favicon.ico')); app.use(express.static(path.join(__dirname, 'public'))); app.listen(3000, function() { console.log("...
var express = require('express'); var app = express(); var router = express.Router(); app.route('/user') .get(function (req, res) { res.send('Get a random user') }) .post(function (req, res) { res.send('Add a user') }) .put(function (req, res) { res.send...
If you want an avatar to appear on the card, use the <md-card-avatar> directive, which must be placed within the <md-card-header> directive. The <md-card-avatar> directive accepts an <img /> tag. Optional: .md-user-avatar, which makes the <img /> tag have a circle look...
In C++, code must be declared or defined before usage. For example, the following produces a compile time error: int main() { foo(2); // error: foo is called, but has not yet been declared } void foo(int x) // this later definition is not known in main { } There are two ways to resolve...
This example will guide you how to get playlist data using the YouTube Data API on Android. SHA-1 fingerprint First you need to get an SHA-1 fingerprint for your machine. There are various methods for retrieving it. You can choose any method provided in this Q&A. Google API console and YouTub...
The HTML5 file API allows you to restrict which kind of files are accepted by simply setting the accept attribute on a file input, e.g.: <input type="file" accept="image/jpeg"> Specifying multiple MIME types separated by a comma (e.g. image/jpeg,image/png) or using wild...
Full list of options: ls -a list all files including hidden file starting with '.' ls --color colored list [=always/never/auto] ls -d list directories - with ' */' ls -F add one char of */=>@| to enteries ls -i list file's inode index number ls -l list with long form...

Page 115 of 153