Posts

Showing posts from March, 2014

port - TcpListener perform code after accepting a SYN packet in C# -

i'm creating "port honey pot" in c#. listens clients tcp server: tcplistener.accepttcpclient(); the code keeps on running after client connects server. however, want server perform code after accepting syn packet. is possible? there other tcp server implementation allows it? to knowledge c# tcp sockets not give access packet descriptors such syn. cannot open port in promiscuous mode. you should open udp socket, instead or take @ libraries lidgren. but then, again, won't able switch udp tcp, have 1 or other. maybe if explain why , need there other ways.

javascript - AngularJs - ng-disabled -

i have following 2 input fields. difference ng-disabled directive. so, there repetition of code.i looking forward use 1 input tag fulfilling both purposes. how can combine these 2 inputs showing/hiding ng-disabled directive based on condition? <input type="radio" name="student_role" ng-model="student.roleid" /> <input type="radio" name="role" ng-disabled="loggedstudent == student.student.email" ng-model="student.roleid" /> just try <input type="radio" name="role" ng-disabled="(loggedstudent == student.student.email) ? true : false" ng-model="student.roleid" />

swift - Drawing on UIImage in UIScrollView -

the problem this going sound crazy. i'm making drawing app , want users able draw on images bigger or smaller screen. when user selects image photo library put image view in scroll view. user draws on image views same dimensions selected image , in scroll view on top of other one. scrolling of 2 scroll views synchronized when draw scroll drawing appears above image (in right place). reason however, when user selects long image (let's 400 x 2000), drawing works @ top of image, when scroll down draw, lines draw go top. can't figure out what's going wrong... code below. about code camerastill image view containing image drawable height of image myscroll scroll view image mainimageview , tempimageview , undo1 , undo2 , undo3 drawing layers drawscroll scroll view drawing layers image selection func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingimage image: uiimage!, editinginfo: [nsobject : anyobject]!) { self.dismi

Magento Upgrading Magento 1.3 to 1.4 Class 'File' not found Cache.php -

upgrading magento 1.3 ( using full package -> overwrite ) . fatal error: class 'file' not found in /home/www/r2h/mysite.net/public/lib/zend/cache.php on line 153 something cache guess..? have cleared apc , there no file in /app/etc delete clears cache. i'm bit baffled now.? :-) magento 1.4 , newer works bit different on clearing cache. that file named cache.ser (i think that's name) no longer exists , function has been moved core_cache_option table in database. turn off cache in database. to manually clear magento cache, delete subdirectories in app/var/cache .

php - Making this into a cron job? -

found lovely piece of sql query code excluded multiple images on magento. update catalog_product_entity_media_gallery_value set disabled = 0; update catalog_product_entity_media_gallery_value mgv, (select entity_id, count(*) image_count, max(value_id) value_id catalog_product_entity_media_gallery mg group entity_id having image_count = 2) mg set mgv.disabled = 1 mgv.value_id = mg.value_id i looking have run cron job instead of direct database have no idea how write one. can made cron job? point me in right direction please. using command line tool comes databases wrap these statements in script, this, using mysql /path/to/mysql --whateverparametersyouneed yourdb << here update catalog_product_entity_media_gallery_value set disabled = 0; update catalog_product_entity_media_gallery_value mgv, (select entity_id, count(*) image_count, max(value_id) value_id catalog_product_entity_media_gallery mg group entity_id having image_count = 2) mg set

How to convert pdf into text file using itext liberary -

below code converting pdf file text file. code runs, doesn't generate resulting text file (sample.txt). can shed light on this? code partly based on example of first itext in action book... import com.lowagie.text.*; import com.lowagie.text.pdf.*; public class convertpdftotext { public static void main(string[] args) throws ioexception { try { document document = new document(); document.open(); pdfreader reader = new pdfreader("data dictinary a4.pdf"); pdfdictionary dictionary = reader.getpagen(1); prindirectreference reference = (prindirectreference) dictionary.get(pdfname.contents); prstream stream = (prstream) pdfreader.getpdfobject(reference); byte[] bytes = pdfreader.getstreambytes(stream); prtokeniser tokenizer = new prtokeniser(bytes); fileoutputstream fos=new fileoutputstream("sample.txt"); stringbuffer

