Posts

Showing posts from July, 2010

ios - Using a Swift String with NSData without NSString -

is possible init swift string (not nsstring ) contents of nsdata object without creating nsstring first? i know can use nsstring: var datastring = nsstring(data data: nsdata!, encoding encoding: uint) but how can use basic swift string type? thought swift strings , nsstrings interchangeable, have data out of nsdata using nsstring , assign value swift string? as of swift 1.2 aren't quite interchangeable, convertible, there's no reason not use nsstring , constructors when need to. work fine: var datastring = nsstring(data:data, encoding:nsutf8stringencoding) as! string the as! needed because nsstring(...) can return nil invalid input - if aren't sure data represents valid utf8 string, may wish use following instead return string? (aka optional<string> ). var datastring = nsstring(data:data, encoding:nsutf8stringencoding) string? once constructed, can use datastring other swift string, e.g. var foo = datastring + "some other string

php - Need to explode and string and make it as key value pairs -

i have data [0] => 1#*#1-1 my requirement explode #*# , have make generated array elements key value pairs example $data = explode("#*#",'1#*#1-1'); $data[0] =1; $data[1] = 1-1; requirement make dynamic associative array array($data[1] => $data[0]) <? $str = '1#*#1-1 3#*#1-2 5#*#1-3 7#*#1-4 9#*#1-5 11#*#1-6 13#*#1-7 15#*#1-8 17#*#1-9 19#*#1-10 2#*#2-1 4#*#2-2 6#*#2-3 8#*#2-4 10#*#2-5 12#*#2-6 14#*#2-7 16#*#2-8 18#*#2-9'; $ex = array_map('trim',explode("\n",$str)); $out = array(); foreach($ex $e){ $ex2 = explode('#*#',$e); $out[$ex2[1]] = $ex2[0]; } print_r($out); array ( [1-1] => 1 [1-2] => 3 [1-3] => 5 [1-4] => 7 [1-5] => 9 [1-6] => 11 [1-7] => 13 [1-8] => 15 [1-9] => 17 [1-10] => 19 [2-1] => 2 [2-2] => 4 [2-3] =&

Array as a dictionary value in swift language -

i have following swift dictionary var list = [ 2543 : [ "book", "pen" ], 2876 : [ "school", "house"] ] how can access array values ? println(list[2543][0]) the above code gives error "could not find member subscript" and should print "book" note subscript returns optional. have force unwrapping: println(list[2543]![0]) or use optional chaining println(list[2543]?[0])

c++ - How to get all ones or all zeros from boolean result? -

i (stupidly) thought if took boolean result of true, cast int , left-shifted end lsb repeated @ every bit, not! if had boolean result , wanted convert ones true , zeros false, cheapest way (computationally) this? bool result = x == y; unsigned int x = 0; //x becomes ones when result true //x becomes zeros when result false like this, perhaps: bool result = x == y; unsigned int z = -result;

bash - shell script pattern matching -

need on shell script. i have following result in file name-label ( rw) : host1 networks (mro): 1/ip: 192.168.1.2; 0/ip: 192.168.1.10 name-label ( rw) : host2 networks (mro): 1/ip: 192.168.1.15; 1/ipv6/0: fe80::9060:b6ff:fec1:7bbb; 0/ip: 192.168.1.20; 0/ipv6/0: fe80::286d:7cff:fefe:3ed7 i want hostname , corresponding 0/ip value file. final output be host1 192.168.1.10 host2 192.168.1.20 perl solution: perl -ne '/^name-label .*: (.+)/ , $name = $1; m(0/ip: ([0-9.]+)) , print "$name $1\n"' name-label stored in variable, it's printed ip when processing next line.

Flash Error #1009: Cannot access a property or method of a null object referencee -

my flash professional cc showing error simple alert code. have tried solve reading discussed on website unable solve it. error : typeerror: error #1009: cannot access property or method of null object reference. @ mx.controls::alert$/show()[/users/aharui/flex-sdk-4.12.1/frameworks/projects/mx/src/mx/controls/alert.as:574] @ alerttest()[d:\summer project\practice\alerttest.as:7] can suggest reason, here code!! package { import flash.display.sprite; import mx.controls.alert; public class alerttest extends sprite { public function alerttest() { alert.show("would exit application?", "confirm", alert.yes | alert.no | alert.cancel); trace("hey"); } } } before getting error 1046 : type not found or compile time constant.. so installed flex skd 4.12.1 in folder , included library path in action settings fla file. after doing landed getting error. kindly suggest. the mx alert class flex framework , can't

Android Camera unlock mediarecorder -

