2019-12-02

CNC Return to Reference


What does G28 Return to Reference Position Do? G28 is one of those odd g-codes that you don’t use very often, but when you need it, it’s pretty darned handy. It’s function is to return to the machine’s reference position, sometimes called the zero position. That zero return position is where most progams begin, most machines will go to this position when you manually home or reference the machine, and it is the reference or zero position for calculating fixture offsets for mills and geometry offsets for lathes. Typically, G28 allows the movement to be done via an intermediate position. The movement to the reference position is done at rapids (G0) speed,and the intermediate position is used to ensure there are no collisions along the way. On many machines, if you have Single Block on, you push the Cycle Start twice–once to go to the intermediate position and once to finish at the reference position. Specifying the G28 Intermediate Position on Mills The intermediate position is specified using one or more position words (X, Y, or Z) after the G28. If the machine is in absolute mode, those position coordinates are relative to program zero (part zero). In relative mode, the coordinates are relative to the tool’s current position. Let’s try some examples: Move Straight to the Reference Position G91 G28 X0 Y0 Z0 In this case, we’re telling the machine the incremental position is at 0, 0, 0 relative to the tool’s position. Since it thinks it is already at the intermediate position, this version essentially causes the intermediate position to be ignored and we get coordinated motion straight to the reference position. Move straight a distance, then on to the Reference position G91 G28 X0 Y0 Z4.0 This variation is telling G28 that the intermediate position is 4″ above the current tool position, hence the machine moves up 4″ before heading straight from there to the reference position. This is much less likely to hit some errant fixture or part of the workpiece than just commanding a move straight to the reference position. Beware absolute mode! You’ll notice the examples started with a G91 to put the machine in relative mode. In absolute mode, the intermediate point is relative to part zero. It’s really hard to know a safe intermediate point in absolute mode, whereas it’s pretty easy to use the relative mode with X0 Y0 Zn to make a safe move to an intermediate position that’s straight up from the current tool position. G28 on Lathes Same idea, but we have a little different coordinate system to work with on a turning center or CNC lathe. Let’s assume we will use U and W to represent incremental moves. Then G28 W0 is the analog of G91 G28 Z0 on a mill. Hence, the tool moves in X only (since the incremental Z move is 0), and that’s the intermediate point. It follows that up with the remaining motion in Z. It’s even more important for most turning operations to be aware of the intermediate point as collisions with the turret or gang tooling are easy to come by if you’re not watchful. G28 in Mach3 The discussion of G28 up until now has centered on the way Fanuc controls operate. Here’s how it works: G28 X~ Y~ Z~ X, Y, and Z determine an intermediate position that will be interpreted as though a G0 X~ Y~ Z~ appeared before a G28 without the XYZ. This is the same as Fanuc. G30 is the same as G28 G28.1: Home the Axes Issuing a G28.1 just does what happens when you manually use “Ref All” to home all the axes of your machine.

 Exercises
1. Get out the programming manual for your machine and see how G28 is supposed to operate.
 2. Write some practice code using G28 and execute it on your machine. Set up so part zero is well up in the air so there’s no real chance of collision. Next Article: Tool Compensation: The Poor Man’s CAM

2019-11-28

How to Stop Selenium browser popup "Failed to load extension from : c:/users/internal. Loading of unpacked extensions is disabled by the administrator".

How to Stop Selenium browser popup "Failed to load extension from : c:/users/internal. Loading of unpacked extensions is disabled by the administrator".



You can stop this by creating webdriver with special properties.

Example:

ChromeOptions chromeOptions = new ChromeOptions();

chromeOptions.setExperimentalOption("useAutomationExtension", false);

How to handle browser admin login popup in selenium?

How to enter username and password to this browser login popup?



Solution:

You can send username and password in the URL request.

Example:  htpp://username:password@xyz.com


But in the latest web browser url credentials are blocked because of security issues.


Still you can use that features, you have to create web driver with some special operations.

Example:

