Skip to main content

Posts

Showing posts from January, 2016

JavaScript Statement termination

//JavaScript Statement can be terminated by ;
doSth();

// ... but they don't have to be, as semicolons are automatically inserted
// wherever there's a newline, except in certain cases.
doSth()

// Because those cases can cause unexpected results, it is safer to use
// semicolons

Not a real number values of JavaScript

// There are three special not-a-real-number values:
Infinity; // result of e.g. 1/0
-Infinity; // result of e.g. -1/0
NaN; // result of e.g. 0/0, stands for 'Not a Number'

typeofInfinity; // returns "number"

var myNumber =88;
while (myNumber !=Infinity) { // Execute until Infinity
myNumber = myNumber * myNumber;
}

OpenSSH security bug

A newly reported bug affects OpenSSH versions 5.4 through 7.1.  This includes both the OpenBSD-specific and portable versions of OpenSSH. This newly revealed bug affects users due to a failed implementation of a feature called roaming, which  was intended to facilitate resuming SSH-connections. Although server-side code was never released to support this feature, on the client-side this code was vulnerable to exploitation by a malicious host.  The bug enables a malicious server host to access memory on the client system which could include the ability for the host to access the private client user keys.

How to set up a trigger for Google App script

Set up a Trigger in Google App Script EditorFrom inside the Script Editor, click on the Resources menu and select the option Current project's triggersIn the window that appears, click the link No triggers set up. Click here to add one now.This will create a trigger for your function. Change the default Hour timer to Minutes timer.Click SaveYou'll be prompted to authorize your app by clicking Continue and then Accept. More information on Google Apps authorization can be found here.

Web design resources and tools

Nowadays websites are designed to be more dynamic and user-friendly thanks to an enormous availability of design resources, including modern web development and graphic designing tools. User interface elements, such as fonts, icons, navigation menu, buttons, hover effects and others make a website more intuitive and visually appealing for a user. The incorporation of modern UI elements in website development is quite important.

WebRTC (Web Real-Time Communication) - an open source technology for implementing multimedia communication capabilities in real time directly in your web browser

WebRTC (Web Real-Time Communication) is an open source technology for implementing multimedia communication capabilities in real time directly in your web browser. It sets the Peer-to-Peer connection between two or more people, which is perfect for transferring of a multimedia file. This technology is natively supported by Google Chrome, Mozilla Firefox and Opera. You do not need any additional plug-ins for these browsers. You just need to open a web page and start a conversation. There is no native support for those using Safari and IE.
The process is simple. First, the browser sends a signal to the WebRTC server that the user wants to initiate a call. After getting the link from the server, the user sends the link to his companion. In the pop-up window browser prompts the user for permission to access a web camera and a microphone.

Cookie Web Tracking

When you browse online using your desktop or laptop computer, online advertising networks rely on browser cookies to track your behavior including sites visited, actions taken, searches, etc. These cookies are small text files placed in your browser directory when you visit websites that deploy them. Sites also use cookies to store your preferences, user ID, password, etc., making your online experience smoother and more efficient. This includes not requiring you to reenter that information each time you leave the site and return or even load a different page. Using similar technology, Google optimizes your searches based on your search history and which results you’ve selected in the past.

Cookie Web Tracking allows web sites to do more than simply recognize you so you don’t need to reenter the same user ID and password. They allow sites to adhere to your privacy preferences such as opt-outs, maintain your personalized themes and appearance preferences, etc. Users have come to appreci…

Bower - A package manager for the web

Bower manages frameworks, libraries, assets, and utilities for you
Bower can manage components that contain HTML, CSS, JavaScript, fonts or even image files. Bower doesn’t concatenate or minify code or do anything else - it just installs the right versions of the packages you need and their dependencies.
Bower is optimized for the front-end. If multiple packages depend on a package - jQuery for example - Bower will download jQuery just once. This is known as a flat dependency graph and it helps reduce page load.

Project oriented Information service

Technical Development
API integration
Interactive Design & Development
Multimedia Development
Content Management (CMS) & Learning Management Systems (LMS) Development
Learning Content Management Systems Development (LCMS)
Web and Application Development
Accessibility
Intranet, Extranet & Portal Development
Mobile Optimization