i want write app records video through smartphone camera. found website : http://developer.android.com/guide/topics/media/camera.html#custom-camera im using source code started. my main activity : public class mainactivity extends activity { protected static final string tag = null; private camera mcamera; private camerapreview mpreview; private mediarecorder mmediarecorder=null; public static final int media_type_image = 1; public static final int media_type_video = 2; private boolean isrecording = false; /** safe way instance of camera object. */ public static camera getcamerainstance(){ camera c = null; try { c = camera.open(); // attempt camera instance } catch (exception e){ // camera not available (in use or not exist) } return c; // returns null if camera unavailable } @overr

Reading Text File and Store it in Array (Android development) -

Image
if (detectconnection.checkinternetconnection(mainactivity.this)) { try { fileinputstream fis = new fileinputstream(myinternalfile); datainputstream in = new datainputstream(fis); bufferedreader br = new bufferedreader(new inputstreamreader(in)); string strline; //0-19 int i=0; int internal_entries=0; toast.maketext(mainactivity.this,"start reading", toast.length_long).show(); while ((strline = br.readline()) != null ) { log.i("index" , integer.tostring(i)); log.i("read_line" , strline.tostring()); //data.array_data[i]=strline; data.array_data[i]=s

javascript - Sencha Touch 2 remove Google map Markers -

Image
i'm trying remove markers google map using extjs. i'm performing setcenter() operation (i need remove old center map) , want add new marker in new center. as know, google map instance need perform getmap() on map container, i.e map.getmap() i tried clearmarkers();, deletemarkers(); , markers = []; neither works. google map object looks weird on chrome developer tools utility, @ least me. with addition, same problem. i'm doing that: new google.maps.marker({ map : map.getmap(), position : new google.maps.latlng(location.lat, location.lng), title : 'drag marker new position', animation : google.maps.animation.drop, draggable : true }); any appreciated! thanks. it's simple. remove marker map, call setmap() method passing null argument. marker.setmap(null); note above method not delete mar

javascript - Jquery Text Slide in Effect -

i want make text animation slide in left. there 3 text fields sports cargo bag $14 sale $25 i want these text set jquery , slide in left link . code jsfiddle , have set these headtext want use jquery method set these texts html <div id="maincontainer"> <div id="logdo"> <img src="http://i.share.pho.to/7346a9ca_o.gif"/> </div> <div id="images"> <img id="introimg" src="http://i.share.pho.to/9064dfe4_o.jpeg"/></div> <div id="headlinetext"> <p id="headline1txt" ></p> <p id="headline2txt" ></p> <p id="headline3txt" ></p> </div> <button class="btn btn-primary" id="ctabtn" type="button">shop now</button> </div> css * { margin:0; padding:0; } #maincont

testing - Find methods related to testcases in Java -

i want automatically change methods in program. these methods contain compiler error , program aims fix these compiler errors. after fixing compiler errors need run test cases related changed method (or class) know correct , if not test cases failed. programs under investigation big, need run test cases related changes. example, if change 1 method, need run test cases related method. therefore, need programmatically able find test cases related each method, , class. useful if there tool can me. example, tool creates matrix shows each test case related method(s) one easy way run test cases , save functions accessed. however, problem @ beginning input program contains compiler error , not possible run test cases because of these compiler error. please let me know best way that. api or tool can used programmatically best me.

javascript / php - Get src of image from the URL of the site -

i noticed @ http://avengersalliance.wikia.com/wiki/file:effect_icon_186.png , there image (a small one) there. click on it, brought page: http://img2.wikia.nocookie.net/__cb20140312005948/avengersalliance/images/f/f1/effect_icon_186.png . for http://avengersalliance.wikia.com/wiki/file:effect_icon_187.png , after clicking on image there, brought page: http://img4.wikia.nocookie.net/__cb20140313020718/avengersalliance/images/0/0c/effect_icon_187.png there many similar sites, http://avengersalliance.wikia.com/wiki/file:effect_icon_001.png , http://avengersalliance.wikia.com/wiki/file:effect_icon_190.png (the last one). i'm not sure if image link related link of parent site, may know, possible http://img2.wikia.nocookie.net/__cb20140312005948/avengersalliance/images/f/f1/effect_icon_186.png string, string http://avengersalliance.wikia.com/wiki/file:effect_icon_186.png , using php or javascript? appreciate help. here small php script can this. uses curl content , d

javascript - Getting data from Spring MVC in Angular JS in the initial view call -

Image
i new angular js, have created spring mvc web application angular js, know view can call rest services angular js using resource, restangular, http , in spring form controller view been triggered , loading datas through angular within view again rest call angular been called view server , gets datas thereafter loading, instead there way pass json object while triggering view spring controller angular js @ first time itself. i have done similar thing, working fine don't know whether approach or not. spring controller @requestmapping("/getemployee") public modelandview helloword(){ jsonarray employeejsonarray = // contains information of employee return new modelandview("employee", "employee",employeejsonarray); } employee.jsp <html ng-app="myapp"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>spring 3.0 mvc series: hello world</title&g

html - Can't get my sidebar on the right-hand side -

i'm amateur css , have tried using guides myself far. i've set fiddle http://jsfiddle.net/defaye/x9t7m/1/ may know i'm doing wrong? can't sidebar on right-hand side right-most column of main content. css structure #wrapper { width: 100%; min-width: 950px; max-width: 1110px; margin: 0 auto; } #header { float: left; height: 354px; width: 100%; } #navigation { float: left; height: 40px; width: 100%; } #container { float: left; width: 100%; } #main { margin-right: 200px; } #sidebar { width: 300px; margin-left: -300px; float: left; } #footer { height: 40px; width: 100%; clear: both; } html structure <body> <div id="wrapper"> <div id="header"></div> <div id="navigation"></div> <div id="container"> <div id="main"></div> <div id="sidebar"></div> </div> <di

mysql - How To Design A Database for a "Check In" Social Service -

i want build "check in" service foursquare or untappd . how design suitable database schema storing check-ins? for example, suppose i'm developing "cheesesquare" people keep track of delicious cheeses they've tried. the table items 1 can check in simple , like +----+---------+---------+-------------+--------+ | id | name | country | style | colour | +----+---------+---------+-------------+--------+ | 1 | brie | france | soft | white | | 2 | cheddar | uk | traditional | yellow | +----+---------+---------+-------------+--------+ i have table users, say +-----+------+---------------+----------------+ | id | name | twitter token | facebook token | +-----+------+---------------+----------------+ | 345 | anne | qwerty | poiuyt | | 678 | bob | asdfg | mnbvc | +-----+------+---------------+----------------+ what's best way of recording user has checked in particular cheese? for ex

ember.js - Ember {{each}} vs {{each x in controller}} -

when use {{each}} example: {{#each imagepost}} <li>{{title}}</li> {{else}} empty :o {{/each}} i 'empty :o' message when this: {{#each imagepost in controller}} <li>{{imagepost.title}}</li> {{else}} empty :o {{/each}} it works fine! it weird cause docs says this: {{#each people}} <li>hello, {{name}}!</li> {{/each}} which doesnt work me =/ does shortened version won't apply models? controller's properties? the shortened version applies properties on controller/model or controller/model. in case be: {{#each controller}} <li>{{title}}</li> {{else}} empty :o {{/each}} or {{#each model}} <li>{{title}}</li> {{else}} empty :o {{/each}} note, if {{#each model}} , have itemcontroller defined on array controller won't wrap each item item controller, need this: {{#each model itemcontroller='foo'}} .

python - rewrite sql query using Django db Api -

these models in django class match(models.model): team_a = models.foreignkey("team", related_name="team_a") equipo_b = models.foreignkey("team", related_name="team_b") goals_team_a = models.integerfield(default=0) goals_team_b = models.integerfield(default=0) winner_team = models.foreignkey("team", related_name="winner_team", null=true) match_type = models.charfield(choices=match_type_choices, max_length=100, null=false) match_played = models.booleanfield(default=false) date = models.datefield() class team(models.model): name = models.charfield(max_length=200) group = models.charfield(choices=group_choices, max_length=1, null=false) matches_played = models.integerfield(default=0) matches_won = models.integerfield(default=0) matches_lost = models.integerfield(default=0) matches_tied = models.integerfield(default=0) goals_in_favor = models.integerfield(default=0)

How to push file from android device to linux desktop? -

how push/pull file android device linux desktop? i've created lsmod log of device, unable pull device desktop of linux distro. you can user adb pull/push file android device pc viceversa using usb cable copy file android device pc adb pull /sdcard/yourfile yourpc's location copy file pc android device adb push filefromyourpc /sdcard/file

javascript - How can I make a form within a tooltip? -

i want use jquery make form has simple yes or no shows when hover on it. problem can't seem jquery acknowledge creation of tooltip dynamically created (e.g. "$('#word_form').size() = 0") , submit alert doesn't run. tested form alone , working. here code: html: <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <p> example 1 : <a href="#" class = "word">cat</a> example 2 : <a href="#" class = "word">dog</a> </p> javascript: $( document ).ready( function() { $(".word").tooltip({ items: '.word', content: ' <div class="tooltip">is word cool?<br> \ <form id = "word_form" method="post"> \ <input type="image" src="

c - Output of printk not showing up -

i trying printk couple of tracing statements in kernel configfs's store , show functions defined (you can find hooks in configfs_item_operations structure in file /include/linux/configfs.h), i'm sure functions called i'm unable see trace printed on console. do need enable symbol same, please you may need bump priority of ends in dmesg : echo 8 4 1 8 > /proc/sys/kernel/printk you can see current settings by: cat /proc/sys/kernel/printk

url - How to make it so a PHP page is directed to the same page but with different variables -

well have calendar , add links bottom have different months -1 month , +1 month on either ends. know need use $_get method in order have specific url. however, i'm not sure need in order have page know when has specific url. right ../index.php url. , if try make extension index.php?day=02&month=01&year=2014 displays default page. how make if user hardcode different month or year in url, direct them correct calendar month. something like: <?php $day = htmlspecialchars($_get['day']); $month = htmlspecialchars($_get['month']); $year = htmlspecialchars($_get['year']); if ($year == 2014) { echo $day . $month . $year . " - special year page! (would idea include here maybe?"; } ?> that should give ideas how can achieve trying do.

java - How can I get the byte value in a Map -

this question has answer here: how convert int array string tostring method in java [duplicate] 8 answers i value of byte inside map object. map<string, object> data = new hashmap<>(); data.put("foo", new byte[]{4}); system.out.println(data.get("foo")); what i'm getting this... [b@1a779dce please me. as adding object map not byte[] need cast it. map<string, object> data = new hashmap<>(); data.put("foo", new byte[]{4,3,1,2}); system.out.println(arrays.tostring((byte[])data.get("foo"))); output [4,3,1,2]

html - How to add new fonts in CSS for local testing -

i'm making webpage imports needed fonts google fonts way: @import url(http://fonts.googleapis.com/css?family=italianno); the problem every time load page need connected internet , takes time load font. there way can load font offline because while testing page i'll refreshing countless number of times , might not connected internet time , don't want wait 3-5 seconds every time font loaded. i tried installing font in system , using in css. didn't work. hey make fonts folder css folder , put desired font there. in css call code example meriyoui font mentioned below. load font onto app. for need download font , put in fonts folder. (pre-requisite).try using web safe fonts. hope helps. css @font-face { font-family: 'meiryo ui'; font-weight: normal; font-style: normal; src: url('../fonts/meiryoui.ttf'); }

xaml - ScrollViewer not showing C# -

i new c# , not understand scrollviewer. please see code below , tell me why no scroll bar becomes visible when below mentiond groupbox gets displayed on screen. highly appreciated. <scrollviewer scrollviewer.verticalscrollbarvisibility="auto" grid.row="5"> <groupbox name="grpdetail" margin="5" height="auto" grid.row="5" scrollviewer.verticalscrollbarvisibility="visible"> <my2:ucdisbursmentdetail grid.row="5" x:name="ucdisbursmentdetail" visibility="collapsed"></my2:ucdisbursmentdetail> </groupbox> </scrollviewer> your scrollviewer bigger it's content therefore doesn't need show scrollbar. add height it <scrollviewer height="300"> ... </scrollviewer>

c# - Retrieve value from toolStripComboBox -

i have created toolstripcombobox , retrieve item list selection database this: private void toolstripcombobox1_click(object sender, eventargs e) { toolstripcombobox1.combobox.valuemember = "month"; toolstripcombobox1.combobox.datasource = dbconnect.selectmonth(); //get month database } the combobox display month database. later i'm trying fetch selection combobox using selecteditem somthing this: string monthselect = toolstripcombobox1.selecteditem.tostring(); however value monthselect = "system.data.datarowview" any idea how value instead of system.data.datarowview ? got solution this. when using datasource toolstripcombobox : toolstripcombobox1.combobox.valuemember = "valuemember"; toolstripcombobox1.combobox.datasource = datasource(); //retrieve value database combobox list toolstripcombobox1.selecteditem return customized view of datarow. in order value of current selection need use : tool

jquery toggle disable click -

i have menu @ click of every item display div 'toggle' function, try click on menu item disabiletare selected or clicked. code used follows. $(function() { $("#pul-m1").click(function() { $('#box-company').toggle('slide', { direction: 'left' }, 800); }); $('#pul-m1').unbind(click); }); where 'pul-m1' click toggle div opens 'box-company' pop-up left; when div opened button clicked on menu (pul-m1) disabled. with code created click continues function activating toggle, did wrong? use slidetoggle,and if want single click , disable clicked item.just use .one function of jquery <script> $(function() { $('#box-company').hide(); $("#pul-m1").one('click',function(e) { $('#box-company').slidetoggle({ direction: 'left' }, 800); }); }); </script>

javascript - Rotate with jQuery, remember position -

i'm rotating div in code bellow. problem don't know how make element continue last position when click again. how do that? (i able in way didn't work in ie) jsfiddle html: <div class="square">click me</div> css: .square { background:red; height:100px; width:100px; cursor:pointer; } js: $('.square').click(function () { rotate($(this), -180, 1000); }); function rotate(element, degrees, speed) { element.animate({ borderspacing: degrees }, { duration: speed, step: function (now, fx) { $(this).css('-webkit-transform', 'rotate(' + + 'deg)'); $(this).css('-moz-transform', 'rotate(' + + 'deg)'); $(this).css('transform', 'rotate(' + + 'deg)'); } }); } you can use jqueryrotator ... and use js code... var value = 0 $("#image").rotate({ bind:

ruby on rails - Using git clone in existing application -

i have existing app. i did this: git clone https://github.com/stefanoverna/activeadmin-globalize.git -b master to use activeadmin-globalize gem. after have new folder activeadmin-globalize , how can use gem, because in these subfolders other folders app/ lib/ config/ etc. how can make work, still keep existing app functionality ? thanks if u still got same error try regular git syntax gem "activeadmin-globalize", git: 'https://github.com/stefanoverna/activeadmin-globalize', branch: 'master'

sql - Select MAX and MIN from multiple columns -

i can max() , min() multiple columns in same table this: select max(maximo) maximo, min(minimo) minimo from( select max(column1) maximo, min(column2) minimo table1 cond1= 'a' , cond2= 'x' union select max(column3) maximo, min(column4) minimo table1 cond1= 'a' , cond2= 'x' union select max(column5) maximo, min(column6) minimo table1 cond1= 'a' , cond2= 'x' union select max(column7) maximo, min(column8) minimo table1 cond1= 'a' , cond2= 'x' ) x but looks ugly. trying use unpivot : select min (v) minvalue, max (v) maxvalue table1 unpivot ( v nvalue in ( column1, column2, column3, column4, column5, column6, column7,

AWS Maintenance - How to manage updates for Java, Tomcat and MySQL? -

new versions (minor versions) of java, tomcat , mysql released on regular basis. amazon these updates or have these updates on own? reading of aws maintenance documentations seems these through scheduled maintenances. i'm not 100% sure. can please confirm? , if there best-practices around these, i'd love know. it depends. if use of managed services, upgrades (like rds). if using standard ec2 instance, wont have access instance, responsible keeping packages upgraded.

java - JSP with Spring form not calling Spring 4.x controller -

i spring newbie , have simple form on jsp: <!-- register person. --> <p>to register library, please <i>click</i> button below:</p> <c:url value="/registerperson/register" var="url" /> <form:form commandname="person" action="${url}" method="get"> <input type="submit" value="register"> </form:form> which want use talk spring controller: @controller @requestmapping("/registerperson") @sessionattributes("person") public class registerpersoncontroller { private registerpersonvalidator registerpersonvalidator; private personservice personservice; @autowired public registerpersoncontroller(registerpersonvalidator registerpersonvalidator, personservice personservice) { this.registerpersonvalidator = registerpersonvalidator; this.personservice = personservice; } // pop

ios - iBeacon and Notification -

i'm developing ios application , i'm using beacons. i've problem. i'm @ beginning of development, have appdelegate. in appdelegate.m have initialized - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; // override point customization after application launch. self.locationmanager = [[cllocationmanager alloc] init]; self.locationmanager.delegate = self; nsuuid *uuid = [[nsuuid alloc] initwithuuidstring:@"8aefb031-6c32-486f-825b-e26fa193487d"]; clbeaconregion *region = [[clbeaconregion alloc] initwithproximityuuid:uuid identifier:@"region"]; if ([cllocationmanager ismonitoringavailableforclass:[clbeaconregion class]]) { nslog(@"i'm looking beacon"); [self.locationmanager startrangin

wpf - Binding details of a TreeViewItem to a ContextMenu -

i have contextmenu appears on right click of treeviewitem. pass couple of details treeviewitem context menu. how starting here: xaml <treeview x:class="myapp.treecontrol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" d:designheight="300" d:designwidth="300" previewmouseleftbuttondown="treeview_previewmouseleftbuttondown" previewmousemove="treeview_previewmousemove" previewmouserightbuttondown="treecontrol_onpreviewmouserightbuttondown"> <treeview.contextmenu> <contextmenu> <menuitem name="dataitem1" header="propert

Sync_gateway couchbase requireRole -

i have problem roles of sync_gateway . sync_function throws missing role error @ requirerole("adminsync"); . i'm accessing user admin1 configured follows: "name": "admin1", "all_channels": {}, "passwordhash_bcrypt": "**************", "explicit_roles": { "adminsync": 1 }, "rolessince": { "adminsync": 1 } also have role configured as: { "name": "adminsync", "admin_channels": { "ch_horas": 1, "ch_personas": 1, "ch_proyectos": 1 }, "all_channels": { "ch_horas": 1, "ch_personas": 1, "ch_proyectos": 1 } } any idea of error?? thanks. re, found out wrong, the variable realuserctx.roles map, according requirerole(..) needs compare 2 arrays, return false. so needed change source code of src/channels/sync_run

c++ - Hide global cursor -

i'm trying add multi-touch gestures google earth plugin, wrote little c++ background program using win32 api catch tactile driver input , make gestures emulated mouse moves. but mouse cursor moving on screen, want hide (i've block input using blockinput function) while user touching screen. is there right way ? i've saw windows 8 cursor_suppressed response getcursorinfo, no way trigger that... edit : found dirty way, using setsystemcursor hide each cursors need : setsystemcursor(hcursor, ocr_sizens); and systemparametersinfo reset cursors : systemparametersinfo(spi_setcursors, 0, null, 0); i hope there better way do... thanks ! try showcursor : showcursor(false);

How to create rebound popup in android similar to Paper App (IOS)? -

Image
i trying create rebound popup similar paper app(ios), tried alot create same popup failed. found link https://github.com/facebook/rebound facebook has released rebound popup library facing difficulties create same popup.below youtube video can find popup on 35-40 seconds attaching screenshot same. please let me know suggestion have stuck here , can't proceed app without this. https://www.youtube.com/watch?v=0a7u8r1ql_q&feature=youtu.be

Creating a pointer of a struct in C++ -

i have struct defined as typedef struct bsp_area { struct bsp_area *otherbsparea; /* pointer */ long bspreturncode; short sgroupnum; /* default 0 */ char filler4[6]; /* alignment bytes */ unsigned char bycobolworkarea[20]; /* cobol work area */ // .... , lots of others fields } * pbsp_pass ; so bsp_area can hold pointer reference itself, create sort of link list. in code, have method createnode() returns bsp_area method signature bsp_area createnode() . in method initialize bsp_area , return it. after calling method, set pointer contains doing this, getting error. bsp_area cobolpassarea2 = createnode(data1); cobolpassarea->otherbsparea = &cobolpassarea2; how initialize pointer otherbsp bsp_pass_area returned createnode() ? please dont advise make createnode return pointer, instead of concrete bsp_area , requirement. cobolpassarea->othe

html - How to find and replace 6 digit numbers within HREF links from map of values across site files, ideally using SED/Python -

i need create bash script, ideally using sed find , replace value lists in href url link constructs html sit files, looking-up in map (old new values), have given url construct. there around 25k site files through, , map has around 6,000 entries have search through. all old , new values have 6 digits. the url construct is: one value: href=".*jsp\?.*n=[0-9]{1,}.*" list of values: href=".*\.jsp\?.*n=[0-9]{1,}+n=[0-9]{1,}+n=[0-9]{1,}...*" the list of values delimited + plus symbol, , list can 1 n values in length. i want ignore construct such this: href=".*\.jsp\?.*n=0.*" ie list n=0 effectively i'm interested in url's include 1 or more values in file map, not prepended changed -- ie list requires updating. please note: in above construct examples: .* means character isn't digit; i'm interested in 6 digit values in list of values after n= ; i've trying isolate n= list rest of url construct, , should noted

python - How to make SMTPHandler not block -

i installed local smtp server , used logging.handlers.smtphandler log exception using code: import logging import logging.handlers import time gm = logging.handlers.smtphandler(("localhost", 25), 'info@somewhere.com', ['my_email@gmail.com'], 'hello exception!',) gm.setlevel(logging.error) logger.addhandler(gm) t0 = time.clock() try: 1/0 except: logger.exception('testest') print time.clock()-t0 it took more 1sec complete, blocking python script whole time. how come? how can make not block script? here's implementation i'm using, based on this gmail adapted smtphandler . took part sends smtp , placed in different thread. import logging.handlers import smtplib threading import thread def smtp_at_your_own_leasure(mailhost, port, username, password, fromaddr, toaddrs, msg): smtp = smtplib.smtp(mailhost, port) if username: smtp.ehlo() # tls add line smtp.starttls() # tls add line

java - DialogFragment: how to prevent saving state? -

i have several classes extending dialogfragment show popups. model class that's used show popup data comes library can't change. public class myfragment extends dialogfragment { private list<mymodel> modeldata; ... } now, dialogfragment shown, if hit home button, crash 06-09 17:21:04.265: e/androidruntime(31470): java.lang.runtimeexception: parcel: unable marshal value ..... the obvious fix change mymodel class implement parcelable. tried similar case , works unfortunately of model classes used in dialogfragments in library , cannot change make them parcelable , don't want wrapper classes. i don't support orientation change , don't have usecase contents of dialog need preserved. there way can ignore state saving process crash can prevented? i figured out , wanted post solution in case else runs same situation. had override onpause this @override public void onpause() { super.onpause(); dismissallowingstateloss(); }

java - Crowd installation error -

i trying install crowd. not able install doesn't initiate process ( cannot open http://crowd.mydomain.com:8095/crowd ), gives me blank screen. here log /var/crowd-home/atlassian-crowd.log 014-06-09 21:28:16,971 localhost-startstop-1 info [containerbase.[catalina].[localhost].[/crowd]] no spring webapplicationinitializer types detected on classpath 2014-06-09 21:28:25,917 localhost-startstop-1 info [com.atlassian.crowd.startup] system information: 2014-06-09 21:28:25,917 localhost-startstop-1 info [com.atlassian.crowd.startup] timezone: coordinated universal time 2014-06-09 21:28:25,917 localhost-startstop-1 info [com.atlassian.crowd.startup] java version: 1.7.0_51 2014-06-09 21:28:25,918 localhost-startstop-1 info [com.atlassian.crowd.startup] java vendor: oracle corporation 2014-06-09 21:28:25,918 localhost-startstop-1 info [com.atlassian.crowd.startup] jvm version: 24.51-b03 2014-06-09 21:28:25,918 localhost-startstop-1 info [com.atlassian.cro

android - how to modifiy a list from ListFragment in its parent activity -

i have sherlocklistfragment , i'm creating adapter inside onactivitycreated. parent activity implements callback interface communicating fragments. when method activity called want add / remove item fragment's list. have tried use getlistadapter , receive npe. if use getlistview, "content view not yet created" error received. how can modify list fragment in correct way? activity code: @override public void addfavorite(contact item) { list<contact> favoritecontacts = ((favoritecontactsadapter) favouritecontactsfragment .getlistadapter()).getcontacts(); favoritecontacts.add(0, item); favoritecontactsadapter adapter = new favoritecontactsadapter( getapplicationcontext(), r.layout.contact_layout, favoritecontacts); favouritecontactsfragment.setlistadapter(adapter); } fragment code: @override public void onactivitycreated(bundle savedinstancestate) { contacts = getarguments() .getparce

logging - Change java.util log levels in tomcat (or tomEE or openEJB) -

i have following logger defined in servlet. private final static logger logger = logger.getlogger(testservlet.class.getname()); changed logger levels in logging.properties, logger.log(level.fine, "hello"); doesn't print. eclipse has integrity issues tomcat. following steps helped. open server configuration double clicking server (in servers tab) click open lauch configuration in arguments tab add following jvm arguments -djava.util.logging.config.file="{your tomcat folder}\conf\logging.properties" -djava.util.logging.manager=org.apache.juli.classloaderlogmanager to change logging levels, through configuration: edit logging.properties add logging levels com.level = fine or through code: static { logger.setlevel(level.fine); }

vba - ListObject.DataBodyRange.SpecialCells(xlCellTypeVisible).Rows.count returns wrong value -

i have filtered list object , need number of rows visible. use statement number of lines: mysheet.listobjects("mylistobject").databodyrange.specialcells(xlcelltypevisible).rows.count most of time works. when table has 1 or 2 rows visible, always returns 1 , though should return 2 when there 2 rows. known issue? if so, there workarounds? i'd rather avoid doing manual loop through every row in table count, can large , excessively slow. further info: list object has totals row enabled, , filtered following code: 'remove existing filter mysheet.listobjects("mylistobject").range.autofilter 'apply new filter mysheet.listobjects("mylistobject").range.autofilter field:=1, criteria1:=key where field 1 (non-unique) key, , key string retrieved elsewhere. can physically see there 2 visible rows in table (not including header or totals row), yet .rows.count consistently returns 1 when there 2 rows. that code incorrect - return

c# - ASP MVC - Adding columns to all tables using EF Code First -

i need add set of columns of database's tables (sql server). have generated database using code first migrations in entity framework 6. is possible add these columns of tables @ once ? instance, overriding onmodelcreating method specific code ? or have add these columns each of models used update database ? thank in advance ! -- glad i found solution, muthu. to automatically add "common columns" tables, had create "base model" containing these columns, , make of models inherit it. this avoids repeatedly adding columns each model properties, , looks cleaner believe.

Modx getResource: Choosing which resource loads first? -

Image
i trying use getresource pull few resources single page, these resources link through detailed information page of specified resource. [[getresources? &tpl=`profile-ditto` &limit=`all` &parents=`18` &sortby=`publishedon` &hidecontainers=`1` &includecontent=`1` &includetvs=`1` &processtvs=`1`]] this pulls content , sorts correct order, need load specific resource depending on link clicked on. this resource list pulling, page loading them people (18) , each of children have more detailed pages need load individually depending on link people click on page. possible load resource getresource call? so after investigating getresource little more on there information page link getresource figured out available getresource wouldn't solve problem. i decided write custom snippet uses id of resource , loads resource when clicked while still using getresource save time on adding content. <div class="one-fifth column

ios - online and offline status users in uitableview quickblox -

i found tuto explain how offline/online status 1 users purpose status of list of users that's why when tried put [qbusers userwithid:usercell.id delegate:self]; in cellforrow many responses webservice don't know how fix that. to realtime online/offline status of users can use contactlist chat api http://quickblox.com/developers/simplesample-chat_users-ios#contact_list you should create datasource table, example array of users. when receive update status of user callback - should update datasource, example this - (void)chatdidreceivecontactitemactivity:(nsuinteger)userid isonline:(bool)isonline status:(nsstring *)status{ user *user = [self.mydatasource userwithid:userid]; user.online = isonline; [self.tableview reloaddata]; }

ios - Ignore nil properties when serializing JSON using RestKit -

i have class: @interface moviestatus : nsobject @property (nonatomic, strong) nsnumber* seen; @property (nonatomic, strong) nsnumber* watchlist; @end where both properties represent optional nullable boolean values. i'm sending object server using restkit through rkobjectmanager , created appropriate mapping. i'm unable skip property post data when serializing object. for example, code: rklogconfigurebyname("*", rklogleveltrace); rkobjectmanager* manager = [rkobjectmanager managerwithbaseurl:[nsurl urlwithstring:@"http://www.example.com/v1"]]; manager.requestserializationmimetype = rkmimetypejson; rkobjectmapping* requestmapping = [rkobjectmapping requestmapping]; [requestmapping addattributemappingsfromarray:@[@"seen", @"watchlist"]]; rkrequestdescriptor* requestdescriptor = [rkrequestdescriptor requestdescriptorwithmapping:requestmapping objectclass:[moviestatus class] rootkeypath:nil method:rkrequestmethodpost]; [manage

maven - Provided transitive dependencies not being listed -

i have 2 projects, when list dependencies of first get: [info] com.onespatial.gothic:gothic-java:jar:5.16 [info] +- com.onespatial.tools.gde:gde-cfg:zip:5.16:provided [info] +- com.onespatial.gothic:gothic-w32:jar:5.16:compile [info] \- com.onespatial.gothic:gothic-lx86_64:jar:5.16:compile which correct. gde-cfg provided . when list dependencies of second project, includes above project, get: [info] +- com.onespatial.radius.studio:rswebmapservice:jar:classes:2.3.4-build-7-snapshot:compile [info] | +- com.onespatial.gothic:gothic-java:jar:5.16:compile [info] | +- com.onespatial.gothic:gothic-lx86_64:jar:5.16:compile [info] | +- com.onespatial.gothic:gothic-w32:jar:5.16:compile the transitive dependency of gothic-java not appearing in tree (or when use dependency:list). can explain why gde-cfg not being listed above. as described in maven docs , transitive provided dependencies not added dependency tree. there bug report 2006, no progress since. you meant decl

functional programming - Check order of two elements in Java-8-Stream -

i want check order of 2 elements in java-8-stream. have iterator-solution: public static boolean isbefore (a a1, a2, stream<a> as) { iterator<a> = as.iterator (); while (it.hasnext ()) { a = it.next (); if (a == a1) { return true; } else if (a == a2) { return false; } } throw new illegalargumentexception ( a1 + " , + " a2 + " arent elements of stream!"); } is there solution without iterators in more functional/non imperative style? it this as.filter (a -> (a==a1) || (a==a2)).findfirst () and check if result a1 or a2 or empty. i'm sorry don't give full solution, it's hard if smart phone

c# - CollectionViewSource Violates MVVM -

i have mvvm app , in couple of vms use collectionviewsource.getdefaultview(datasource) initialize icollectionview , works perfectly. concern violating mvvm when using cvs in vms? thank inputs i prefer exposing collection in view model , creating collectionviewsource in xaml: <window.resources> <collectionviewsource x:key="collectionviewsource" source="{binding items}"> <i:interaction.behaviors> <behaviors:myfilterlogic /> </i:interaction.behaviors> </collectionviewsource> </window.resources> <itemscontrol itemssource="{binding source={staticresource collectionviewsource}}" /> and behavior class: public class myfilterlogic: behavior<collectionviewsource> { protected override void onattached() { base.onattached(); associatedobject.filter += associatedobjectonfilter; } private void associatedobjectonfilter(object