ChromeOptions chromeOptions = new ChromeOptions();

chromeOptions.addArguments("--disable-blink-features=BlockCredentialedSubresources");

This feature consider as network error.
You can reopen the URL.
Example:

driver.get("htpp://username:password@xyz.com");

driver.get("xyz.com");


2019-11-26

Java - Annotations for Concurrency

Class Annotations

We use three class-level annotations to describe a class's intended thread-
safety promises: @Immutable, @ThreadSafe, and @NotThreadSafe. @Immutable means, of
course, that the class is immutable, and implies @ThreadSafe. @NotThreadSafe is
optionalif a class is not annotated as thread-safe, it should be presumed not to
be thread-safe, but if you want to make it extra clear, use @NotThreadSafe.
These annotations are relatively unintrusive and are beneficial to both users
and maintainers. Users can see immediately whether a class is thread-safe,
and maintainers can see immediately whether thread-safety guarantees must
be preserved. Annotations are also useful to a third constituency: tools. Static
codeanalysis tools may be able to verify that the code complies with the
contract indicated by the annotation, such as verifying that a class annotated
with @Immutable actually is immutable.

Field and Method Annotations

The class-level annotations above are part of the public documentation for the
class. Other aspects of a class's thread-safety strategy are entirely for
maintainers and are not part of its public documentation.
Classes that use locking should document which state variables are guarded
with which locks, and which locks are used to guard those variables. A
common source of inadvertent non-thread-safety is when a thread-safe class
consistently uses locking to guard its state, but is later modified to add either
new state variables that are not adequately guarded by locking, or new
methods that do not use locking properly to guard the existing state variables.
Documenting which variables are guarded by which locks can help prevent
both types of omissions.
@GuardedBy(lock) documents that a field or method should be accessed only with
a specific lock held. The lock argument identifies the lock that should be held
when accessing the annotated field or method. The possible values for lock are:
@GuardedBy("this"), meaning the intrinsic lock on the containing object (the
object of which the method or field is a member);
@GuardedBy("fieldName"), meaning the lock associated with the object
referenced by the named field, either an intrinsic lock (for fields that do
not refer to a Lock) or an explicit Lock (for fields that refer to a Lock);
@GuardedBy("ClassName.fieldName"), like @GuardedBy("fieldName"), but referencing a
lock object held in a static field of another class;
@GuardedBy("methodName()"), meaning the lock object that is returned by calling
the named method;
@GuardedBy("ClassName.class"), meaning the class literal object for the named
class.
Using @GuardedBy to identify each state variable that needs locking and which
lock guards it can assist in maintenance and code reviews, and can help
automated analysis tools spot potential thread-safety errors.

Elasticsearch - Indices

Indices are containers for mapping types. An Elasticsearch index is an independent
chunk of documents, much like a database is in the relational world: each index is
stored on the disk in the same set of files; it stores all the fields from all the mapping
types in there, and it has its own settings. For example, each index has a setting called
refresh_interval, which defines the interval at which newly indexed documents are
made available for searches. This refresh operation is quite expensive in terms of per-
formance, and this is why it’s done occasionally—by default, every second—instead of
doing it after each indexed document. If you’ve read that Elasticsearch is near-real-time,
this refresh process is what it refers to.
TIP Just as you can search across types, you can search across indices. This
gives you flexibility in the way you can organize documents. For example, you
can put your get-together events and the blog posts about them in different
indices or in different types of the same index. Some ways are more efficient
than others, depending on your use case.
One example of index-specific settings is the number of shards. An index can be made up of one or more chunks called shards. This is good for
scalability: you can run Elasticsearch on multiple servers and have shards of the
same index live on all of them. Next, we’ll take a closer look at how sharding works
in Elasticsearch.

Elasticsearch - Types

Types are logical containers for documents, similar to how tables are containers for
rows. You’d put documents with different structures (schemas) in different types. For
example, you could have a type that defines get-together groups and another type for
the events when people gather.
 The definition of fields in each type is called a mapping. For example, name would
