Skip Spring placeholder substitution

I’m using Spring properties placeholders in my application. One of my properties values contains something Spring interprets as a placeholder, but I don’t want it:

@Value("${propertyName}")
private String property;

My property is well defined:

propertyName=Welcome ${name}

Without surprise I get an error :

Could not resolve placeholder ‘name’ in value “Welcome ${name}”

propertyName is something I want to interpret myself, so I don’t want ${name} to be resolved by Spring. Is this possible?

How can I get the IP address of the default gateway in Swift 3+

I’ve just started working with Swift after a while Objective C. I Need the IP address of the Router.

I already have this code working in my program to get the IP address of the device:

func getWiFiAddress() -> String? {
    var address : String?

    // Get list of all interfaces on the local machine:
    var ifaddr : UnsafeMutablePointer<ifaddrs>?
    guard getifaddrs(&ifaddr) == 0 else { return nil }
    guard let firstAddr = ifaddr else { return nil }

    // For each interface ...
    for ifptr in sequence(first: firstAddr, next: { $0.pointee.ifa_next }) {
        let interface = ifptr.pointee

        // Check for IPv4 or IPv6 interface:
        let addrFamily = interface.ifa_addr.pointee.sa_family
        if addrFamily == UInt8(AF_INET) || addrFamily == UInt8(AF_INET6) {

            // Check interface name:
            let name = String(cString: interface.ifa_name)
            if  name == "en0" {

                // Convert interface address to a human readable string:
                var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
                getnameinfo(interface.ifa_addr, socklen_t(interface.ifa_addr.pointee.sa_len),
                            &hostname, socklen_t(hostname.count),
                            nil, socklen_t(0), NI_NUMERICHOST)
                address = String(cString: hostname)
            }
        }
    }
    freeifaddrs(ifaddr)

    return address
}

I’ve also found this code for Objective C. I have experience in Objective C but I don’t know how to Convert the code to Swift 3+
How to get router IP address in Objective C?

dry-validation: dynamically change locale?

I am using Trailblazer 2.1 (and dry-validation (0.11.1) consequently) in a Rails 5 project.

I have 2 different language locales bound to the user profile.

When I dynamically change the user’s locale – dry-validation does not notice it – and keeps yielding the validation errors with a former locale.

What’s wrong? Is this or bug or a feature? Why doesn’t dry-validation respond to the locale change? How to fix it?

Here’s my locale switching code:

class ApplicationController < ActionController::Base

  before_action :switch_locale

  def switch_locale

    I18n.locale = current_user.locale

  end

end

Remote login using php curl request

Is it possible to remote login, if <form has not action and method="POST" and also hidden input?

I am new in php curl, so i have many questions and i am fetching many problem.

How to i make curl request without action, method=”POST” and on hidden input.

Here is full form html code:

<form class="RFjuSb bxPAYd k6Zj8d" jsname="nUpftc" jscontroller="gsfs7c" jsaction="click:v3HUwf(preventDefault=true|DPJEMd),sJqX4b(Cuz2Ue),rYhRle(preventDefault=true|RTjbJ);LfGMDc:RbvWUd;h4C2te:NGpkv;mejaPb:WWkjY;E855kc:hRLCTe;u3KAb:UHZ0U;azuPB:s57X0c;sPvj8e:XyQaue;rcuQ6b:WYd;EJh3N:.CLIENT;submit:.CLIENT;WMmLoc:.CLIENT;ms5v1:.CLIENT" data-locale="en" data-is-refreshable="" data-branding="jcJzye" role="presentation" novalidate="">

    <div jsname="uybdVe" class="mbekbe bxPAYd" role="presentation">
        <div jsname="USBQqe" class="iUe6Pd Us7fWe JhUD8d" role="presentation">
            <div class="RCum0c">


                <div jscontroller="zB5w" jsaction="keydown:C9BaXe;YqO5N:di0fJ;O22p3e:fpfTEe;AHmuwe:Jt1EX;rcuQ6b:WYd;EJh3N:WYd" jsname="dWPKW" class="fQxwff" role="presentation" data-is-rendered="true">
                    <div class="rFrNMe uIZQNc og3oZc sdJrJc Tyc9J" jscontroller="pxq3x" jsaction="clickonly:KjsqPd; focus:Jt1EX; blur:fpfTEe; input:Lg5SV;" jsshadow="" jsname="Vsb5Ub">
                        <div class="aCsJod oJeWuf">
                            <div class="aXBtI Wic03c">
                                <div class="Xb9hP"><input type="email" class="whsOnd zHQkBf" jsname="YPqjbf" autocomplete="username" spellcheck="false" tabindex="0" aria-label="Email or phone" name="identifier" id="identifierId" dir="ltr" data-initial-dir="ltr" data-initial-value="">
                                    <div jsname="YRMmle" class="AxOyFc snByac" aria-hidden="true">Email or phone</div>
                                </div>
                                <div class="i9lrp mIZh1c"></div>
                                <div jsname="XmnwAc" class="OabDMe cXrdqd Y2Zypf"></div>
                            </div>
                        </div>
                        <div class="LXRPh">
                            <div jsname="ty6ygf" class="ovnfwe Is7Fhb"></div>
                            <div jsname="B34EJ" class="dEOOab RxsGPe" aria-atomic="true" aria-live="assertive"></div>
                        </div>
                    </div>
                </div>

                <input type="password" name="hiddenPassword" jsname="RHeR4d" class="yb9KU" tabindex="-1" aria-hidden="true">

            </div>
            <div jscontroller="D02xdc" jsaction="JIbuQc:UHZ0U(tJiF1e),s57X0c(LwtuAc); click:qrB6Cf(NjDI7d);NNw7lb:V2GCBc;U57Bbf:OGJhZ;PueeNd:hRLCTe;" jsname="yXBf7b" class="GtglAe" data-button-id-prefix="identifier">
                <div class="OZliR">
                    <div role="button" id="identifierNext" class="O0WRkf zZhnYe e3Duub C0oVfc Zp5qWd Hj2jlf dKVcQ" jscontroller="VXdfxd" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue;touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc(preventMouseEvents=true|preventDefault=true); touchcancel:JMtRjd;focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef;" jsshadow="" jsname="tJiF1e" aria-disabled="false" tabindex="0">
                        <div class="Vwe4Vb MbhUzd" jsname="ksKsZd"></div>
                        <div class="ZFr60d CeoRYc"></div>
                        <content class="CwaK9"><span class="RveJvd snByac">Next</span></content>
                    </div>
                </div>
            </div>
        </div>
    </div>

</form>

This is form line:

<form class="RFjuSb bxPAYd k6Zj8d" jsname="nUpftc" jscontroller="gsfs7c" jsaction="click:v3HUwf(preventDefault=true|DPJEMd),sJqX4b(Cuz2Ue),rYhRle(preventDefault=true|RTjbJ);LfGMDc:RbvWUd;h4C2te:NGpkv;mejaPb:WWkjY;E855kc:hRLCTe;u3KAb:UHZ0U;azuPB:s57X0c;sPvj8e:XyQaue;rcuQ6b:WYd;EJh3N:.CLIENT;submit:.CLIENT;WMmLoc:.CLIENT;ms5v1:.CLIENT" data-locale="en" data-is-refreshable="" data-branding="jcJzye" role="presentation" novalidate="">

This is first input:

<input type="email" class="whsOnd zHQkBf" jsname="YPqjbf" autocomplete="username" spellcheck="false" tabindex="0" aria-label="Email or phone" name="identifier" id="identifierId" dir="ltr" data-initial-dir="ltr" data-initial-value="">

and this is hidden input:

<input type="password" name="hiddenPassword" jsname="RHeR4d" class="yb9KU" tabindex="-1" aria-hidden="true">

Again i wants to say, i am new in this programming, so please don’t fell boring and don’t angry with me. thanks

NB: if i don’t understand you, please comment below, i will try to my best to explain again.

Edited:
I found this code on stackoverflow and tried this.

<?php

$USERNAME = 'gmail';
$PASSWORD = 'gmail pass';
$COOKIEFILE = 'cookies.txt';

// initialize curl handle used for all requests
$ch = curl_init();

// set some options on the handle
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $COOKIEFILE);
curl_setopt($ch, CURLOPT_COOKIEFILE, $COOKIEFILE);
curl_setopt($ch, CURLOPT_HEADER, 0);  
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);

// url of our first request fetches the account login page
curl_setopt($ch, CURLOPT_URL, 
  'https://accounts.google.com/ServiceLogin?hl=en&service=alerts&continue=http://www.google.com/alerts/manage');
$data = curl_exec($ch);

// extract form fields from account login page
$formFields = getFormFields($data);

// inject email and password into form
$formFields['Email']  = $USERNAME;
$formFields['Passwd'] = $PASSWORD;
unset($formFields['PersistentCookie']);

$post_string = http_build_query($formFields); // build urlencoded POST string for login

// set url to login page as a POST request
curl_setopt($ch, CURLOPT_URL, 'https://accounts.google.com/ServiceLoginAuth');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);

