Posts

arraylist - Java: Checking if an IP address is in an Array List -

is there particular way check if ip address not exist in arraylist? right have arraylist made of strings of ip addresses (e.g. "192.168.0.4", etc.). after receiving packet i'd check if packet's ip address belongs in arraylist. at first thought suffice: for (int = 0; < mylist.size(); i++) { if (packet.getaddress().equals(inetaddress.getbyname(mylist.get(i)))) { system.out.println("this packet's ip address in list"); } else { system.out.println("this packet's ip address not in list!"); } i thought else statement solve situation wrong. suggestions appreciated. you have check entire list before know ip not there : boolean found = false; (int = 0; < mylist.size() && !found; i++) { if (packet.getaddress().equals(inetaddress.getbyname(mylist.get(i)))) { found = true; system.out.println("this packet's ip address in list"); } } if (!found) { system.out....

ios - <Error>: CGAffineTransformInvert: singular matrix. in cellForRowAtIndexPath -

i have tableviewcell button load photo imagepickercontroller. here code imagepickercontroller. send tableviewcell index tag button find out on cell button clicked. when user selects image gallery sets image background of loading button , saves image array of selected images. // photo function func getphotofromgallery(sender: uibutton){ celltag = sender.tag picker.allowsediting = false picker.sourcetype = .photolibrary presentviewcontroller(picker, animated: true, completion: nil) } func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [nsobject : anyobject]) { var chosenimage = info[uiimagepickercontrolleroriginalimage] as! uiimage let cell = tableview.cellforrowatindexpath(nsindexpath(forrow: celltag!, insection: 0)) as! questiontableviewcell cell.photoimageview.setbackgroundimage(chosenimage, forstate: uicontrolstate.normal) photos[celltag!] = chosenimage dismissviewcontrolleranimated(true, complet...

c# - Bind enum to AspxListBox -

i have following enum called billtypes : public enum billtypes { [enumproperties("natural gas")] naturalgas= 1, [enumproperties("electric")] electric = 2, [enumproperties("water")] water = 3 } how can bind enum aspxlistbox ? i think should able run following: (please bear me, if code not work, due i'm not familar asp ) billtypes b = billtypes.electric; aspxlistbox alb = new aspxlistbox(); alb.items.add(billtypes.natural_gas.tostring().replace("_", " ")); alb.items.add(billtypes.electric.tostring().replace("_", " ")); alb.items.add(billtypes.water.tostring().replace("_", " ")); alb.selectedindexchanged += (ob, ex) => (indexchanged()); and method indexchanged : public void indexchanged() { b = (billtypes)(alb.selectedindex + 1); // here can whatever want... } note edited enum class: public enum billtypes { [enumproperties(...

php - Laravel 5 Model Class not found -

i trying port web app laravel 4 5 having issues in 1 of model classes not found. i have tried utilize namespacing , have following models located locally c:\xampp\htdocs\awsconfig\app\models the file error appears in looks <?php use app\models\securitygroup; function from_camel_case($input) { preg_match_all('!([a-z][a-z0-9]*(?=$|[a-z][a-z0-9])|[a-za-z][a-z0-9]+)!', $input, $matches); $ret = $matches[0]; foreach ($ret &$match) { $match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match); } return implode('_', $ret); } $resource_types = array(); $resource_types['aws::ec2::instance'] = 'ec2instance'; $resource_types['aws::ec2::networkinterface'] = 'ec2networkinterface'; $resource_types['aws::ec2::vpc'] = 'vpc'; $resource_types['aws::ec2::volume'] = 'volume'; $resource_types['aws::ec2::securitygroup'] = 'securitygroup'; $resour...

c# - DateFormat in radGridViewDataColumn WPF -

i'm working on wpf mvvm application telerik controls. need format 1 of column date( mm/dd/yyyy ). when select date calendar works fine , after switching next column value showed mm/dd/yyyy 12:00:00 . dont need time displyed along. //code: <telerik:gridviewdatacolumn header="apprvddate" datamemberbinding="{binding approveddate, mode=twoway, updatesourcetrigger=propertychanged}" dataformatstring="{}{0: mm/dd/yyyy}"> <telerik:gridviewdatacolumn.celledittemplate> <datatemplate> <telerik:raddatepicker name="clrdatepicker" selecteddate="{binding approveddate, mode=twoway}" allowdrop="true"> </telerik:raddatepicker> </datatemplate> </telerik:gridviewdatacolumn.celledittemplate> </telerik:gridviewdatacolumn> where approveddate string object in collection. the dataformatstring doesn't work. tried changing many fo...

javascript - Ember data, relationships and JSON -

Image
i have following json being returned api: { "project": [ { "id": "1", "name": "my first project", "owned_by": "1", "updated_at": { "date": "2015-05-06 15:46:27.000000", "timezone_type": 3, "timezone": "europe/london" }, "created_at": { "date": "2015-05-06 15:46:27.000000", "timezone_type": 3, "timezone": "europe/london" } } ], "subscriptions": [ { "id": "10", "output": "hello world", "project_id": "1", "owned_by": "1", "updated_at": { "date": "2015-05-06 16:56:40.000000", ...

c# - Regex lookahead discard a match -

i trying make regex match discarding lookahead completely. \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* this match , regex101 test . but when email starts - or _ or . should not match completely, not remove initial symbols. ideas welcome, i've been searching past half hour, can't figure out how drop entire email when starts symbols. you can use word boundary near @ negative lookbehind check if @ beginning of string or right after whitespace, check if 1st symbol not inside unwanted class [^\s\-_.] : (?<=^|\s)[^\s\-_.]\w*(?:[-+.]\w+)*\b@\w+(?:[-.]\w+)*\.\w+(?:[-.]\w+)* see demo list of matches: support@github.com s.miller@mit.edu j.hopking@york.ac.uk steve.parker@soft.de info@company-hotels.org kiki@hotmail.co.uk no-reply@github.com s.peterson@mail.uu.net info-bg@software-software.software.academy additional notes on usage , alternative notation note best practice use few escaped chars possible in regex, so, [^\s\-_.] can written [^\s_.-] , h...