be mapped as a string, but the geolocation field under location would be mapped
as a special geo_point type. (We explore working with geospatial data in appendix A.)
Each kind of field is handled differently. For example, you search for a word in the
name field and you search for groups by location to find those that are located near
where you live.
TIP Whenever you search in a field that isn’t at the root of your JSON docu-
ment, you must specify its path. For example, the geolocation field under
location is referred to as location.geolocation.
You may ask yourself: if Elasticsearch is schema-free, why does each document belong
to a type, and each type contains a mapping, which is like a schema?
 We say schema-free because documents are not bound to the schema. They aren’t
required to contain all the fields defined in your mapping and may come up with
new fields. How does it work? First, the mapping contains all the fields of all the
documents indexed so far in that type. But not all documents have to have all fields.
Also, if a new document gets indexed with a field that’s not already in the mapping,
Elasticsearch automatically adds that new field to your mapping. To add that field, it
has to decide what type it is, so it guesses it. For example, if the value is 7, it assumes
it’s a long type.
 This autodetection of new fields has its downside because Elasticsearch might not
guess right. For example, after indexing 7, you might want to index hello world,
which will fail because it’s a string and not a long. In production, the safe way to go is
to define your mapping before indexing data.
 Mapping types only divide documents logically. Physically, documents from the
same index are written to disk regardless of the mapping type they belong to.

Elasticsearch - Documents

Elasticsearch is document-oriented, meaning the smallest unit
of data you index or search for is a document. A document has a few important prop-
erties in Elasticsearch:
■ It’s self-contained. A document contains both the fields (name) and their values
(Elasticsearch Denver).
■ It can be hierarchical. Think of this as documents within documents. A value of a
field can be simple, like the value of the location field can be a string. It can also
contain other fields and values. For example, the location field might contain
both a city and a street address within it.
■ It has a flexible structure. Your documents don’t depend on a predefined schema.
For example, not all events need description values, so that field can be omitted
altogether. But it might require new fields, such as the latitude and longitude of
the location.
A document is normally a JSON representation of your data. As we discussed in chap-
ter 1, JSON over HTTP is the most widely used way to communicate with Elasticsearch,
and it’s the method we use throughout the book. For example, an event in your get-
together site can be represented in the following document:
{
 "name": "Elasticsearch Denver",
 "organizer": "Lee",
 "location": "Denver, Colorado, USA"
}
NOTE Throughout the book, we’ll use different colors for the field names
and values of the JSON documents to make them easier to read. Field names
are darker/blue, and values are in lighter/red.
You can also imagine a table with three columns: name, organizer, and location. The
document would be a row containing the values. But there are some differences that
make this comparison inexact. One difference is that, unlike rows, documents can be
hierarchical. For example, the location can contain a name and a geolocation:
{
 "name": "Elasticsearch Denver",
 "organizer": "Lee",
 "location": {
 "name": "Denver, Colorado, USA",
 "geolocation": "39.7392, -104.9847"
 }
}


A single document can also contain arrays of values; for example:
{
 "name": "Elasticsearch Denver",
 "organizer": "Lee",
 "members": ["Lee", "Mike"]
}
Documents in Elasticsearch are said to be schema-free, in the sense that not all your doc-
uments need to have the same fields, so they’re not bound to the same schema. For
example, you could omit the location altogether in case the organizer needs to be
called before every gathering:
{
 "name": "Elasticsearch Denver",
 "organizer": "Lee",
 "members": ["Lee", "Mike"]
}
Although you can add or omit fields at will, the type of each field matters: some are
strings, some are integers, and so on. Because of that, Elasticsearch keeps a mapping
of all your fields and their types and other settings. This mapping is specific to every
type of every index. That’s why types are sometime called mapping types in Elastic-
search terminology.

2019-07-25

Ag grid column ids dynamically changing adding _1