c# - Collapsed Grid in StackPanel change position of other controls in StackPanel -

i have xaml page: <stackpanel orientation="horizontal"> <grid x:name="inkgrid0" margin="0,0,0,0" horizontalalignment="left" > <canvas x:name="inkcanvas0" width="570"> <canvas.background> <imagebrush x:name="dimage0" imagesource="{binding}"/> </canvas.background> </canvas> </grid> <grid x:name="inkgrid1" margin="0,0,0,0" horizontalalignment="right" > <canvas x:name="inkcanvas1" width="570"> <canvas.background> <imagebrush x:name="dimage1" imagesource="{binding}"/> </canvas.background>

python - Issue encoding an email for my app -

i configuring app operates subscriptions emails, runs except part of form should encode email received. this error obtained when sign email: **unicode-objects must encoded before hashing** traceback: file "/home/draicore/sunflower/ambiente1/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response 132. response = wrapped_callback(request, *callback_args, **callback_kwargs) file "/home/draicore/sunflower/ambiente1/lib/python3.4/site-packages/django/views/generic/base.py" in view 71. return self.dispatch(request, *args, **kwargs) file "/home/draicore/sunflower/ambiente1/lib/python3.4/site-packages/django/views/generic/base.py" in dispatch 89. return handler(request, *args, **kwargs) file "/home/draicore/sunflower/ambiente1/lib/python3.4/site-packages/django/views/generic/edit.py" in post 214. if form.is_valid(): file "/home/draicore/sunflower/ambiente1/lib/python3.4/site-packages/django/forms/forms.py"

heroku - How to schedule task with certain (say, 5) hour period? -

it common use crontab schedule task. however, found crontab can schedule tasks on minutely, hourly or daily basis. if want schedule task on every 4 hours, can still make setting 6 daily task. however, if want have period doesn't make 1 day, say, task every 5 hours / 7 hours? there way set task hour period in crontab or using other tools? (would better if tool can run on paas heroku / openshift) here example of using minutely crontab setup task happens every 5 minutes ( https://github.com/openshift-quickstart/openshift-cacti-quickstart/blob/master/.openshift/cron/minutely/cactipoll ) if [ ! -f $openshift_data_dir/last_run ]; touch $openshift_data_dir/last_run fi if [[ $(find $openshift_data_dir/last_run -mmin +4) ]]; #run every 5 mins rm -f $openshift_data_dir/last_run touch $openshift_data_dir/last_run php $openshift_repo_dir/php/poller.php > $openshift_data_dir/cacti.log 2>&1 fi basically task runs every minute, gets executed after 5 min

event - object referance is not set to an instanse of an object windows forms C# -

