Posts

Showing posts from July, 2014

c# - How to add checkboxes to each day in this calendar view? -

i trying add simple checkbox feature each day in calendar view. must inline style of current calendar , when bool selected must able save changes database. suggestions appreciated. my main issue @ moment checkboxes being selected not being saved db. controller.cs private f2fw _db = new f2fw(); [httpget] public actionresult calendarindex() { list<event> events = new list<event>(); project.models.calendar calendar = new project.models.calendar(); calendar.setdate(datetime.now.year, datetime.now.month, datetime.now.day); calendar.view(@"~\views\patient\calendar.cshtml"); calendar.viewdata.add("events", events); viewbag.calendar = calendar.render(); return view(calendar); } [httppost] public actionresult calendarindex(user user, calendararg calarg, int daycounter, string[] cbx_day, patient patient, sessionexercise sessionexercise) { sessionin

osx - QLPreviewView can not show the quicklook preview in sandbox -

i use qlpreviewview show quicklook preview in app. without sandbox, works well, once change app sandbox, preview can not show up. i found error in console: quicklookuihelpe(20786) deny file-read-data xxx. i have used security-scoped bookmarks & com.apple.security.files.user-selected.read-write grant access user home dir, then: [allowedurl startaccessingsecurityscopedresource]; self.mypreiviewitem.myurl = fileurl; self.myqlpreviewview.previewitem = self.mypreiviewitem; [self.myqlpreviewview refreshpreviewitem]; [allowedurl stopaccessingsecurityscopedresource]; with these, can delete files of user home dir, qlpreviewview can not work. not know difference between these 2 scenes, qlpreviewview need more sandbox? if add com.apple.security.files.downloads.read-only entitlement, files in "downloads" can previewed, other files of user home dir can not previewed. finally have found solution! refreshpreviewitem async call, before mac finishes loading p

agda - how to define an element of type record? -

i have define datatype of real number as.. record ℝ : set field l : stream pair r : stream pair inhabited : ∀ (x : pair) → ( (x mem l) or (x mem r)) disjoint : ∀ (x : pair) → ( (not (x mem l)) or (not (x mem r))) located : ∀ (x y : pair) → (x ≤pair y) → ((x mem l) or (y mem r)) now want define element of type r . tried as.. mkreal : stream pair -> stream pair -> r mkreal x y = record { l = x; r = y}. but not working please help. your record ℝ has 5 fields, l , r , inhabited , disjoint , , located . define instance of ℝ , have supply values 5 fields: mkreal x y = record { l = x; r = y; inhabited = ?; disjoint = ?; located = ? } you have pass values of inhabited , disjoint , , located arguments mkreal well. by way, there way automatically define constructor record: record ℝ : set constructor mkreal field l : stream pair r : stream pair inhabited : ∀ (x : pair) → ((x mem l) or (x

Android Google Play Services in Emulator -

Image
i "google play services" message when run app using emulator i have checked many posts , said have download google apis , google play services and did, , have code in gradle.build dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.0.0' compile 'com.google.android.gms:play-services:7.3.0' } how resolve issue? please download 1 , check again : because using com.google.android.gms: play-services :7.3.0 in dependencies.

c++ - Need to create a custom data 2D texture with reasonable precision -

the idea i need create 2d texture fed resonably precise float values (i mean @ least precise glsl mediump float ). want store in each pixel's distance camera. don't want gl zbuffer distance near plane, own lovely custom data :> the problem/what i've tried by using standard texture color attachment, don't enough precision. or maybe missed ? by using depth attachment texture gl_depth_component32 getting clamped near plane distance - rubbish. so seems stuck @ not using depth attachment tho seem hold more precision. there way have mediump float precision standard textures ? i find strange opengl doesn't have generic container arbitrary data. mean custom bit-depth. or maybe missed again! you can use floating point textures instead of rgba texture 8 bit per pixel. support of these depends on devices want support, older mobile devices have lack of support these formats. example gl_rgba16f ( not tested ): glteximage2d(gl_texture_2d, mipm

clojure: stack overflow over range -

i trying solve problem 60 @ 4clojure.com sequence reductions my solution works last 2 cases fails first case in handling range. here solution (fn reds ([func lst](if (empty? lst) [] (reds func (first lst) (rest lst)))) ([func init lst](if (empty? lst) (println "hi") (concat [init] (reds func (func init (first lst)) (rest lst))))) ) i think because keep calling function on more terms of infinite list . how do better? update : solved using lazy-seq

c# - Calculate best collection to use in method -

i have search method in custom a* algorithm. uses collection keep track of search doing. set path know doing following collection: contains 860x (lookup) remove 91x add 270x the order or sorting not matter unless can find way order it. possible generate unique id each node based on x , y value. making dictionary lookup possible. is there way calculate based on method, best collection use in specific case? thanks in advance, smiley the general census says: if don't run performance issues, leave alone. if , can away it, leave alone. if do, can't (or love code tight), benchmark it, , you'll find. ( clarification : didn't use "premature optimization root of evil" reference, because think there place optimization. here's good article subject). from you're saying, doubt it'll make change, unless you're running on device next no resources, again, unless need it, above numbers, doubt you'll see difference. edit : pe

java - ImageIcon is displayed as a small square -

Image
where problem. not show image properly. default.png = ********* what see = ********* i dont think there problem png. in src , refreshed on eclipse. codes: import java.awt.*; import javax.swing.*; public class main { public static void main(string[] args) { jframe jf = new jframe(); jf.settitle( "test"); jf.setlayout( new flowlayout()); jf.setsize(350, 450); jf.setvisible(true); jf.setdefaultcloseoperation(jframe.exit_on_close); jf.add(new panel()); } } panel: import java.awt.graphics; import javax.swing.imageicon; import javax.swing.jpanel; public class panel extends jpanel { // properties public imageicon icon; // constructors public panel() { icon = new imageicon(this.getclass().getresource("default.png")); } public void paintcomponent(graphics g) { super.paintcomponent(g); g.drawimage(icon.getimage(), 0, 0, null); } } this answer addresses criticism of answer op. example in

php - Calling User Defined Function In User Defined Class -

i trying create custom class handle mailing me. here class (mailerclass.php) : class mailer { // private fields private $to; private $subject; private $message; // constructor function function __construct($to, $subject, $message) { $to = $to; $subject = $subject; $message = $message; } // function send mail constructed data. public function sendmail() { if (mail($to, $subject, $messagecontent)) { return "success"; } else { return "failed"; } } } when try call here (index.php) "call undefined function sendmail()" message? if ($_server['request_method'] == "post") { // import class include('mailerclass.php'); // trim , store data $name = trim($_post['name'])

symfony - Symfony2 LTS: how to upgrade from 2.3 to 2.7? -

symfony 2.7 released on 30th april 2015 , current lts (long term support) version after 2.3 version . maintenance these versions end on may 2016 symfony 2.3 , may 2018 symfony 2.7. security fixes released during 1 year after end of maintenance both versions. as suggested massimiliano arione in announce comments , changes required upgrade symfony 2.3 2.7 without having check minor upgrades (2.3 → 2.4, 2.4 → 2.5, etc.)? as reminded med in comment, symfony2 developers have tried keep backward compatibility in 2.x branch. long don't want switch 3.0 branch later, can ignore changes between 2.3 , 2.7 because deprecation changes. in order upgrade app symfony 2.3 symfony 2.7 you'll have update composer.json file: ( […] indicates unchanged code) old ( 2.3 ) version: { […] "autoload": { "psr-0": { "": "src/" } }, "require": { "php": ">=5.3.3", &qu

java - constrcut hashmap form database rows -

this question has answer here: group field name in java 7 answers i have following rows when query id listingid campaignid budget clicks 1 bvfbdvfdv xxx 500 20 2 ijioiooij xxx 500 13 3 awstetsee xxx 500 09 4 gccgdcdcc yyy 600 45 5 jjkhvnsdj yyy 600 28 6 bvkljfvjv zzz 1000 17 7 hejvejvek ppp 690 23 8 vmfklvmkv ppp 690 0 9 fnkvnfkvd ppp 690 11 how ever created entity class listingreport above rows , stored in list. i need create hashmap<string>,list<listingreport>> , where key campaignid column of listingreport , listingreport rows corresponding same campaignid stored in list. while iterating listingreport where key campaignid column w

Got Data in json object from url but can't bind it to listview in android application -

i creating android application, in got data database per current longitude , latitude. got data in json object cant bind in listview. please guide me. blockquote **@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.shopdetail); aq=new aquery(this); gpstracker gps = new gpstracker(shopdetail.this); if(gps.cangetlocation()){ double latitude = gps.getlatitude(); double longitude = gps.getlongitude(); getdatalatlog(latitude,longitude); }else{ gps.showsettingsalert(); } }** the getdatalatlog(latitude,longitude) method below. blockquote private void getdatalatlog(double latitude, double longitude) { string link = "http://192.168.0.104/php/webservice/comments.php?latitude='"+latitud

user interface - How to access handles of another MATLAB GUI -

i have 2 guis in matlab. stored values in gui1 in handles structure, when displays in command window, looks this: gui1: [1x1 figure] pushbutton2: [1x1 uicontrol] text2: [1x1 uicontrol] edit1: [1x1 uicontrol] output: [1x1 figure] val1: 0 i want use val1 set value, counter , in gui2. don't have command initialize counter in gui2. how access handles of gui1 in gui2? i tried use command guidata(findobj('tag', 'gui1')) handles, shows me it's empty. i tried doing following: in gui1, under openingfcn: handles.val1 = 0; guidata(hobject, handles); setappdata(handles.gui1,'val1', handles.val1) and in gui2, in pushbutton function: counter = getappdata(handles.gui1,'val1') but doesn't seem work either! gives me error saying, "reference non-existent field 'gui1'." i have handle visibility on gui1, , tag set "gui1". why still having

php - Remove item with $product_id - Woocommerce -

made function customer product added cart when reach specific amount. example of when customer reaches level 3 , product added. // bonus products $product_1 = '4751'; $product_2 = '4752'; $product_3 = '4753'; // cart value in clean format $cart_total = wc()->cart->get_cart_subtotal(); $cart_total = html_entity_decode($cart_total, ent_quotes, 'utf-8'); $cart_total_format = strip_tags($cart_total); $cart_value = preg_filter("/[^0-9]/", "", $cart_total_format); $sum_raw = $cart_value; // set sum level $level3 = '1500'; // check sum , apply product if ($sum_raw >= $level3) { // cycle through each product in cart , check match $found = 'false'; foreach (wc()->cart->cart_contents $item) { global $product; $product_id = $item['variation_id']; if ($product_id == $product_3) { $found = 'true'; } } // if product found nothing if ($found == 'true')

xml - Getting "The content of element 'MethodOfPayment' is not complete", even though the element exists -

i having problem validating xml payload against schema. schema section causing issue summarised below. element causing problem "methodofpayment/cheque", according schema documentation needs exist , should not contain content. <xsd:element name="methodofpayment" minoccurs="0"> <xsd:complextype> <xsd:choice> <xsd:element name="cheque"> <xsd:complextype/> </xsd:element> <xsd:element name="account"> <xsd:complextype> <xsd:choice> <xsd:element name="..."> </xsd:element> <xsd:element name="..."> </xsd:element> <xsd:element name="..."> </xsd:element> </xsd:choice> </xsd:complextype> </xsd:element> <xsd:element name="other"> <x

php - How to get the search results in real time? -

i'm building website udemy.com . on front page there search bar users search courses want enroll in. how done show results if users inputs something? i know ajax used in scenario. got working solution or better implementation? i hope i'm clear question. @arosh, looking this: jquery autocomplete

android - How to build for Qualcom Snapdragon 800 msm8974 chip on Samsung Note 3 -

hi have been working on compiling android image samsung note 3. downloaded source samsung, directed me download version of android open source project code. followed procedures in readme files provided. there discrepancies between procedures , tools used samsung vs. qualcomm's documents. question finding right procedure, , working image. have followed samsung's procedures, , have not resulted in working image of now. tried flash boot.img file created, , collected recovery logs posted here doing wrong though; not saying procedures wrong. here issues struggling with: 1- samsung's readme file says download arm-eabi-4.7, while qualcomm says used 4.8 compiler add on llvm. of now, plan try llvm 4.7 , 4.8 , see happens. have tried 4.7 w/o llvm , has not helped. 2 samsung procedures state update cross_compile statement path above arm-eaby-4.7 executable, export arch=arm, create config file following statement: make variant_defconfig=msm8974_sec_hlte_spr_defconfig msm897

c# - How to use variable of program class to another class? -

i need use following string variable of program class telnetconnection class,i possible ways not worked , please give me sugessions. thank you. program class class program { static void main() { string s = telnet.login("some credentials"); } } telnetconnection class class telnetconnection { public string login(string username, string password, int logintimeoutms) { int oldtimeoutms = timeoutms; timeoutms = logintimeoutms; writeline(username); s += read(); writeline(password); s += read(); timeoutms = oldtimeoutms; return s; } } it should this: public class telnetconnection { public string login(string username, string password, int logintimeoutms) { string retval = ""; int oldtimeoutms = timeoutms; timeoutms = logintimeoutms; writeline(username);

javascript - Unable to get json data in IE9 browsers -

here have javascript code getting json data. getting json values. in firefox , chrome able see values not in ie9. can please tell me why is? $.getjson("getuserinfo?uid=" + user, function(result) { console.log("user info"); console.dir(result); aadhaarid = result.aadhaarid; username = result.name; console.log(result.aadhaarid); $("#uname").html(result.name); });

How to plot a marker away from another marker by 100 metres in Mapbox Leaflet? -

i trying plot marker using leaflet , marker away the first 1 100 metres. plotting marker easy: var marker = l.marker([0, 0]).addto(map); but how plot marker away 1 100 metres? there way convert metres long , lat , plotting it? or there better way not aware of? i've forked fiddle show example. it's based on these answers: https://gis.stackexchange.com/questions/25877/how-to-generate-random-locations-nearby-my-location var r = 100/111300 // = 100 meters , y0 = original_lat , x0 = original_lng , u = math.random() , v = math.random() , w = r * math.sqrt(u) , t = 2 * math.pi * v , x = w * math.cos(t) , y1 = w * math.sin(t) , x1 = x / math.cos(y0) newy = y0 + y1 newx = x0 + x1

javascript - Change star rating on hover -

i use code display stars: <ul class="rating"> <li> <span class="ratingselector"> <input type="radio" name="ratings[1]" id="degelijkheid-1-5" value="1" class="radio"> <label class="full" for="degelijkheid-1-5"></label> <input type="radio" name="ratings[1]" id="degelijkheid-2-5" value="2" class="radio"> <label class="full" for="degelijkheid-2-5"></label> <input type="radio" name="ratings[1]" id="degelijkheid-3-5" value="3" class="radio"> <label class="full" for="degelijkheid-3-5"></label> <input type="radio" name="ratings[1]" id="degelijkheid-4-5" value="4" class="radio"> <label class="full" for="degelijkheid-4-5

Iterate JSON Response with Javascript / JQuery -

i have following json response trying iterate javascript :- { "documentresponseresults": [ { "name": "example1", "id": "1" }, { "name": "example2", "id": "2" }, { "name": "example3", "id": "3" } ] } i've tested makes sure valid json using online validator. i'm receiving via response webmethod in asp.net. in response looks this:- d:"{"documentresponseresults":[{"name":"example1","id":"1"},{"name":"example2","id":"2"},{"name":"example3","id":"3"}]}" i'm trying iterate items in json string. i started off parsing :- var jsondata = json.parse(response.d); i've

Convert c++ function to PHP? -

i convert xor function php. can done? needs work it`s working now... string encryptdecrypt(string toencrypt) { char key[9] = { '1', '2', '3', '4', '5', '6', '7', '8', '9' }; string output = toencrypt; (int = 0; < toencrypt.size(); i++) output[i] = toencrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; return output; } you can use same syntax in php c++ function does: function encryptdecrypt($toencrypt) { $key= array( '1', '2', '3', '4', '5', '6', '7', '8', '9' ); $key_len = count($key); $output = $toencrypt; ($i = 0; $i < strlen($toencrypt); $i++) { $output[$i] = $toencrypt[$i] ^ $key[$i % $key_len]; } return $output; } online demo c++ function: https://ideone.com/g9cphj online demo php function: https://ideone.com/3prgd0

google app engine - Under GAE, can a Python function detect if it is running locally or in production? -

i need app run differently depending on whether running on gae launcher on laptop or inside gae. app-id same, app.yaml same, there different can see? have read of documentation on handling requests https://cloud.google.com/appengine/docs/python/requests#python_the_environment section on environment. you see number of potentially relevant environment variables. 1 want server_software . contain "development" in value. also has been answered before on so. in python, how can test if i'm in google app engine sdk?

android - After changing action bar height, the homeasupindicator not vertical -

<style name="apptheme" parent="@style/theme.appcompat.light.darkactionbar"> <item name="actionbarstyle">@style/actionbarstyle</item> <item name="homeasupindicator">@drawable/homeasup_back</item> <item name="actionmenutextcolor">@color/text_orange</item> <item name="actionmenutextappearance">@style/actionbarmenutextstyle</item> </style> <style name="actionbarstyle" parent="@style/widget.appcompat.light.actionbar"> <item name="height">@dimen/actionbar_height</item> <item name="background">@color/actionbar_bg</item> <item name="titletextstyle">@style/actionbartitletext</item> <item name="icon">@mipmap/icon</item> <item name="displayoptions">showtitle|homeasup</item> </style> if not change a

MSISDN country code detection -

how can detect country code following msisdn ? cyprus (+357xxxxxxxx) -- 11 digits finland (+358xxxxxxxxxx) -- 13 digits serbia (+381xxxxxxx) -- 10 digits different countries have different number of digits in country code , in msisdn, so, there no way match country code alone entire number. so, how can country code specific msisdn? if data present in fixed format: {country_code} {space} {phone_digits} , use string operations (regex, splitting , on) country code part. determine country code represents, should match against list of known country codes - either store these in database or use web service validation. a possible approach database country codes, , compare manually find match - in case format not consistent. error prone, country codes may differ in length , match wrong one. acceptable approach, if there no other choice, first match longest, , shorter codes - yet there no guarantee invalid matches. avoid issue, consider next suggestion: if have contro

hadoop - Issues with running mapreduce on hbase 1.0.1 -

i'm running hbase 1.0.1 standalone on apache hadoop 2.7 cluster environment. i'm getting below issue while running simple map reduce job on hbase. exception in thread "main" java.io.filenotfoundexception: file not exist: hdfs://hdmaster:9000/usr/hadoop/share/hadoop/common/lib/zookeeper-3.4.6.jar @ org.apache.hadoop.hdfs.distributedfilesystem$22.docall(distributedfilesystem.java:1309) @ org.apache.hadoop.hdfs.distributedfilesystem$22.docall(distributedfilesystem.java:1301) @ org.apache.hadoop.fs.filesystemlinkresolver.resolve(filesystemlinkresolver.java:81) @ org.apache.hadoop.hdfs.distributedfilesystem.getfilestatus(distributedfilesystem.java:1301) @ org.apache.hadoop.mapreduce.filecache.clientdistributedcachemanager.getfilestatus(clientdistributedcachemanager.java:288) @ org.apache.hadoop.mapreduce.filecache.clientdistributedcachemanager.getfilestatus(clientdistributedcachemanager.java:224) .. .. .. .. my hadoop

models - importError: No module named django.db -

from django.db import models # create models here. def article(models.model): title=models.charfield(max_length=200) body=models.textfield() pub_date=models.datetimefield('date published') likes=models.integerfield() def __unicode__(self): return self.title this code using django 1.8.2 within virtual environment are sure create simple project? django-admin.py startproject nameofyourproject mkdir apps cd apps django-admin.py startapp nameofyourapp add in settings in variable "installed apps" new app nothing should fail...

single sign on - Customizing sso_redirect.html in wso2 IS 5.0 -

i'm trying customize sso_redirect.html page in wso2 5.0 sp1 found in location is_home\repository\resources\security\sso_redirect.html. though javascript or inline css changes getting reflected in page, reference images not honored. e.g tag doesnt fetch image on page. there limitation on front? thanks in advance. cijoy this page customized defining resources(style sheet, images, java script, etc..) references url instead of relative path. resources may available @ page loading time.

android - Should I put getDefaultSharedPreferences in application class -

as far know getdefaultsharedpreferences loading preference file memory. in app have many classes pass context , use getdefaultsharedpreferences . during execution these classes load many times, result getdefaultsharedpreferences called allot. question is: should load preferences 1 time in application class , access preferences there in classes? doable? increase speed of app? did this? something this: private static myapplication singleton; public static myapplication getinstance() { return singleton; } @override public void oncreate() { super.oncreate(); mypreferences = preferencemanager.getdefaultsharedpreferences(this); } public sharedpreferences getpreferences(){ return mypreferences; } sharedpreferences caches after first load, disk access load data take time 1 time.once in memory, after first reference. first time retrieve specific sharedpreferences (e.g., preferencemanager.getdefaultsharedpreferences() ), data loaded disk, , kept around.

c# - Use XERO API in CRM Plugin, RSA Encryption Private Key Issues(CRM ONLINE) -

i trying connect ms crm 2015 plugin(online) xero accounting system(online). xero has api source code available. have downloaded source code , using same in our plugin code. unfortunately xero uses rsa public/private key encryption authentication etc. in plugin not have access key store private key becomes unavailable, have tried export key console app , embed file resource in plugin. failed giving me error system.security.securityexception: request permission of type 'system.security.permissions.keycontainerpermission, mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089' failed i hope making sense, if else has faced , solved problem, please let me know how did it.

mysql - datetime select with -15 minute interval showing wrong result -

Image
for room reservation page i'm making query entries among 3 tables. datetime values in 1 table, table keeps info if room key has been checked out. , table keeps reservation information. if current time has past start of reservation time @ least 15 minutes , key has not been checked out, entry should deleted. problem is, deletes future reservations, start time of reservation has not past yet. query looks this. select dt.field_reservation_datetime_value , dt.entity_id , co.field_reservation_checked_out_value , co.entity_id , res.reservation_id field_data_field_reservation_datetime dt join field_data_field_reservation_checked_out co on co.entity_id = dt.entity_id join studyroom_reservation res on res.reservation_id = co.entity_id co.field_reservation_checked_out_value = 0 , date (dt.field_reservation_datetime_value) <= now() - interval 15 minute right 9:52am, shouldn't showing next 2 hours , 38 minutes. this: any idea may

regex - JavaScript regexp select only last occurrence -

select last occurrence i'm trying select last word (until space), come after last white space , @ character. following string hello hi @why helo @blow @name // capture: name hello hi @why helo @blow name@name // capture: blow and string @blow not know how resolve // capture: blow here last occurrence first word blow , select @ after word (obviously whitespace not in first word). i tryed this: https://regex101.com/r/pg1ku1/1 simplest answer: /\b@[^@]\w*(?!.*?\s@)/ see demo

c# - Compressing resources with gzip or deflate can reduce the number of bytes sent over the network -

Image
my website www.hashgurus.com this hosted on windows 2008 r2. google site health suggests following: enable compression compressing resources gzip or deflate can reduce number of bytes sent on network. i checked iis setting and static compression enabled. google asks me following: compressing http://hashgurus.com/js/jquery-ui.min.js save 163.1kib (73% reduction). compressing http://hashgurus.com/css/style.css save 98.6kib (83% reduction). compressing http://hashgurus.com/js/jquery-2.1.0.min.js save 53kib (64% reduction). compressing http://hashgurus.com/background/gallery3b.aspx?page=1&q= save 51.4kib (91% reduction). is there else should doing other this. please note want website rather doing websites in server. enabling compression on iis open iis manager , navigate level want manage. in features view, double-click compression. on compression page, select box next enable dynamic content compression. click apply in actions pane. in addition

ios - UILabel redraws the view. How to avoid this behavior? -

i have viewcontroller 3 subviews. use autolayout , size classes. these views animated , change location , size. after animations update label whole view redrawn each view in initial position , size. shouldn't happen. in apple developer reference says: "the default content mode of uilabel class uiviewcontentmoderedraw. mode causes view redraw contents every time bounding rectangle changes. can change mode modifying inherited contentmode property of class." it doesn't seem clear me how modify -contentmode- in order update label , leave view -as is-. can give me clue? in advance. it sounds may using autolayout lay out view (e.g., via constraints in ib), you're manipulating views' frame s directly animations - case? if so, should instead animating constant values of constraints, or possibly transform s of subviews. if manipulate frames directly in view uses autolayout, changes over-written next time system lays out view (e.g. after

c# - Using Equals with LINQ on an IEnumerable -

this code : var allsubjectsforastudent = getallsubjects<subject>(studentid); returns ienumerable<subject> and can see bunch of subjects returned in debugger. want check particular subject doing case insensitive comparison. this code have: var studentsubjects = allsubjectsforastudent.where(s => s.name.equals(subjectname, stringcomparison.currentcultureignorecase)); 'subjectname' parameter method recieve. when line executes 'object not set instance of object' error. so want case insensitive search , return first item when there more 1 , return empty collection when there none. any clues? edit 1 the answers suggest there can entry in first collection might have 'null'. while observation true program makes sure 'subject name' can not null value. hope helps. thanks in advance. you try: var studentsubjects = allsubjectsforastudent.where(s => !string.isnullorwhitespace(s.name) && s.name.to

Waiting for the user activities before proceeding to next step of code jquery -

i building simple plugin confirmation. send request plugin yes or no activities. click yes delete item database & no escape step. want plugin wait user activity. if user click no stop current code of function. if user press yes proceed remaining part of code. like: $(document).on("click",".somebtn", function(){ $(this).confirm(); //calls plugin $(this).confirm.no(); //calling plugin 'no' function // how returned data function of plugin //here want plugin wait user activity. //if click 'no' stop code execution here , //if click 'yes' go , execute code below. $(this).confirm.yes(); }); plugin jquery.fn.confirm = function () { jquery.fn.confirm.yes = function (data) { //ajax calls }; jquery.fn.confirm.no = function () { return "abcd"; }; }; i've prepared example simple modal box.

Combine two mysql queries with two different order by statements -

i want combine these 2 queries. select * table1 status='pending' , adr='' order id desc limit 0,1; select * table1 status='pending' , adr='new' order rand() limit 1 you can use union set operator concatenate results of 2 queries ( select * table1 status='pending' , adr='' order id desc limit 1 ) union ( select * table1 status='pending' , adr='new' order rand() limit 1 ) reference: union all https://dev.mysql.com/doc/refman/5.5/en/union.html

c# - Particular Constructor was called before the Method is called -

class employeebase : base { protected idependency _dependency; ctor(idependency dependency) { _dependency = dependency; } ctor(string name, int age) { base.initialize("xxx " + name, "yyy" + age); } ilist<emp> getallemployees() { return _dependency.getrecords(); } } class filteredemployeebase : employeebase { ctor(string name, int age) : base(name, age){} ilist<emp> getmatchingemployees() { return _dependency.getrecords(); } } // test getmatchingemployees, have inject idependency , check assert called on _dependency.getrecords... but key thing here is... base classes overloaded constructor should have been called - how test in rhino mocks pls note: except filteredemployeebase rest legacy code & don't have control on changing them. if call filteredemployeebase.getmatchingemployees without calling base class constructor taking dependency , ca

c# - i get "Server was unable to process request.---> Access is denied", when hosting app as a usercontrol -

i'm afraid can't undle configuration in iis 7. have client side app in winform connect server side , take credindials windows auth , work well. problem when host client app usercontrol in diffrent app host it. in case, soapexception "soapexception: server unable process request.---> access denied, message: 1 or more errors accoured". i tried connect app host uc , succeed. *i fail debug server side when hosting app usercontrol, seems server side didn't rquest @ all. soo, don't know can more?? wish help.

How to supress invalid type for Teradata Insert? -

when inserting data 1 table , teradata performs automatic type cast. example if 1 inserts varchar date field , teradata cast varchar date . , works perfect if varchars valid date strings. however, when teradata encounters varchar not valid date , unable cast , shows error . how can force dirty insert ? want teradata insert null if it's unable cast (silently ignoring errors) is there way ? you can try using calendar table. of depend on structure of data, basically: insert <your destination table> select <t1.columns>, t2.calendar_date <your table> t1 left join sys_calendar.calendar t2 on t1.<your character date column> = cast (cast(t2.calendar_date date format 'yyyy-mm-dd') char(10)) the formatting depend on column looks like. instead of inserting column source table, insert calendar_date column calendar table. if date in source table invalid, you'll insert null.

Executing a cassandra insert query through Python multiprocessing queue -

i have cassandra keyspace sujata .i connecting cassandra using python driver cassandra.cluster .the column family of sujata hello . following code:- from multiprocessing import process,queue cassandra.cluster import cluster import os queue=queue() cluster = cluster(['127.0.0.1']) metadata = cluster.metadata session = cluster.connect("sujata") def hi(): global session global queue while true: y=queue.get() if y=="exit": os._exit(0) else: print y session.execute(y) if __name__=="__main__": x=process(target=hi) x.start() in xrange(10): z="insert hello(name) values('" + str(i) + "');" queue.put(z) if i==9: queue.put("exit") session.cluster.shutdown() session.shutdown() in table, have column name want insert value of i.the insert query passed through queue.i able contents of

ios - How to retrieve data from NSUserDefaults? -

currently, try make music playlist application. try save , retrieve playlist data nsuserdefaults. have no problem when saving data got error when retrieving data. i got: terminating app due uncaught exception 'mpmediaitemcollectioninitexception', reason: '-init not supported, use -initwithitems: i'm following answer play ipod playlist retrieved saved persistentid list try write in swift. here save function: func saveplaylist(var mediaitemcollection: mpmediaitemcollection){ var items: nsarray = mediaitemcollection.items var listtosave: nsmutablearray = nsmutablearray() song in items{ var persistentid: anyobject! = song.valueforproperty(mpmediaitempropertypersistentid) listtosave.addobject(persistentid) } var data: nsdata = nskeyedarchiver.archiveddatawithrootobject(listtosave) nsuserdefaults.standarduserdefaults().setobject(data, forkey: "songslist") nsuserdefaults.standarduserdefaults().syn

android - how to get call number info for outgoing and incoming calls -

i have made broadcast receiver , whenever outgoing call event happens fetches outgoing number. want integrate incoming number too. sharing code. callreceiver class public class callreceiver extends broadcastreceiver { telephonymanager tmanager; @override public void onreceive(context context, intent intent) { final string outgoingcallnumber = intent.getstringextra(intent.extra_phone_number); log.i("clapp", outgoingcallnumber); } } manifest file <receiver android:name=".callreceiver"> <intent-filter> <action android:name="android.intent.action.new_outgoing_call"/> <action android:name="android.intent.action.phone_state" /> </intent-filter> </receiver> error-log : 06-01 10:57:36.209: e/dalvikvm(29762): not find class 'android.content.restrictionsmanager', referenced method com.salesforce.androidsdk.config.runtimeconfig.getrestriction