Column ID's
Each column generated by the grid is given a unique ID. Parts of the Grid API use Column ID's (column identifiers).
If you are using the API and the columns ID's are a little complex (eg what if two columns have the same field, or what if you are using valueGetter instead of field) then it is useful to understand how columns ID's are decided.
If the user provides colId in the column definition, then this is used, otherwise the field is used. If both coldId and fieldthen colId gets preference. If neithercolId or field then numeric is provided. Then finally the ID ensured to be unique by appending '_[n]' where n is the first positive number that allows uniqueness.
In the example below, columns are set up to demonstrate the different ways ID's are generated. Open the example in a new tab and observe the output in the dev console. Note the following:
  • Col 1 and Col 2 both use colId. The grid appends '_1' to Col 2 to make the ID unique.
  • Col 3 and Col 4 both use field. The grid appends '_1' to Col 4 to make the ID unique.
  • Col 5 and Col 6 have neither colIdor field so the grid generates columns.

2019-05-10

How do you find longest common substring ?

Problem statement:
Given two strings S1 & S2. Find the longest common substring between S1 & S2.
  1. import java.util.ArrayList;
  2. import java.util.List;

  3. public class LongestCommonSubstring {
  4.     public static void main(String[] args) {
  5.         String S1 = "LCLC";
  6.         String S2 = "CLCL";
  7.         //String S3 = "abcdabccab";
  8.         //String S4 = "bcdaccabaabc";
  9.         List<String> com = commonSubstring(S1, S2);
  10.         for (String s: com){
  11.             System.out.println(s);
  12.         }
  13.     }
  14.     public static List<String> commonSubstring(String s1, String s2) {
  15.         Integer match[][] = new Integer[s1.length()][s2.length()];
  16.         int len1 = s1.length();
  17.         int len2 = s2.length();
  18.         int max = Integer.MIN_VALUE;    // max length of the string
  19.         ArrayList<String> result = null;    // result list
  20.         for (int i = 0; i < len1; i++) {    // row iteration
  21.             for (int j = 0; j < len2; j++) {  // column iteration
  22.                 if (s1.charAt(i) == s2.charAt(j)) {
  23.                     if (i == 0 || j == 0)
  24.                         match[i][j] = 1;
  25.                     else
  26.                         match[i][j] = match[i - 1][j - 1] + 1;
  27.                     // if you find a longer common substring re-initialize 
  28. // the max count and update the result list
  29.                     if (match[i][j] > max) {
  30.                         max = match[i][j];
  31.                         result = new ArrayList<String>();
  32.                         // substring starts at i-max+1 & ends at i
  33.                         result.add(s1.substring(i - max + 1, i + 1));
  34.                     }
  35.    // else if you find a common substring with the max length, 
  36.   // store it in the list
  37.                     else if (match[i][j] == max) {
  38.                         result.add(s1.substring(i - max + 1, i + 1));
  39.                     }
  40.                 } else {
  41.                     match[i][j] = 0;
  42.                 }
  43.             }
  44.         }
  45.         return result;
  46.     }
  47. }
Output:
LCL
CLC

2019-04-07

How do you add two numbers represented by linked lists ??

Problem statement:
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.


Example:


Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)

Output: 7 -> 0 -> 8
Explanation: 342 + 465 = 807.

class Node {
    int data;
    Node next;

    Node(int data) {

        this.data = data;
    }

    Node() {

    }

    @Override

    public String toString() {
        return "Node{" +
                "data=" + data +
                ", next=" + next +
                '}';
    }
}

public class AddTwoNumbers {

    static Node head = null;

    public static void main(String[] args) {

        Node n1 = new Node(1);
        Node n2 = new Node(2);
        Node n3 = new Node(3);

        n1.next = n2;

        n2.next = n3;

        Node n4 = new Node(1);

        Node n5 = new Node(2);
        Node n6 = new Node(3);

        n4.next = n5;

        n5.next = n6;

        Node result = calculate(n1, n4);

        System.out.println(result);
    }