Marketing and Outreach Consulting
Communications Messaging
Social Media Strategy & Implementation
Content Marketing
Copy-writing & Technical Editing
Project, Program & Quality Management

Educational Consulting
Curriculum Design & Assessment
Web-based Training (WBT)
E-learning
Responsive On-line Training
Blended Learning Solutions
Learning Management System (LMS) Integration
Survey Design, Evaluation, & Analytics
Pilot Testing & Focus Group Facilitation
Instructor-led Training
Mobile or Tablet-optimized Course Conversions

Creative Design and Development
Graphic Design
Multimedia Design
Branding
Print Collateral
Infographics
User-centered Interface Design
User Ex…

Java DB - Oracle's supported distribution of the Apache Derby open source database

Java DB supports standard ANSI/ISO SQL through the JDBC and Java EE APIs. Java DB is included in the JDK. At a GlanceFull-featured and easy-to-useTransaction-protected and crash-recoverableEmbeddable in applicationsPure Java and portable and across CDC FP 1.1, Java 5, Java 6, and Java 7 (everywhere from tablets to mainframes)Included in the JDKCompact (2.6 MB)

How to reduce MySQL InnoDB Lock by innodb_autoinc_lock_mode

There are three possible settings for the innodb_autoinc_lock_mode configuration parameter. The settings are 0, 1, or 2, for “traditional”,“consecutive”, or “interleaved” lock mode, respectively. innodb_autoinc_lock_mode = 0 (“traditional” lock mode) The traditional lock mode provides the same behavior that existed before the innodb_autoinc_lock_mode configuration parameter was introduced in MySQL 5.1. The traditional lock mode option is provided for backward compatibility, performance testing, and working around issues with “mixed-mode inserts”, due to possible differences in semantics. innodb_autoinc_lock_mode = 1 (“consecutive” lock mode) This is the default lock mode. In this mode, “bulk inserts” use the special AUTO-INC table-level lock and hold it until the end of the statement.  innodb_autoinc_lock_mode = 2 (“interleaved” lock mode)

How to find / check which MySQL configuration file my.cnf are being used

There is no internal MySQL command to trace which MySQL configuration file are being used. There might be 5 locations. They load cascading.

/etc/my.cnf/etc/mysql/my.cnf$MYSQL_HOME/my.cnf[datadir]/my.cnf~/.my.cnf
Those are the default locations MySQL looks at. If it finds more than one, it will load each of them & values override each other (in the listed order, I think). Also, the --defaults-file parameter can override the whole thing.

If you just want to see the values: SHOW VARIABLES.

You can find out how many my.cnf files exist in your system:

$sudofind/-namemy.cnf
/usr/db-ssl/openssl/my.cnf

/usr/my.cnf

/etc/my.cnf



How to Set / Change / Configure MySQL Replication / Binary Log Format

You can select the binary logging format explicitly by starting the MySQL server with --binlog-format=type. The supported values for type are: STATEMENT causes logging to be statement based. ROW causes logging to be row based. MIXED causes logging to use mixed format. Prior to MySQL 5.7.7, statement-based logging format was the default. In MySQL 5.7.7 and later, row-based logging format is the default. The logging format also can be switched at runtime. To specify the format globally for all clients, set the global value of the binlog_formatsystem variable:



mysql> SET GLOBAL binlog_format = 'STATEMENT';
mysql> SET GLOBAL binlog_format = 'ROW';
mysql> SET GLOBAL binlog_format = 'MIXED';
An individual client can control the logging format for its own statements by setting the session value of binlog_format:

Example of HAS ALL query in SQL

"GROUP BY ... HAVING COUNT" can use to find those emails which have all the tags you search for.

You have all the email_tag ids in tagids, the size of tagids is tagsize.

The example JPQL query is:
select e from EmailTagMap etm joinetm.email e whereetm.emailTag.id in :tagids
group bye.idhavingcount(distinct etm.emailTag.id) = :tagsize

Markdown - a plain text formatting syntax for writers

Markdown is a plain text formatting syntax for writers. It allows you to quickly write structured content for the web, and have it seamlessly converted to clean, structured HTML.

Back in 2004, Apple pundit John Gruber came up with the idea after becoming frustrated by writing long, laborious HTML tags to properly format his content. He devised a simple writing system which would make web based documents both easier to write, and easier to read in their raw state.