i trying raise event in dll file refrenced windows forms project. i have following message when run program "object not set instace of object": namespace server { public delegate void messagehnadler(); public class classserver { public event messagehnadler messageforchat public string message { get; set; } public socket listenersocket; public binaryformatter transbinary; public thread threadingserver; public tcplistener listenerserver; private list<tcpclient> connectedclients = new list<tcpclient>(); public bool openserver(string ipaddress, int portnumber) { try { listenerserver = new tcplistener(ipaddress.parse(ipaddress), portnumber);//creating listener clients connect listenerserver.start(); threadingserver = new thread(loopthroughclients); threadingserver.start(); threadingserver = new thread(getmessage); thr

go - Reading database rows into map and appending to a slice of maps -

i trying use maps , slice of maps store rows returned database query. in every iteration of rows.next() , in final slice of 1 same row query. seems problem related memory place being same store cols , yet not resolve until now. what thing missing here: the source code follows: package main import ( "database/sql" _ "github.com/lib/pq" "fmt" "log" "reflect" ) var mymap = make(map[string]interface{}) var myslice = make([]map[string]interface{}, 0) func main(){ fmt.println("this go playground.") // db connection- db, err := sql.open("postgres", "user=postgres dbname=proj2-dbcruddb-dev password=12345 sslmode=disable") if err != nil { log.fatalln(err) } rows, err := db.query("select id, username, password userstable") defer rows.close() if err != nil { log.fatal(err) } colnames, err := rows.columns() if err

android - managed profile on a second user -

i tried use basicmanagedprofile sample provided goggle set managed profile. when use on primary user, working fine. if create secondary user , try install app also, error occurs. says managed profils have set owner of device. how can set managed profile on second user ? thanks according documentations, managed profile can enabled primary user. although called 'managed profile' pretty similar in inside process secondary user. in fact similar having secondary user in same launcher! same rules of creating secondary users applied when creating managed profile. according multi-user feature of android os, primary user can create other users (which secondary users). same rule applies here , primary user can enable managed profile (which closer creating secondary user). thanks.

C# ASP.NET retrieve DATE only issue from MS SQL 2014 -

i have table contain column having data type of date. i've checked records inside mssql, giving correct result want such 16-jun-2014. but in c# razor code, tried retrieve with @foreach (var row in db.query("select * table_a")) { @row.date } in website view, giving me 16-jun-2014 12:00:00 am. can help? .net has datetime type, includes both date , time. have format way want be, example @row.date.tostring("dd'-'mmm'-'yyyy"); you might need set desired culture also, if it's not correct default. can either set application's culture, or provide culture specific call @row.date.tostring("dd'-'mmm'-'yyyy", new cultureinfo("en-us")); of course it's better create cultureinfo once , save in variable create every time called.

ios - Parse local json to UILabels -

i'm trying parse json file can use it's contents nsstrings , display in uilabels throughout application. my json: { "customtext": [ { "bodytext": "this body text", "logintext": "this logintext", "extratext": "this text" } ] } my code: nsstring *filepath = [[nsbundle mainbundle] pathforresource:@"file" oftype:@"json"]; nsdata *content = [[nsdata alloc] initwithcontentsoffile:filepath]; nsmutabledictionary *json = [nsjsonserialization jsonobjectwithdata:content options:kniloptions error:nil]; nsarray *customstrings = json[@"customtext"]; nsstring *body = [customstrings valueforkey:@"bodytext"]; nsstring *login = [customstrings valueforkey:@"logintext"]; self.labeltext.text = body; i'm not sure why breaks, have looks , surprisingly didn't find on how best use local json file.

Ubuntu: When upstart service is run with user root, it returns Unknown job -

as can see following output(not limited mysql, other service gives similar result), when run service/status sudo, gives correct result, gives 'unknown job' when run directly root. i googled lot, key words 'status/service' have multiple meaning, found nothing related problem, similar questions answering why 'unknown job' when run 'sudo service...'. root@ubuntu-user:/etc/init# status mysql status: unknown job: mysql root@ubuntu-user:/etc/init# sudo status mysql mysql stop/waiting root@ubuntu-user:/etc/init# service mysql status status: unknown job: mysql root@ubuntu-user:/etc/init# sudo service mysql status mysql stop/waiting i have checked strace , didn't find anything(output long), , think it's restriction of status , service , nothing in man page root or sudo . question: why service gives unknown job when runs service without sudo ? os: ubuntu 14.04 lts if use upstart v1.4+, try setuid , setgid. more details here: htt

vb.net - Inserting all the rows in a List View to a Data Grid View -

i have listview has several items. want pass items datagridview keep getting error: an unhandled exception of type 'system.argumentoutofrangeexception' occurred in system.windows.forms.dll additional information: invalidargument=value of '14' not valid 'index'. this code use: dim num integer num = 0 while (num <= listview1.items.count) listview1.items(num) dim lvitem() string = {.text, .subitems(1).text, .subitems(2).text, .subitems(3).text, .subitems(4).text, .subitems(5).text, .subitems(6).text} '// listview selecteditem. datagridview1.rows.add(lvitem) '// add datagridview. end num = num + 1 end while use while (num < listview1.items.count) in place of while (num <= listview1.items.count)

javascript - need to divide circle image to 8 part, and put label on each part. pressing label will turn the circle to the divided part -

Image
i have circle image (like roulette template), , need split 8, , put label on each part. when pressing on divided part, need circle point on correct part. this jsfiddle of have in mean time: http://jsfiddle.net/eyalin/x8q9nqt1/ this js: var img = document.queryselector('img'); img.addeventlistener('click', onclick, false); function onclick() { this.removeattribute('style'); var deg = 500 + math.round(math.random() * 500); var css = '-webkit-transform: rotate(' + deg + 'deg);'; this.setattribute( 'style', css ); } what need create image in photoshop dividers , use image map select dividers, use jquery select them. post image , image map code soon. then use image map generator and result: <img src="url/to/your/image.jpg" alt="" usemap="#map" /> <map name="map" id="map"> <area alt="" title="" hre

javascript - Remove previous Directions Route Google Maps -

hi, trying plan route info window, unable remove previous set route. tried setmap(null) didn't work. using callback event listener need pass parameter returned api call. 1 option use new google.maps.map on each event e.g ( link ) on marker markers placed when page loads. element = document.getelementbyid('map-canvas'); map = new google.maps.map(element, options); var marker = new google.maps.marker({ position: new google.maps.latlng(car.lat, car.long), map: map, title: car.make }); google.maps.event.addlistener(marker, 'click', directionscallback(car)); function directionscallback(car) { return function (e) { if( infowindow != null ) { infowindow.close(); } var directionsservice = new google.maps.directionsservice(); directionsdisplay = new google.maps.directionsrenderer(); directionsdisplay.setmap(null); console.log(directionsdisplay); calcroute = function(){

android - the Staggered Grid View in view pager does not set the adapter properly -

my staggered grid view adapter works in api 19 or higher.but when run in api 17 or lower seen adapter not set properly.if change staggered grid view grid view works fine , shows adpter class work fine.but dont know problem.the images not set in staggered grid view .maybe cause view pager tis tab view xml viewpager: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".mainactivity"> <ir.hisis.cloth.slidingtablayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:elevation="2dp" android:background="@color/colorprimary"/> <android.support.v4.view.vie

linux - How to logically disconnect and reconnect a USB modem without unplugging it physically -

i want restart usb modem power on restart without rebooting , unplugging physically in linux machine. have tried doing procedure : echo -n 0 > /sys/devices/platform/omap/ti81xx-usbss/musb-hdrc.0/usb1/bconfigurationvalue echo -n 1 > /sys/devices/platform/omap/ti81xx-usbss/musb-hdrc.0/usb1/bconfigurationvalue but able disconnect 2nd command failed. giving following prints : hub 1-0:1.0: usb hub found hub 1-0:1.0: 1 port detected usb 1-1: new full speed usb device using musb-hdrc , address 4 usb 1-1: device descriptor read/64, error -19 usb 1-1: device descriptor read/64, error -19 usb 1-1: new full speed usb device using musb-hdrc , address 5 usb 1-1: device descriptor read/64, error -19 usb 1-1: device descriptor read/64, error -19 usb 1-1: new full speed usb device using musb-hdrc , address 6 usb 1-1: device not accepting address 6, error -19 usb 1-1: new full speed usb device using musb-hdrc , address 7 usb 1-1: device not accepting address 7, error -19 hub 1-0:1.0

node.js - ES6 React server-side rendering, how to import a React Component? -

i'm transpiling es6 es5. babeljs nodejs express server files , server-side rendering output directory build/server/. browserify + babelify reactcomponents output build/client/bundle.js file when trying import react component build/client/bundle.js build/server/ file app crashes because i'm importing untranspiled reactcomponent. how import reactcomponent without duplicating code in server (re-using code client/bundle.js)? you have few solutions: your server code doesn't need pre-compiled. if run babel-node , compiled on-the-fly. you bundle server code. don't know resource on how browserify, here's resource started webpack backend. you build client code alongside server code.

angularjs - unable to update controller model value from custom directive with controller as syntax -

i facing problem update model values custom directive using controller syntax. can see through console.log values getting changed in directive not getting updated in controller. <h4>{{self.tabs}} </h4> shows same values. in addition want watch on controller (self --> tabs) model add 'active class' when try use watch throwing me out error. have commented part. following watch related code, not working: $scope.$watch('tabsctrlself.tabs.index', function() { if (tabsctrlself.tabs.index === index) { angular.element($element).addclass('active'); } }); please find plunker , can 1 direct me fix this? you can use 'ng-class' attribute,eg: <en-tab data-pane="mypanename1" ng-class="{active:index==1}">tab #1</en-tab> <en-tab data-pane="mypanename2" ng-class="{active:index==2}" >tab #2</en-tab> <en-tab data-pane="mypane

javascript - How to dynamically add color to a gauge chart in highchart? -

i have gauge chart showing different label different parameters want add color needles dynamically while loading chart.how can ?? posting s fiddle ,i have tried couldn't . here fiddle tooltip: { formatter: function() { var = 0, j, y = this.y; arrttf.foreach(function(ttf) { if (ttf == y) { j = i; return; } i++; }); return arrlabel[j] + ": " + y + ' km/h'; } } above code helped me put different label needles,but couldn't put different color runtime gauge

javascript - How to remove selected drop down value in HTML using Java script? -

i have multiple dropdown item, when selected item drop down, item shouldn't show drop down. for example drop downs drop town items "10 20 30" initially , 1st dropdown contain "10, 20, 30" 2nd dropdown contain "10, 20, 30" 3rd dropdown contain "10, 20, 30" when choose 30 2nd drop down , 1st , 3rd drop down shouldn't show "30" both. i hope soon, in advance below code tried <script type="text/javascript"> $(document).ready(function () { var hideoptions = function () { var $select = $('select'); $select.find('option').show(); $select.each(function () { var $this = $(this); var value = $this.val(); var $options = $this.siblings('select').find('option'); var $option = $options.filter('[value="' + value + '"]'); if (value) {

jquery - Child Div not respecting Overflow hidden In Safari -

on below fiddle, there pagination, when hover pagination circle animate but, in safari image inside circle not respecting overflow hidden, in other browsers working fine.. in solution, image needs centered vertically... fiddle:- http://jsfiddle.net/w5uhet4x/ html <div class="slidecontainer vidopia slide-row"> <div class="article_pagination2"> <div class="back_arrow2 arrow-disable"><a title="prev" href="javascript:void(0);"><strong>prev</strong></a></div> <ul> <li> <div onclick="location.href='http://www0.bhaskar.com/news-ht/spo-ipl-ofipl-introducing-all-the-teams-of-indian-premier-league-8-4957058-pho.html?seq=1'" class="pagination_no2"><span title="slide 1" class="pg_number2 active">1</span> <figure class="article_image2"><span class="image_inner"><img src="

jquery - How to make a sticky ad on sidebar? -

hi website http://cafun.cf have div containing ad @ bottom of sidebar. want slide down when user scrolls till meets footer. i've tried many solutions using jquery, not working right way (i don't know jquery!) this structure : <aside> <!--other divs 'asider' class --> <div class="asider"> <div id="side_ad"> <!-- ad code--> </div> </div> </aside> please me this... thanks! note: want whole 'asider' class slide down. i think need this $stick = $('#marker'); jquery(function($) { function fixdiv() { var $cache = $('#getfixed'); if ($(window).scrolltop() > $stick.offset().top) $cache.css({ 'position': 'fixed', 'top': '10px' }); else $cache.css({ 'position': 'relative', 'top': 'auto' }); } $(window).s

Unable to see Checkout Option in Clearcase explorer for a development view -

after creating view in clearcase project explorer, trying add projects developement view through clearcase explorer, not finding option "add source control" while right clicking projects i've added. please out here you must check if sources of project in created view: either in c:/path/to/my/view/vobtag (snpashot view) or in m:/myview/vobtag (dynamic view) if not, need clearfsimport of folder sources view. see " how can use clearcase “add source control …” recursively? " clearfsimport -preview -rec -nset c:\path\to\sourcedir\* c:\tests\avobtag now when want check out projects right clicking, getting "search" option, want see other options ex:checkout those sources not yet added source control. checkout available if sources first added source control. instead of pasting sources directly in view, best clearfsimport of sources (stored elsewhere) view, described above.

ios - scene is unreachable due to a lack of entry points.. no identifier for runtime access? -

Image
this question has been asked & addressed before haven't found solution fixes issue. why getting "scene unreachable due lack of entry points , not have identifier runtime access via - instantiateviewcontrollerwithidentifier" error? when run app, after launching image, turns black & debugger has following message: my default tableviewcontroller (which 1st) instantiated following code within: import uikit class firsttableviewcontroller: uitableviewcontroller { override func viewdidload() { super.viewdidload() } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } // mark: - table view data source override func numberofsectionsintableview(tableview: uitableview) -> int { // #warning potentially incomplete method implementation. // return number of sections. return 1 } override func tableview(tableview: uitabl

automation - How can I call exceptions or functions instantaneously in Python program execution? -

i have application automated through python script. application may hang or crash anytime unknowingly. hence need write exception or function handle same. i have call exception or function if running in background , should revoked whenever crash or hang happens. for ex: consider python script doing automation on application. doing following... open application browse on icon clicks on icon select file upload file close application during of these steps, crash or hang may occur in application , have different "function/ method" each of steps. how invoke exception @ every steps. i know easy in java like: public void openapp() throws crashexception, errorexception { but don't know how same in python. please me same. 1)you can see here built-in exceptions in python. 2) this post examines differences between python , java regarding exception handling. 3)for simple exception handling in python taken here : def divide(x, y): try:

Android disable scroll and click for listview -

i have simple layout, listview, , 2 icons filtering , sorting options. when click on either of 2 options have layout placed above listview , covers 60% of screen thereby making listview below partially visible. want achieve disable scrolling listview also, none of listview item should clickable long overlay visible. i tried using setenabled(false) setclickable(false) on listview doesn't make difference. other ways achieve this. you can use disabling parent scrollview parentview.requestdisallowintercepttouchevent(true); if overlay visible .

Cassandra isolation in same row-key mutation -

we know that,batch statement operations same row key isolated. is applicable insert,update , delete mutations. cassandra supports row-level isolation since 1.1. applies mutations under same partition key.

java - Input Text Design Issue for a search Box -

i doing java web application has 1 search box. <input type="text" id="twotabsearchtextbox" title="search for" value="${requestscope['searchkey']}" name="searchkey" autocomplete="off" class="tftextinput" data-nav-tabindex="10" tabindex="1"/> if search regular works fine. if search `<div id="test"> </div>` something html content searches fine design break completely. why happens? wen search apple comes in value section , if search html content coming in value section. how avoid problem? have tried stringescapeutils.unescapehtml(you-search-value);

sql server - Best way to delete records in two tables having foreign key? -

i created 2 tables marks , users . maintained foreign key relation between 2 tables, when delete row in marks table, need delete particular user in user table based on uid exists in both tables commonly.can suggest me? use on delete cascade option if want rows deleted in child table when corresponding rows deleted in parent table. but case reverse it.there no way reverse automatically. you need use delete trigger explicitly whenever record delete child table. btw not safe reverse there might many marks record single user , if delete 1 of them user removed user table. i suggest logically in sproc. you can check in sproc record user deleted in mark table remove user user table.

Multiplying array indexes in PHP with array_reduce -

why array_reduce() method work differently when adding , multiplying? when add array values below, code produces expected result: 15 . when multiply , returns: 0 . same code... difference + sign switched * sign. function sum($arr){ print_r(array_reduce($arr, function($a, $b){return $a + $b;})); } function multiply($arr){ print_r(array_reduce($arr, function($a, $b){return $a * $b;})); } sum(array(1, 2, 3, 4, 5)); // 15 multiply(array(1, 2, 3, 4, 5)); // 0 according documentation, might wanna try function multiply($arr){ print_r(array_reduce($arr, function($a, $b){return $a * $b;},1)); } here quote this discussion: the first parameter callback accumulator result-in-progress assembled. if supply $initial value accumulator starts out value, otherwise starts out null.

mysql - sql find and remove duplicate columns with trim -

i have table "partner_entries" 3 columns : our_ref | partner_ref | partner_tag thoses 3 fields form primary key. i have amount of "duplicate" rows : 42 | abc | tag1 42 | abc | tag1 as can see it's not duplicate because there space after same word. can retrieve duplicates based on our_ref , partner_tag : select count(*) nb_duplicates, our_ref, partner_tag partners_entries group our_ref, partner_tag having count(*) > 1 but take rows partner_ref different, want select thoses partner_ref same space after, how can ? thanks help use trim in select , group clauses: select count(*) nb_duplicates, our_ref, trim(both '\n' partner_ref), partner_tag partners_entries group our_ref, trim(both '\n' partner_ref), partner_tag having count(*) > 1 use extended trim syntax remove newlines , other symbols data sql fiddle

c# - Why is exec sp_executesql much slower than inline sql? -

Image
i have test query in management studio , execute fast(less second) declare @p_message_0 varchar(3) = 'whh' declare @p_createdtime_0 datetime = '2015-06-01' select count(1) (select * [logs](nolock) contains([message], @p_message_0) , [createdtime]<@p_createdtime_0) t select t2.* (select t.*,row_number() on (order id desc) rownum (select * [logs](nolock) t contains([message], @p_message_0) , [createdtime]<@p_createdtime_0) t) t2 rownum>0 , rownum<=20 execution plan this: then move c# ado.net, run this exec sp_executesql n'select count(1) (select * [logs](nolock) contains([message], @p_message_0) , [createdtime]<@p_createdtime_0) t select t2.* (select t.*,row_number() on (order id desc) rownum (select * [logs](nolock) t contains([message], @p_message_0) , [createdtime]<@p_createdtime_0) t) t2 rownum>0 , rownum<=20',n'@p_message_0 varchar(3),@p_createdtime_0 datetime',@p_message_0='whh',@p_createdtime_0='2015-

Multidimensionals Arrays indirect interaction -

Image
i've extracted problem, don't understand why cout << array[0][8] writes 2 instead of 1. http://gyazo.com/d159d3ea97b07f1551605daacd631703 #include <iostream> using namespace std; int main() { int array[8][8]; array[0][8] = 1; array[1][0] = 2; cout << array[0][8] << endl; system("pause"); return(0); } i think array assigned type: an element in 2-dimensional array accessed using subscripts, i.e., row index , column index of array. example: type arrayname [ x ][ y ]; where type can valid c++ data type , arrayname valid c++ identifier. a two-dimensional array can think table, have x number of rows , y number of columns. 2-dimensional array a, contains 3 rows , 4 columns can shown below: thus, every element in array identified element name of form a[ ][ j ], name of array, , , j subscripts uniquely identify each element in a. int val = a[2][3];

node.js - Why can't I seem to merge a normal Object into a Mongo Document? -

i have data feed 3rd party server pulling in , converting json. data feed never have mongodb's auto-generated _id s in it, there unique identifier called vehicle_id . the function below handling taking data-feed generated json object fresh_event_obj , copying values mongo document if there mongo document same vehicle_id . function update_vehicle(fresh_event_obj) { console.log("updating vehicle " + fresh_event_obj.vehicleid + "..."); vehicle.find({ vehicleid: fresh_event_obj.vehicleid }, function (err, event_obj) { if (err) { handle_error(err); } else { var updated = _.merge(event_obj[0], fresh_event_obj); updated.save(function (err) { if (err) { handle_error(err) } else { console.log("vehicle updated"); } }); } }); } the structures of event_obj[0] , fresh_event_obj identical, except event_obj[0] has _id , __v whil

json - What does N in jsonFormatN in spray mean? -

i'm looking @ code of " akka , spray " tutorial in typesafe's activator, written eigengo. not jsonformat1, jsonformat2, ... jsonformatn defined , how does. implicit val sendmessageformat = jsonformat2(sendmessage) the above snippet in scala > api > messengerservice.scala thank you. basically, n in jsonformatn denotes number of parameters of class trying marshall/unmarshall . an excerpt link posted ashalynd : the jsonformatx methods reduce boilerplate minimum, pass right 1 companion object of case class , return ready-to-use jsonformat type (the right 1 one matching number of arguments case class constructor, e.g. if case class has 13 fields need use jsonformat13 method).

Java regex for XLSX file extension -

i have following file name: abc 14-15 pcee qwerty checklist - checked xyz idffcfyyl-01 bb.xlsx i using following regex test whether file has xlsx extension: string filename = "abc 14-15 pcee qwerty checklist - checked xyz idffcfyyl-01 bb.xlsx"; private static final string checkxlsxfile = "([^\\s]+(\\.(?i)(xlsx))$)"; private static final pattern pattern = pattern.compile(checkxlsxfile); if (pattern.matcher(filename).matches()) { system.out.println("heaven"); } else { system.out.println("hell"); } however, pattern fails file name. can me resolve this? why not use string.endswith(string) method? if(filename.tolowercase().endswith(".xlsx")) { // } else { // else }

ios - Substantial time to push UIViewController in Twitter completion block -

when running code... -(ibaction)loginwithtwitter:(id)sender { nslog(@"logging in twitter"); acaccountstore *accountstore = [[acaccountstore alloc]init]; acaccounttype *accounttype = [accountstore accounttypewithaccounttypeidentifier:acaccounttypeidentifiertwitter]; [accountstore requestaccesstoaccountswithtype:accounttype options:nil completion:^(bool granted, nserror *error) { if (error) { [self showerror:error]; return; } if (granted) { nsarray *accountsarray = [accountstore accountswithaccounttype:accounttype]; if ([accountsarray count] > 1) { nslog(@"multiple twitter accounts"); } acaccount *twitteraccount = [accountsarray objectatindex:0]; nslog(@"%@", twitteraccount); [self pushmaincontroller]; } }]; } there 5-10 second delay before pushmaincontroller is called, though account information logged (after pre-authorization). if move pushmaincontro

ruby on rails - How to format f.submit with css, glyphicons, and symbol? -

how can make this: <%= f.submit :conceal %> work <span class="glyphicon glyphicon-plus"> , word private , , class: "btn" . here attempts: #this didn't make :conceal work <%= button_tag(type: 'submit', class: "btn") %> <% :conceal %><span class="glyphicon glyphicon-plus"></span> private <% end %> #this stopped :conceal working <%= f.submit "private", class: "btn" %> <% :conceal %> <% end %> #this ignored 2nd line despite, <%= f.submit :conceal, class: "btn" %> <span class="glyphicon glyphicon-plus"></span> private <% end %> in controller : if (params[:commit] == 'conceal') @valuation.conceal = true end i'm afraid can't achieve button's appearance icon when using input[type=submit] . you have go button . please, consider following: <%= button_tag(type: &quo

java - multiple issues with spring tool suite 3.6.3 release -

Image
i have wanted learn spring mvc , took @ javavids - youtube , wanted follow along series have multiple problems/issues first rebuild global repo in maven repositories solved then created maven project structure in videos but have instead solved ok want add plugins pom.xml getting dialog in videos shows : update don't plug-in select solved have compiler compliance when set compiler java 1.7 solved and @ last when tried update sts 3.6.3 freezes , shows ok have proxy settings update make changes , add dependency according answer error: now don't see resources can me these remaining issues resolved! highly appreciated. first maven default compiler level set 1.5. in order set 1.7 either configure maven-compiler-plugin <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>3.3</version> <configurat