    static Node calculate(Node a, Node b) {

        //        //FIXME: Write your logic
        //  1, 2, 3
        //  1, 2, 3
        int carry = 0;

        while (a != null && b != null) {

            addLast(a.data + b.data);

            a = a.next;

            b = b.next;
        }
        return head;
    }

    public static void addLast(int data) {


        if (head == null) {

            head = new Node(data);
            return;
        }
        Node last = head;
        while (last.next != null) {
            last = last.next;
        }
        last.next = new Node(data);
    }
}


Output:
Node{data=2, next=Node{data=4, next=Node{data=6, next=null}}}

2019-03-24

Convert String to an int

How to convert a String to an int ?

String str = "1234";

Integer x = Integer.valueOf(str);
// or
int y = Integer.parseInt(str);



Groovy : Use Collect with Initial Collection Value

The collect() method in Groovy can be used to iterate over collections and transform each element of the collection. The transformation is defined in as a closure and is passed to the collect() method. But we can also add an initial collection to which the transformed elements are added.


// Collect without
// initial collection.
assert [0,2,4,6] == (0..3).collect { it * 2 }
assert ['Groovy', 'Grails'] == [lang: 'Groovy', framework: 'Grails'].collect { it.value }

// Collect with initial collection argument.
assert [0, 1, 2, 3] == [2, 3].collect([0, 1]) { it }
assert [0, 3, 6, 9] == [2, 3].collect([0, 3], { it * 3})
assert ['Gradle', 'groovy', 'grails'] == ['Groovy', 'Grails'].collect(['Gradle']) { it.toLowerCase() }
assert ['m','r','h','a','k','i'] == [4, -3, 7, 5].collect(['m', 'r']) { (it + 100) as char }

Groovy : Regular Expressions example

In Groovy we use the =~ operator (find operator) to create a new matcher object. If the matcher has any match results we can access the results by invoking methods on the matcher object. But Groovy wouldn't by groovy if we could access the results easier. Groovy enhances the Matcher class so the data is available with an array-like syntax. If we use groups in the matcher the result can be accessed with a multidimensional array. Although the result of the =~ operator is a matcher object in a conditional statement the result will be converted to a Boolean values.

We can use a second operator, ==~ (match operator), to do exact matches. With this operator the matches() method is invoked on the matcher object. The result is a Boolean value.


def finder = ('groovy' =~ /gr.*/)
assert finder instanceof java.util.regex.Matcher

def matcher = ('groovy' ==~ /gr.*/)
assert matcher instanceof Boolean

assert 'Groovy rocks!' =~ /Groovy/  // =~ in conditional context returns boolean.
assert !('Groovy rocks!' ==~ /Groovy/)  // ==~ looks for an exact match.
assert 'Groovy rocks!' ==~ /Groovy.*/

def cool = /gr\w{4}/  // Start with gr followed by 4 characters.
def findCool = ('groovy, java and grails rock!' =~ /$cool/)
assert 2 == findCool.count
assert 2 == findCool.size()  // Groovy adds size() method.
assert 'groovy' == findCool[0]  // Array-like access to match results.
assert 'grails' == findCool.getAt(1)

// With grouping we get a multidimensional array.
def group = ('groovy and grails, ruby and rails' =~ /(\w+) and (\w+)/)
assert group.hasGroup()
assert 2 == group.size()
assert ['groovy and grails', 'groovy', 'grails'] == group[0]
assert 'rails' == group[1][2]

// Use matcher methods.
assert 'Hi world' == ('Hello world' =~ /Hello/).replaceFirst('Hi')

// Groovy matcher syntax can be used in other methods.
assert ['abc'] == ['def', 'abc', '123'].findAll { it =~ /abc/ }
assert [false, false, true] == ['def', 'abc', '123'].collect { it ==~ /\d{3}/ }

2019-03-15

Intellij idea: search anything with file extension

1. Press Ctrl+shift+f button
2. Check mark "file mask" checkbox
3. Enter extension "*. example" in this format

2019-01-01