Here’s a quick example of Markdown in action:

The *quick* brown fox, jumped **over** the lazy [dog](https://en.wikipedia.org/wiki/Dog).
becomes

The quick brown fox, jumped over the lazy dog.

With just a couple of extra characters, Markdown makes rich document formatting quick and beautiful.

How to highlight bash/shell code in markdown

For github flavoured markdown for example, shell should work fine. Aliases are sh, bash or zsh. You can find the list of available syntax lexers here.
Or using the knitr package: ```{r, engine='bash'} ... i.e.

```{r, engine='bash'}
$ id -nG i88ca
```
The result is:
$id-nGi88ca

How to remove user from a group in linux

For example:
$id-nGi88cai88ca wheel postdrop

To remove i88ca from postdrop
$sudousermod-Gi88ca,wheeli88ca
Put after '-G' a list of supplementary groups which the user is also a member of. Each group is separated from the next by a comma, with no intervening whitespace.  This is because if the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list.

See also:
How to add existing user to a group in linux

Containers and continuous delivery

Containers and continuous delivery are two trends in the market today that are changing the process of software developmentContainers provide an open platform for building, shipping, and running distributed applications. Continuous delivery drives repeatability and feedback by moving smaller blocks of changes through the pipeline at high frequency. This reduces risk and brings features to market faster. Containers are facilitating this transformation by making environments and tooling consistent

Google Polymer framework - Custom web elements ready to use in your applications

Built for Speed
Polymer 1.0 replaces the shadow DOM polyfill with a lightweight shim, uses a new, faster data-binding system, and significantly reduces code size.

For Modern Browsers
Polymer is built from the ground up for modern browsers, using the latest web platform APIs. Polyfills provide support on evergreen browsers for APIs that aren't universal yet.

Using Web Components
Polymer leverages web components, a new set of standards designed to provide reusable components for the web.

MySQL Router - lightweight middleware that provides transparent routing between your application and any backend MySQL Servers

MySQL Router can be used for a wide variety of use cases, such as providing high availability and scalability by effectively routing database traffic to appropriate backend MySQL Servers. The pluggable architecture also enables developers to extend MySQL Router for custom use cases.

Failover
Typically, a highly available MySQL setup consists of a single master and multiple slaves and it is up to the application to handle failover, in case the MySQL master becomes unavailable. Using MySQL Router, application connections will be transparently routed based on load balancing policy, without implementing custom application code.

Load Balancing
MySQL Router provides additional scalability and performance by distributing database connections across a pool of servers. For example, if you have a replicated set of MySQL Servers, MySQL Router can distribute application connections to them in a round-robin fashion.

Pluggable Architecture
MySQL Router's pluggable architecture allows MySQL developers…

PrimeElements - Web Components

Web Components is a collection of four specifications to create reusable user interface components. These different technologies are Custom Elements, Shadow DOM, Html Imports and Templates. Modern browsers provide native implementations and javascript libraries called pollyfills are available to use them on older browsers. There are some libraries to create web components easily such as Google Polymer or Mozilla X-Tag while providing additional features.

PrimeElements is an add-on library for PrimeUI that only uses the Custom Elements technology. PrimeElements are based on X-Tag APIs, a simple and lightweight library to create cross browser custom elements.

PrimeElements is a library not a framework, features such as data binding, validation, routing are out of scope since they can be provided by your framework of choice. As they are regular html elements, there are various use cases including integration with a simple REST backend, a javascript mvc framework or implementation in a serv…

X-Tag - a Microsoft supported, open source, JavaScript library that wraps the W3C standard Web Components family of APIs

X-Tag provides a compact, feature-rich interface for rapid component development. While X-Tag offers feature hooks for all Web Component APIs (Custom Elements, Shadow DOM, Templates, and HTML Imports), it only requires Custom Element support to operate. In the absence of native Custom Element support, X-Tag uses a set of polyfills shared with Google's Polymer framework.

Example of MySQL FIND_IN_SET function

FIND_IN_SET(str,strlist) returns a value in the range of 1 to N if the string str is in the string list strlist consisting of N substrings. A string list is a string composed of substrings separated by “,” characters. If the first argument is a constant string and the second is a column of type SET, the FIND_IN_SET() function is optimized to use bit arithmetic. Returns 0 if str is not in strlist or if strlist is the empty string. Returns NULL if either argument is NULL. This function does not work properly if the first argument contains a comma (“,”) character.
mysql>SELECT FIND_IN_SET('b','a,b,c,d');
->2In PHP:
$ids=array(1,2,3,4,5,6,7);
$stmt=$db->prepare( 'SELECT title FROM episode WHERE FIND_IN_SET(id,?)' );
$param=implode(',',$ids);
$stmt->bind_param('s',$param);
$stmt->execute(); It can be used in the case that "in" clause can not be properly used in prepare statement. For example: $stmt=$db->prepare( 'SELECT title…

MySQL Prepared statement Examples

Java JDBC
This example uses Java and the JDBC API:
java.sql.PreparedStatement stmt = connection.prepareStatement(
"SELECT * FROM users WHERE USERNAME = ? AND ROOM = ?");
stmt.setString(1, username);
stmt.setInt(2, roomNumber);
stmt.executeQuery();Java PreparedStatement provides "setters" (setInt(int), setString(String), setDouble(double), etc.) for all major built-in data types.
PHP PDO
This example uses PHP and PHP Data Objects (PDO):

$stmt=$dbh->prepare("SELECT*FROM users WHERE USERNAME = ? AND PASSWORD = ?");
$stmt->execute(array($username, $password));
MySQL
PREPARE i88_ca FROM
'insert low_priority ignore into
sharedlist(listid, contactid)
select ?, sl.contactid from sharedlist sl
join contacts c on c.contactid=sl.contactid
where sl.listid=? order by c.email limit ?';

EXECUTE i88_ca USING @v_listid1,@v_listid,@count;

How to fix MySQL: table index is corrupted

To rebuild a table with ALTER TABLE, use a “null” alteration; that is, an ALTER TABLE statement that “changes” the table to use the storage engine that it already has. For example, if t1 is an InnoDB table, use this statement:

mysql> ALTER TABLE t1 ENGINE = InnoDB;

To rebuild all tables in all databases, use the --all-databases option:

shell> mysqldump --all-databases > dump.sql
shell> mysql < dump.sql

See also:
How to Rebuild or Repaire Tables or Indexes in MySQL

How to Rebuild or Repaire Tables or Indexes in MySQL

To rebuild a table with ALTER TABLE, use a “null” alteration; that is, an ALTER TABLE statement that “changes” the table to use the same storage engine that it already has. For example, if t1 is a MyISAM table, use this statement:
mysql> ALTER TABLE t1 ENGINE = MyISAM;If you must rebuild a table because a table checking operation indicates that the table is corrupt or needs an upgrade, you can use REPAIR TABLE if that statement supports the table's storage engine. For example, to repair a MyISAM table, use this statement:
mysql> REPAIR TABLE t1;For storage engines such as InnoDB that REPAIR TABLE does not support, use mysqldump to create a dump file and mysql to reload the file.

mysqlcheck --repair provides command-line access to the REPAIR TABLE statement. This can be a more convenient means of repairing tables because you can use the --databases or --all-databases option to repair all tables in specific databases or all databases, respectively:
shell> mysqlcheck --repair --…

How to prevent replication of some MySQL queries

If you want to prevent any MySQL query from executing on a Slave, just run this on the Master:

SET SQL_LOG_BIN=0;
# a query you don't want to replicate
# another query you don't want to replicate
SET SQL_LOG_BIN=1;
This prevents the Master from recording the queries in its binary logs. Since the Slave only replicates from the binary logs of the Master, just don't record the commands that you do not want replicated.

UPDATE before first checking if necessary to reduce deadlock in MySQL

If the conditions are not met, update will do nothing. An empty update is just as fast as an empty select.

A potential side affect of always calling the UPDATE is the locking that needs to be put to insure that no other connection modifies these rows.

If the table is MyISAM - a lock will be places on the he entire table during the search.If the table is InnoDB, locks will be places on the indexes/gaps.
From the Docs:

A locking read, an UPDATE, or a DELETE generally set record locks on every index record that is scanned in the processing of the SQL statement. It does not matter whether there are WHERE conditions in the statement that would exclude the row. 

String functions in JSF EL (JSF Expression Language)

Add JSTL functions namespace in Facelets XHTML:

xmlns:fn="http://java.sun.com/jsp/jstl/functions"
Example1:

#{fn:startsWith(beanName.fieldName,'PREFIX_')}

Example 2:
<c:forEachitems="${contacts}"var="contact">
<c:iftest="${not fn:containsIgnoreCase(contact, 'i88.ca')}"> <p>Doesn't contain 'i88.ca'</p>
</c:if>
</c:forEach> Other functions:toUpperCase, toLowerCase: Changes the capitalization of a stringsubstring, substringBefore, substringAfter: Gets a subset of a stringtrim: Trims white space from a stringreplace: Replaces characters in a stringindexOf, startsWith, endsWith, contains, containsIgnoreCase: Checks whether a string contains another stringsplit: Splits a string into an arrayjoin: Joins a collection into a stringescapeXml: Escapes XML characters in a stringlength: Returns the number of items in a collection, or the number of characters in a stringSee also:
http://docs.…

Drop Unused Indexes or use temporary indexes for database performance

Dropping unused indexes can help to speed up data modifications without affecting data retrieval. Also, you need to define a strategy for batch processes that run infrequently and use certain indexes. In such cases, creating indexes in advance of batch processes and then dropping them when the batch processes are done helps to reduce the overhead on the database.

Web redirection: Meta Refresh vs 301 Redirect

Meta Refresh vs 301 RedirectsHow to redirect by Meta Refresh Tag:
Place

   <meta HTTP-EQUIV="refresh" CONTENT="0;URL=http://it.i88.ca/">

in the head of your page copy. The number is a measure of time to redirect the browser to the new location.

What is the problem with using a Meta Refresh Tag?
One of the bigger problems with this is that it is a common spam technique. Some people suggest setting the meta refresh to at least 5 seconds to avoid any ranking penalty.

In addition Google will show the URL of the original page in the search results if it has a higher PageRank than the location of the destination page.

How to redirect by 301:
A 301 redirect is a perminant change of location code. It tells a search engine spider that a page or website has moved.

Redirect permanent / http://www.newurl.com/cool/

The 301 redirect code goes inside a .htaccess file either at the root level or in a local level. Or in your web server's configuration file. You can also use a 301 r…

How to stop / configure storing text messages in iPhone

By default, your iPhone stores all of the text messages you send and receive...forever. This is convenient if you need to look up a 2-year old conversation; not so convenient if you need that storage space back. 

To stop your phone from saving texts forever, open up the Settings app and tap Messages. Scroll down until you find Message History and tap Keep Messages. Change Forever to 30 Days or 1 Year. A pop-up will ask you if you want to delete older messages; tap Delete to proceed.

Wring the most from your twitter marketing program

To get the most from your twitter marketing program, you need to send great tweets… tweets that serve two masters well; your customers, and your business. Your customers need to be engaged and enticed by your tweets. If they're not, eventually they will unsubscribe and leave. That's the last thing you want to see.

The whole point of your campaigns is to promote your business or generate revenue. Falling short on either means you will not get the full potential from your campaigns.

IoT turns products into services

Connected, sensor-enabled "Internet of things" act more like services than what we usually think of as products.



Manufacturing connected IoT versions of traditional products requires more than multiple deep technology skills. It also requires a shift in mindset.

Tips of Angular.js you should know

Tips of Angular.js$($0).scope() is the code to use if you want to see the scope that is associated with the element and all its properties.The properties that have been inherited from the parent scope will not show up, but if you want to see them, you can always type their names.To look for the properties of the parent scope, use the code $($0).scope().$parent.$($0).scope().$root is the code to use in order to look at the properties of the root code.If there is a directive you have highlighted with the isolate scope, you can look at its properties using the code $($0).isolateScope()If you have a highlighted element inside an isolated scope, the code $($0).scope() will show what is available

IoT market opportunities versus threats

Gartner predicts that number of IoT devices in use worldwide will grow from an estimated 5 billion in 2015 to some 25 billion connected devices by 2020. The best business strategies will perfectly balance the ever-growing IoT market opportunities versus a rapidly evolving threat environment.