To access MySQL from the command line:
mysql --user=username --password=pwd --host=hostname test_db
This can be shortened to:
mysql -u username -p password -h hostname test_db
By omitting the password value MySQL will ask for any required password as the first input. If you specify password ...
double area;
double h = 1.0 / n;
#pragma omp parallel for shared(n, h, area)
for (i = 1; i <= n; i++)
{
double x = h * (i - 0.5);
#pragma atomic
area += (4.0 / (1.0 + x*x));
}
pi = h * area;
In this example, each threads execute a subset of the iteration count and they accumula...
double area;
double h = 1.0 / n;
#pragma omp parallel for shared(n, h, area)
for (i = 1; i <= n; i++)
{
double x = h * (i - 0.5);
#pragma omp critical
{
area += (4.0 / (1.0 + x*x));
}
}
double pi = h * area;
In this example, each threads execute a subset of the iteratio...
The following MATLAB script shows how to define and call a basic function:
myFun.m:
function [out1] = myFun(arg0, arg1)
out1 = arg0 + arg1;
end
terminal:
>> res = myFun(10, 20)
res =
30
When signing personal scripts or when testing code signing it can be useful to create a self-signed code signing certificate.
5.0
Beginning with PowerShell 5.0 you can generate a self-signed code signing certificate by using the New-SelfSignedCertificate-cmdlet:
New-SelfSignedCertificate -Friendl...
Unity networking provides the High Level API (HLA) to handle network communications abstracting from low level implementations.
In this example we will see how to create a Server that can communicate with one or multiple clients.
The HLA allows us to easily serialize a class and send objects of ...
Pre-requisites:
cx_Oracle package - See here for all versions
Oracle instant client - For Windows x64, Linux x64
Setup:
Install the cx_Oracle package as:
sudo rpm -i <YOUR_PACKAGE_FILENAME>
Extract the Oracle instant client and set environment variables as:
ORACLE_HOME=&...
To alias a command in you ~/.zshrc file, you can use the following syntax:
alias [alias-name]="[command-to-execute]"
For example, it is common to execute the command ls -a. You can alias this command as la as such:
alias la="ls -a"
After reloading the ~/.zshrc file, you w...
ExecutorService
ExecutorService executor = Executors.newFixedThreadPool(50);
It is simple and easy to use. It hides low level details of ThreadPoolExecutor.
I prefer this one when number of Callable/Runnable tasks are small in number and piling of tasks in unbounded queue does not increase m...
Executors returns different type of ThreadPools catering to specific need.
public static ExecutorService newSingleThreadExecutor()
Creates an Executor that uses a single worker thread operating off an unbounded queue
There is a difference between newFixedThreadPool(1) and newSingleThreadE...
To easily convert all tables in one database, use the following:
SET @DB_NAME = DATABASE();
SELECT CONCAT('ALTER TABLE `', table_name, '` ENGINE=InnoDB;') AS sql_statements
FROM information_schema.tables
WHERE table_schema = @DB_NAME
AND `ENGINE` = 'MyISAM'
AND `TABLE_TYPE` = '...
To Initialize a session, you can simply load it in your controller, this us usually placed inside the controller constructs, but it also can be autoloaded into the array found inside application/config/autoload.php:
$this->load->library('session');
SELECT DISTINCT
o.name AS Object_Name,o.type_desc
FROM sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id=o.object_id
WHERE m.definition Like '%myField%'
ORDER BY 2,1
Will find mentions of myField in SProcs, Views, etc.
This uses the SwiftyDropbox library to upload a file from a NSFileHandle to the Dropbox account using upload sessions, handling every error case:
import UIKit
import SwiftyDropbox
class ViewController: UIViewController {
// filled in later in doUpload:
var fileHandle : NSFileHandle?...
This is an example to show how to change the allowed choices on a subCategory select field depending on the value of the category select field.
To do that you have to make your subCategory choices dynamical for both client and server side.
1. Make the form dynamic on the client side for display / ...
Method 1:
proc sql;
create table foo like sashelp.class;
quit;
Method 2:
proc sql;
create table bar as
select * from sashelp.class (obs=0);
quit;
Method 1 should be the preferred option
Most of linux distros stores its version info in the /etc/lsb-release (debian) or /etc/redhat-release (RPM based) file. Using below generic command should get you past most of the Debian and RPM derivatives as Linux Mint and Cent-Os.
Example on Ubuntu Machine:
cat /etc/*release
DISTRIB_ID=Ubuntu
...
By default, all the controllers you generate with Symfony's built-in generate:controller command will make use of Symfony annotations for routing:
namespace AppBundle\Controller;
// You have to add a use statement for the annotation
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
...