Google Adsense High Paying Keywords 2019

Google AdSense is one of the best and leading monetizing networks to generate money from your blog. Most of the new bloggers or webmasters use AdSense as their only way to generate income from their websites. But the majority of them don’t know the importance of high CPC keywords even me at the starting of my blogging career.


High Paying keywords list for Google Adsense.
1.Adobe illustrator classes (10$)
2.ANNUITY SETTLEMENT ($100.72)
3.ASBESTOS LAWYERS ($105.84)
4.AUTO ACCIDENT ATTORNEY ($75.64)
5.AUTOMOBILE ACCIDENT ATTORNEY ($76.57)
6.Bankruptcy lawyer (23$)
7.BEST CRIMINAL LAWYER IN ARIZONA ($97.93)
8.Best Seo company (16$)
9.Best social media platforms (15$)
10.Best social media platforms for business (20$)
11.BETTER CONFERENCING CALLS ($91.44)
12.Business finance group (20$)
13.Business management software (15$)
14.CAR ACCIDENT LAWYERS ($75.17)
15.CAR DONATE ($88.26)
16.CAR INSURANCE IN SOUTH DAKOTA ($92.72)
17.CAR INSURANCE QUOTES COLORADO ($100.93)
18.CAR INSURANCE QUOTES MN ($94.29)
19.CAR INSURANCE QUOTES PA ($92.88)
20.CAR INSURANCE QUOTES UTAH ($97.92)
21.Casino (100$)
22.Casino reviews (54$)
23.CHEAP AUTO INSURANCE IN VA ($93.84)
24.CHEAP CAR INSURANCE FOR LADIES ($92.23)
25.CHEAP CAR INSURANCE IN VIRGINIA ($92.03)
26.CHEAP DOMAIN REGISTRATION HOSTING ($98.39)
27.Christmas cards (11$)
28.Computer science classes online (23$)
29.CRIMINAL DEFENSE ATTORNEYS FLORIDA ($98.07)
30.Criminal defense lawyer (28$)
31.Criminal lawyer (30$)
32.Custom Christmas cards (14$)
33.Custom WordPress theme designer (16$)
34.DALLAS MESOTHELIOMA ATTORNEYS ($94.33)
35.DAYTON FREIGHT LINES ($99.39)
36.DONATE A CAR IN MARYLAND ($98.51)
37.DONATE CAR FOR TAX CREDIT ($126.65)
38.Donate Car To Charity CALIFORNIA ($130.25)

High CPC Adsene Ad Network List High CPC rate 2019

250 High CPC Adsene Ad Network List High CPC rate


Adsene High CPC Ad Network List    High CPC Rate

1 Hearst Digital Media $10.80
2 InPowered $10.19
3 Kapanlagi $10.13
4 Yandex.ru $10.11
5 Open Inventory $9.24
6 WebAds $8.71
7 Madhouse Mobile $8.12
8 CPX Interactive $7.75
9 Guru Media $7.41
10 Advertising Alliance $6.59
11 Compare Group $6.33
12 transcosmos $6.09
13 eHealthcare Solutions $6.06
14 KPI Solutions $5.70
15 ScaleOut $5.65
16 Bannerconnect $5.43
17 Independent Traveler $5.40
18 Quantcast $5.29
19 MediaScience $5.17
20 AdKnowledge $5.11
21 Barons Media $4.91
22 Specific Media $4.81
23 InterCLICK $4.73
24 Dun & Bradstreet $4.70
25 Advantage Media $4.45
26 Bridge Marketing $4.41
27 Belgacom $4.39
28 Connexity $4.32
29 HealthiNation $4.30
30 Advertising Technologies $4.28
31 remerge $4.19
32 Media Decision $4.17
33 Performance Advertising $4.04
34 AdGear $3.93
35 Business Ad $3.93
36 Cyber Communications $3.69
37 Motricity $3.66
38 TruEffect $3.60
39 TCS Bank $3.46
40 MediaMind $3.43