// execute login request
$result = curl_exec($ch);

// check for "Redirecting" message in title to indicate success
// based on your language - you may need to change this to match some other string
if (strpos($result, '<title>Redirecting') === false) {
    die("Login failed");
    var_dump($result);
}

// login likely succeeded - request account page; unset POST so we do a regular GET
curl_setopt($ch, CURLOPT_URL, 'https://mail.google.com/mail/h/jeu23doknfnj/?zy=e&f=1');
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, null);

// execute request for login page using our cookies
$result = curl_exec($ch);

echo $result;


// helpef functions below

// find google "#gaia_loginform" for logging in
function getFormFields($data)
{
    if (preg_match('/(<form.*?class=.?RFjuSb.*?<\/form>)/is', $data, $matches)) {
        $inputs = getInputs($matches[1]);

        return $inputs;
    } else {
        die('didn\'t find login form');
    }
}

// extract all <input fields from a form
function getInputs($form)
{
    $inputs = array();

    $elements = preg_match_all('/(<input[^>]+>)/is', $form, $matches);

    if ($elements > 0) {
        for($i = 0; $i < $elements; $i++) {
            $el = preg_replace('/\s{2,}/', ' ', $matches[1][$i]);

            if (preg_match('/name=(?:["\'])?([^"\'\s]*)/i', $el, $name)) {
                $name  = $name[1];
                $value = '';

                if (preg_match('/value=(?:["\'])?([^"\'\s]*)/i', $el, $value)) {
                    $value = $value[1];
                }

                $inputs[$name] = $value;
            }
        }
    }

    return $inputs;
}
?>

Integrating Flask-Python with HTML and JavaScript

In my code , I want the Javascript defined in index.html page to run when a particular condition in app.py is true, else the script should not run. How can I achieve this?

app = Flask(__name__)
@app.route('/',methods=["GET","POST"])
def index():
    #print "came here"
    if request.method == 'POST':
        search_token = request.args.get("validationtoken")
        print "search", search_token
        if search_token != None:
            # text = search_token
            resp = Response(search_token, status=200, mimetype='plain/text')
            print "resp",resp
            return resp
        else:
             print " Notification received "
             ##### HERE I NEED TO CALL THE Java SCRIPT DEFINED IN HTML PAGE TO EXECUTE


    elif request.method=="GET":
         code=request.args.get('code')
         state=request.args.get('state')
         ----

pls help..

Need Data in two serial ports

I have /dev/ttyS1 with is getting GPS data.
I want to get the same data in another serial port also like /dev/COM8

What is the possibility to get data in both serial ports.

I tried by doing soft link
ln -s /dev/ttyS1 /dev/COM8

I can get data on both ports now. But if i tried to open Both port at a time using application, I cannot get data.

Can anyone help me to resolve this issue ?

have a condition in a variable in PHP

I am passing a condition as a string to my method and I want to use it inside an if statement like so but it doesn’t seem to work.

// $condition could be a > or < or == etc...
if (!( $field $condition $value )) {
         //code here
}

Is there a way to do this in PHP. I have tried wrapping $condition in curly brackets but does not work.

many thanks in advance

How do I compare two MySQL tables and then update one of them

I have two tables called it_systems and departments. The it_systems table contains all the department names but I want to add in all their ID’s so I can remove the deprtmentNames column. so I need to compare the name with the name in the department table and then insert the departments.id into the it_systems.departmentid but seems to be falling flat as MySQL is not that great.
This is how far I have got

UPDATE 
it_system_additional INNER JOIN
(
    SELECT departmentName
    FROM it_system_additional
) departments ON departments.DepartmentName = it_system_additional.departmentName
SET it_system_additional.departmentid = departments.departmentId

but I keep getting this error
[Err] 1054 – Unknown column ‘departments.departmentId’ in ‘field list’
even though I know that column does exist.

Any help will be greatly appreciated.
Thanks in advance.
Andrea

“Handshake Protocol\Distinguished names” not present in Server certificate request

I am trying to connect to a remote host using x509 certificate. While TLS handshake the connection gets aborted with error message Handshake Failure (40). I made some inspection about this and found out After server made a request to produce valid certificate to client, Client is not producing any certificate.

Upon looking in to more details I found that on Server certificate request it will give all the CA names which they will accept. And wireshark shows my Server certificate request does not have portion called "Handshake Protocol\Distinguished names" where server can tell which all are the trusted CA’s, So I assume this is the reason why my machine couldn’t find the certificate needed. Can anyone please point out what sever certificate request doesn’t have this section?
enter image description here

enter image description here

enter image description here