Posts

Smarty replace the string and use another variable instead of that -

i have form in smarty this <div class="psmd_content"> <div class="psmd_text"> <form class="psmd-form psmd_"> <div class="psmd-fields"> {if {$display_fields} == 1 || {$display_fields} == 2 } <input type="text" placeholder="enter first name" name="psmd_fname" class="psmd_fname"> {/if} {if {$display_fields} == 2} <input type="text" placeholder="enter last name" name="psmd_lname" class="psmd_lname"> {/if} <input type="text" placeholder="enter email" name="psmd_email" class="psmd_email"> </div> <div class="psmd-btn-cont"> <button class="psmd-btn">{$submit_button_text}</button> </div> <div class="psmd-...

regex - Test for filtering illegal characters from a string -

i need filter out illegal unicode characters string outlined in guide preparing data amazon cloud search. both json , xml batches can contain utf-8 characters valid in xml. valid characters control characters tab (0009), carriage return (000d), , line feed (000a), , legal characters of unicode , iso/iec 10646. fffe, ffff, , surrogate blocks d800–dbff , dc00–dfff invalid , cause errors. (for more information, see extensible markup language (xml) 1.0 (fifth edition).) can use following regular expression match invalid characters can remove them: /[^\u0009\u000a\u000d\u0020-\ud7ff\ue000-\ufffd]/ . i trying write test success , failure cases, having trouble writing unicode characters in prohibited range. edit2: javascript language trying write tests in edit1: link amazon cloudsearch documentation: http://docs.aws.amazon.com/cloudsearch/latest/developerguide/preparing-data.html in javascript can use unicode escape sequences produce invalid characters strings, so...

python - Why reflectbox doesn't work when pdflatex is called with the dvips option of graphicx package -

general overview i want generate pdf image containing latex-style flipped character matplotlib associated package graphicx. here python code: import matplotlib params = {'backend':'pdf', 'text.latex.preamble':['\usepackage{amsmath}', '\usepackage{graphicx}'], 'text.usetex':true} matplotlib.rcparams.update(params) import matplotlib.pyplot plt fig = plt.figure() axe = fig.add_subplot(111) axe.set_xlabel('\text{\reflectbox{$\boldsymbol{\gamma}$}}') axe.savefig('image.pdf',bbox_inches='tight') i non-flipped character whereas same latex command compiled pdflatex works fine , gives horizontaly flipped character. apparently matplotlib generates latex-style calling dvi latex compiler force use [dvips] option graphicx package. implementation test i tried same syntax directly in latex , observed [dvips] option of package graphicx disable flipping behaviour of...

python - OpenCV findContours() complains if used with black-white image -

Image
i want perform edge detection following code. error because of image color depth. error makes in eyes no sense, convert image gray-scale image, , in subsequent step black , white image, working correctly. when call findcontours error. import cv2 def bw_scale(file_name, tresh_min, tresh_max): image = cv2.imread(file_name) image = cv2.cvtcolor(image, cv2.color_rgb2gray) #(thresh, im_bw) = cv2.threshold(image, tresh_min, tresh_max, cv2.thresh_binary | cv2.thresh_otsu) (thresh, im_bw) = cv2.threshold(image, tresh_min, tresh_max, 0) cv2.imwrite('bw_'+file_name, im_bw) return (thresh, im_bw) def edge_detect(file_name, tresh_min, tresh_max): (thresh, im_bw) = bw_scale(file_name, tresh_min, tresh_max) contours, hierarchy = cv2.findcontours(thresh, cv2.retr_tree, cv2.chain_approx_simple) if __name__ == '__main__': edge_detect('test.jpg', 128, 255) i error: dgrat@linux-v3pk:~> python aoi.py opencv error: unsupported form...

java - How to display the value of a HashMap key when user clicks autocom -

i'm new android development , java programming. in code (shown below), when user clicks search button , value of key displayed in displayfield textview . want value displayed when user clicks (touches) item on autocompletetextview dropdown items, without needing click search button . import java.util.hashmap; import java.util.map; import android.content.context; import android.os.bundle; import android.support.v7.app.actionbaractivity; import android.view.view; import android.view.inputmethod.inputmethodmanager; import android.widget.arrayadapter; import android.widget.autocompletetextview; import android.widget.button; import android.widget.edittext; import android.widget.textview; public class mainactivity extends actionbaractivity { map<string, string> map = new hashmap<string, string>(); private edittext autocomplete_searchfield; private textview displayfield; string note; @override protected void oncreate(bundle sav...

mysql - PDO via SSH2 in PHP? -

i'm trying access remote mysql database reachable locally (localhost). my code looks this: $connection = ssh2_connect('ip server', 22); if (ssh2_auth_password($connection, 'user', 'password')) { echo "authentication successful!\n"; } else { die('authentication failed...'); } $tunnel = ssh2_tunnel($connection, '127.0.0.1', 3306); try { $this->_connection = new pdo($dsn, $config['login'], $config['password'], $flags); $this->connected = true; if (! empty($config['settings'])) { foreach ($config['settings'] $key => $value) { $this->_execute("set $key=$value"); } } } catch (pdoexception $e) { throw new missingconnectionexception(array( 'class' => get_class($this), 'message' => $e->getmessage() ...

c# - Swipe between webviews in Xamarin -

anyone knows way swipe between webview s using c# in xamarin ? i have list of static urls want swipe between cards (tinder like). each webview load 1 url , user able swipe between them carousel. best practice ways lot.