Daily Archives

Articles indexed Tuesday June 25 2013

Page 8/20 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • replacing values in formated file with python

    - by froggy
    I have a string see attached file like that and i would like to modify it using a function Giving section name parameter name and value to set Also in case i want to modify several parameters for a same section how can i have position in file to avoid scanning x time for a same section and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question and other to pass my question an and other to pass my question d other to pass my question and other to pass my question and other to pass my question and other to pass my questionand other to pass my question and other to pass my question

    Read the article

  • why my application sometimes got error in early launch?

    - by Hendra
    I have some problem. sometimes when I just try to run my application, it is going to be force close. I don't know why it is going to be happened. here are my source code. AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setCancelable(false); //AlertDialog.Builder alert = new AlertDialog.Builder(this); ..... alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { no_pasien = no_pas.getText().toString(); new LoginProses().execute(); ..... alert.show(); class LoginProses extends AsyncTask<String, String, String> { protected void onPreExecute() { super.onPreExecute(); ...... } protected String doInBackground(String... args) { List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("no_pasien", no)); JSONObject json = jsonParser.makeHttpRequest(url_login, "POST", params); try { int success = json.getInt(TAG_SUCCESS); if (success == 1) { // successfully created product pasien = json.getJSONArray("pasien"); JSONObject c = pasien.getJSONObject(0); int id = c.getInt("id"); new Temporary().setIdPasien(id); Intent goMainAct = new Intent(); // goMainAct.putExtra("id", id); goMainAct.setClass(Login.this, MainActivity.class); finish(); startActivity(goMainAct); } else { // failed to create product Intent getReload = getIntent(); getReload.putExtra("status", 1); finish(); startActivity(getReload); } } catch (JSONException e) { if(pDialog.isShowing()){ pDialog.dismiss(); } } return null; } protected void onPostExecute(String file_url) { // dismiss the dialog once done pDialog.dismiss(); } } here is the log error for my problem: //HERE IS THE LOG: 06-25 22:57:23.836: E/WindowManager(7630): Activity com.iteadstudio.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41939850 that was originally added here 06-25 22:57:23.836: E/WindowManager(7630): android.view.WindowLeaked: Activity com.iteadstudio.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41939850 that was originally added here 06-25 22:57:23.836: E/WindowManager(7630): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:344) 06-25 22:57:23.836: E/WindowManager(7630): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:267) 06-25 22:57:23.836: E/WindowManager(7630): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215) 06-25 22:57:23.836: E/WindowManager(7630): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140) 06-25 22:57:23.836: E/WindowManager(7630): at android.view.Window$LocalWindowManager.addView(Window.java:537) 06-25 22:57:23.836: E/WindowManager(7630): at android.app.Dialog.show(Dialog.java:278) 06-25 22:57:23.836: E/WindowManager(7630): at com.iteadstudio.Login$LoginProses.onPreExecute(Login.java:122) 06-25 22:57:23.836: E/WindowManager(7630): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:561) 06-25 22:57:23.836: E/WindowManager(7630): at android.os.AsyncTask.execute(AsyncTask.java:511) 06-25 22:57:23.836: E/WindowManager(7630): at com.iteadstudio.Login$3.onClick(Login.java:95) 06-25 22:57:23.836: E/WindowManager(7630): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166) 06-25 22:57:23.836: E/WindowManager(7630): at android.os.Handler.dispatchMessage(Handler.java:99) 06-25 22:57:23.836: E/WindowManager(7630): at android.os.Looper.loop(Looper.java:137) 06-25 22:57:23.836: E/WindowManager(7630): at android.app.ActivityThread.main(ActivityThread.java:4441) 06-25 22:57:23.836: E/WindowManager(7630): at java.lang.reflect.Method.invokeNative(Native Method) 06-25 22:57:23.836: E/WindowManager(7630): at java.lang.reflect.Method.invoke(Method.java:511) 06-25 22:57:23.836: E/WindowManager(7630): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823) 06-25 22:57:23.836: E/WindowManager(7630): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590) 06-25 22:57:23.836: E/WindowManager(7630): at dalvik.system.NativeStart.main(Native Method) 06-25 22:57:23.946: D/dalvikvm(7630): GC_CONCURRENT freed 782K, 6% free 14319K/15203K, paused 4ms+3ms 06-25 22:57:23.976: D/AndroidRuntime(7630): Shutting down VM 06-25 22:57:23.976: W/dalvikvm(7630): threadid=1: thread exiting with uncaught exception (group=0x40ab4210) 06-25 22:57:23.986: E/AndroidRuntime(7630): FATAL EXCEPTION: main 06-25 22:57:23.986: E/AndroidRuntime(7630): java.lang.IllegalArgumentException: View not attached to window manager 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:587) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:324) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:151) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.app.Dialog.dismissDialog(Dialog.java:321) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.app.Dialog$1.run(Dialog.java:119) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.app.Dialog.dismiss(Dialog.java:306) 06-25 22:57:23.986: E/AndroidRuntime(7630): at com.iteadstudio.Login$LoginProses.onPostExecute(Login.java:177) 06-25 22:57:23.986: E/AndroidRuntime(7630): at com.iteadstudio.Login$LoginProses.onPostExecute(Login.java:1) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.os.AsyncTask.finish(AsyncTask.java:602) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.os.AsyncTask.access$600(AsyncTask.java:156) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.os.Handler.dispatchMessage(Handler.java:99) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.os.Looper.loop(Looper.java:137) 06-25 22:57:23.986: E/AndroidRuntime(7630): at android.app.ActivityThread.main(ActivityThread.java:4441) 06-25 22:57:23.986: E/AndroidRuntime(7630): at java.lang.reflect.Method.invokeNative(Native Method) 06-25 22:57:23.986: E/AndroidRuntime(7630): at java.lang.reflect.Method.invoke(Method.java:511) 06-25 22:57:23.986: E/AndroidRuntime(7630): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823) 06-25 22:57:23.986: E/AndroidRuntime(7630): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590) 06-25 22:57:23.986: E/AndroidRuntime(7630): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • HTTP error code 405: tomcat Url mapping issue

    - by Andrew
    I am having trouble POSTing to my java HTTPServlet. I am getting "HTTP Status 405 - HTTP method GET is not supported by this URL" from my tomcat server". When I debug the servlet the login method is never called. I think it's a url mapping issue within tomcat... web.xml <servlet-mapping> <servlet-name>faxcom</servlet-name> <url-pattern>/faxcom/*</url-pattern> </servlet-mapping> FaxcomService.java @Path("/rest") public class FaxcomService extends HttpServlet{ private FAXCOM_x0020_ServiceLocator service; private FAXCOM_x0020_ServiceSoap port; @GET @Produces("application/json") public String testGet() { return "{ \"got here\":true }"; } @POST @Path("/login") @Consumes("application/json") // @Produces("application/json") public Response login(LoginBean login) { ArrayList<ResultMessageBean> rm = new ArrayList<ResultMessageBean>(10); try { service = new FAXCOM_x0020_ServiceLocator(); service.setFAXCOM_x0020_ServiceSoapEndpointAddress("http://cd-faxserver/faxcom_ws/faxcomservice.asmx"); service.setMaintainSession(true); // enable sessions support port = service.getFAXCOM_x0020_ServiceSoap(); rm.add(new ResultMessageBean(port.logOn( "\\\\CD-Faxserver\\FaxcomQ_API", /* path to the queue */ login.getUserName(), /* username */ login.getPassword(), /* password */ login.getUserType() /* 2 = user conf user */ ))); } catch (RemoteException e) { e.printStackTrace(); } catch (ServiceException e) { e.printStackTrace(); } // return rm; return Response.status(201).entity(rm).build(); } @POST @Path("/newFaxMessage") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public ArrayList<ResultMessageBean> newFaxMessage(FaxBean fax) { ArrayList<ResultMessageBean> rm = new ArrayList<ResultMessageBean>(); try { rm.add(new ResultMessageBean(port.newFaxMessage( fax.getPriority(), /* priority: 0 - low, 1 - normal, 2 - high, 3 - urgent */ fax.getSendTime(), /* send time */ /* "0.0" - immediate */ /* "1.0" - offpeak */ /* "9/14/2007 5:12:11 PM" - to set specific time */ fax.getResolution(), /* resolution: 0 - low res, 1 - high res */ fax.getSubject(), /* subject */ fax.getCoverpage(), /* cover page: "" – default, “(none)� – no cover page */ fax.getMemo(), /* memo */ fax.getSenderName(), /* sender's name */ fax.getSenderFaxNumber(), /* sender's fax */ fax.getRecipients().get(0).getName(), /* recipient's name */ fax.getRecipients().get(0).getCompany(), /* recipient's company */ fax.getRecipients().get(0).getFaxNumber(), /* destination fax number */ fax.getRecipients().get(0).getVoiceNumber(), /* recipient's phone number */ fax.getRecipients().get(0).getAccountNumber() /* recipient's account number */ ))); if (fax.getRecipients().size() > 1) { for (int i = 1; i < fax.getRecipients().size(); i++) rm.addAll(addRecipient(fax.getRecipients().get(i))); } } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } return rm; } } Main.java private static void main(String[] args) { try { URL url = new URL("https://andrew-vm/faxcom/rest/login"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setRequestProperty("Content-Type", "application/json"); FileInputStream jsonDemo = new FileInputStream("login.txt"); OutputStream os = (OutputStream) conn.getOutputStream(); os.write(IOUtils.toByteArray(jsonDemo)); os.flush(); if (conn.getResponseCode() != 200) { throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); } BufferedReader br = new BufferedReader(new InputStreamReader( (conn.getInputStream()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { System.out.println(output); } // Don't want to disconnect - servletInstance will be destroyed // conn.disconnect(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } I am working from this tutorial: http://www.mkyong.com/webservices/jax-rs/restfull-java-client-with-java-net-url/

    Read the article

  • using subset but old variables still left

    - by user2520852
    I am working with a data set, which is basically daily usage data (let's just say variable X and Y) by different cities (about 150 cities). I have created a subset of data for only specific cities, choosing just 3 of the 150 cities. Then when I do tapply by cities, I get means for 3 cities but also get NA for all other 147 cities that was in the data set. I am using the below coding df<-read.csv(...) df_sub<-subset(df,df$City==1|df$City==3|df$City==19) X_Breakdown<-tapply(X,df_sub$City, mean, na.rm=TRUE) Print(X_Breakdown) City 1 City 2 15 NA City 3 City 4 12 NA City 5 City 6 NA NA Hope you get the idea. I would like to get a dataset that only contains the 3 cities that I'm interested in. It seems that the set of variables is encoded in R, is there a way to fix this? Kindly advise. Thanks

    Read the article

  • PHP - Select from database the same query

    - by How to PHP
    I created a table that contains the name of the user and his job, and created PHP page that shows me all the users that works doctor, I entered doctor into a variable then I selected from the table where Jobs equal to $doctor, that is great, but I need it to get the same Jobs into a table in the page and the other same jobs into a table in the same page. this is my code that shows only the users works doctor in one table, <html> <h1>Doctors</h1> </html> <?php mysql_connect('localhost','root',''); mysql_select_db('data'); $doctor='doctor'; $query= mysql_query("SELECT * FROM `users` WHERE `job` = '$doctor'")or die(mysql_error()); while ($arr = mysql_fetch_array($query)) $name= $arr['name']; echo $name; } ?> That shows me doctors when I put doctor in a variable I want to show all same Jobs in a table. Is there is a way to do this? Thanks :)

    Read the article

  • Moving directory after compilation of R

    - by CravingSpirit
    I compiled R in /tmp/R-3.0.0 and then moved it to /home/user/opt/R-3.0.0, then I got an error when executing R: /home/kaiyin/opt/R-3.0.0/bin/R: line 236: /tmp/R-3.0.0/etc/ldpaths: No such file or directory ERROR: R_HOME ('/tmp/R-3.0.0') not found If I export R_HOME='/home/kaiyin/opt/R-3.0.0', it still gives almost the same error: WARNING: ignoring environment value of R_HOME /home/kaiyin/opt/R-3.0.0/bin/R: line 236: /tmp/R-3.0.0/etc/ldpaths: No such file or directory ERROR: R_HOME ('/tmp/R-3.0.0') not found Is there a way to solve this, or do I have to recompile it?

    Read the article

  • Why does the javascript style property not work as expected?

    - by dramasea
    <html> <head> <style type="text/css"> #wow{ border : 10px solid red; width: 20px; height: 20px; } </style> </head> <body> <div id="wow"></div> <script> var val = document.getElementById("wow"); alert(val.style.length); </script> </body> </html> This is my code, why is val.style.length 0? Because I defined 3 properties, I expected it to be 3

    Read the article

  • How to extend the Smarty class right

    - by Evolutio
    I have a Problem with Smarty. I have made this class: <?php require_once(INCLUDE_PATH.'smarty/Smarty.class.php'); class IndexPage extends Smarty { public $templateName = 'index.tpl'; public function __construct() { parent::__construct(); $this->showTemplate(); } public function showTemplate() { self::display('index.tpl'); } } ?> But why it doesn't works? Here is the Error: Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'index.tpl'' in D:\xampp\htdocs\aiondb\lib\smarty\sysplugins\smarty_internal_templatebase.php:127 Stack trace: #0 D:\xampp\htdocs\aiondb\lib\smarty\sysplugins\smarty_internal_templatebase.php(374): Smarty_Internal_TemplateBase->fetch('index.tpl', NULL, NULL, NULL, true) #1 D:\xampp\htdocs\aiondb\lib\classes\IndexPage.class.php(14): Smarty_Internal_TemplateBase->display('index.tpl') #2 D:\xampp\htdocs\aiondb\lib\classes\IndexPage.class.php(10): IndexPage->showTemplate() #3 D:\xampp\htdocs\aiondb\index.php(3): IndexPage->__construct() #4 {main} thrown in D:\xampp\htdocs\aiondb\lib\smarty\sysplugins\smarty_internal_templatebase.php on line 127

    Read the article

  • How to import a module from a directory?

    - by Roman
    On my system I have two versions of Python (to call them I type python and python2 in the command line). When I use the first version of Python, I cannot import sklearn module but I can do it in the second version of Python. I would like to use the first version of python (because other modules are available there) and, at the same time, I would like to be able to import sklearn from this version of Python. My solution was to use: import sys sys.path.append('location_of_the_sklearn_module') To find the location of the sklearn module I started a python session (using the second version of python, in which sklearn works). The I type: import sklearn sklearn.__file__ As a result I got: /home/name/my_name/numpy/local/lib/python2.7/site-packages/sklearn/__init__.pyc In the session of the first version of Python I tried: import sys sys.path.append('/home/name/my_name/numpy/local/lib/python2.7/site-packages/sklearn') import sklearn Unfortunately it did not work. As a result I got: ImportError: No module named sklearn Does anybody know what I am doing wrong and if it is possible to reach the goal in the way I try?

    Read the article

  • Align table columns HTML

    - by Luigi Tiburzi
    I finally was able to align the columns in the tables of a page of my website. Though I found the solution I don't understand it. This is a fiddle I prepared. If you delete display: block from the CSS the columns are centered perfectly. The fact is that I don't understand what that instruction is causing problems, doesn't it means that elements are displayed as block elements? Shouldn't it cause the elements (the raw in particular) to fill an entire line? Thanks for your explanation

    Read the article

  • Best way to check for null values in Java?

    - by Arty-fishL
    I need to check whether the function of an object returns true or false in Java, but that object may be null, so obviously then the function would throw a NullPointerException. This means I need to check if the object is null before checking the value of the function. What is the best way to go about this? I've listed some methods I considered, I just want to know the most sensible one, the one that is best programming practice for Java (opinion?). // method 1 if (foo != null) { if (foo.bar()) { etc... } } // method 2 if (foo != null ? foo.bar() : false) { etc... } // method 3 try { if (foo.bar()) { etc... } } catch (NullPointerException e) { } // method 4 // would this work all the time, would it still call foo.bar()? if (foo != null && foo.bar()) { etc... }

    Read the article

  • R how to find NA values after using addNA function

    - by screechOwl
    I have a data frame with a bunch of categorical variables. Some of them contain NA's and I use the addNA function to convert them to an explicit factor level. My problem comes when I try to treat them as NA's they don't seem to register. Here's my example data set and attempts to 'find' NA's: df1 <- data.frame(id = 1:200, y =rbinom(200, 1, .5), var1 = factor(rep(c('abc','def','ghi','jkl'),50))) df1$var2 <- factor(rep(c('ab c','ghi','jkl','def'),50)) df1$var3 <- factor(rep(c('abc','ghi','nop','xyz'),50)) df1[df1$var1 == 'abc','var1'] <- NA df1$var1 <- addNA(df1$var1) df1$isNaCol <- ifelse(df1$var1 == NA, 1, 0);summary(df1$isNaCol) df1$isNaCol <- ifelse(is.na(df1$var1), 1, 0);summary(df1$isNaCol) df1$isNaCol <- ifelse(df1$var1 == 'NA', 1, 0);summary(df1$isNaCol) df1$isNaCol <- ifelse(df1$var1 == '<NA>', 1, 0);summary(df1$isNaCol) Also when I type ??addNA I don't get any matches. Is this a gray-market function or something? Any suggestions would be appreciated.

    Read the article

  • How to use Application.OnTime to call a macro at a set time everyday, without having to close workbook

    - by Shayne K
    I have written a macro that uses Application.OnTime that works if I manually execute the macro. I'm trying to automate this process so I don't have to write Application.OnTime in "This Workbook" or (Private Sub Workbook_Open() Most of you do this because you can have windows scheduler open the workbook at a certain time which starts the macros on open. I CANNOT USE SCHEDULER. Because I am not able to use windows scheduler I will keep the workbook open and the timer should refresh my data then Call "my Macro" at a certain time everyday. Where do I place this code, and how do I set an auto timer?

    Read the article

  • Cannot write the output to a text file in cpp program

    - by swapedoc
    I have this input file "https://code.google.com/codejam/contest/351101/dashboard/do/A-large-practice.in?cmd=GetInputFile&problem=374101&input_id=1&filename=A-large-practice.in&redownload_last=1&agent=website&csrfmiddlewaretoken=OWMxNTVmMTUyODBiYjhhN2Q2OTM3ZGJiMTNhNDkwMDF8fDEzNzIxNzI1NTE3ODAzMjA%3D" I tried to read this file :-using freopen("filename.txt",r,stdin); and then I wanted the output written to be written to another text file which I can upload in this codejam practice question for the judge. #include<iostream> #include<cstdio> using namespace std; int main() { int t,k=0,a[2000]; freopen("ab.txt","r",stdin); scanf("%d",&t); while(t--) { freopen("cb.txt","w",stdout); int c; scanf("%d",&c); int n; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); printf("Case #%d: ",++k); for(int i=0;i<n-1;i++) {for(int j=i+1;j<n;j++) if((a[i]+a[j])==c) {printf("%d %d\n",i+1,j+1); i=n;} } } return 0; } This is my code. Now the problem is the output file cb.txt contains only the last line of the input. I want the the whole of the output to be written to cb.txt,so what should I do.

    Read the article

  • How to insert a div into the content of another div?

    - by Selva Ganesh
    How do i insert a div inside the content of another content-editable div? The parent div is a content-editable one and its contains string content. I want to insert another content-editable div when i type '@' at the cursor position. for example, <div id="target" class="text-area" contenteditable='true'>This text can be anything... how to insert a div when i type start typing @... </div> I want to insert another div when i type '@'? How can i achieve this? Here is what i tried out JSBIN Please help me. Thanks in advance

    Read the article

  • Wrong cells values of UITableView per section

    - by androniennn
    I have a UITableView that has a different rows count in every section. I made that code to try achieving a correct result: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier= @"channel"; ChannelsCell *cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if(!cell) { cell =[[ChannelsCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } NSInteger rowsCountSection = [[arrayofChannelsCount objectAtIndex:indexPath.section] intValue];// this variable has the number of rows of every section NSUInteger pos = indexPath.section*count+ indexPath.row; cell.channelName.text=[arrayofChannelName objectAtIndex:pos]; return cell; } I'm pretty sure that's a mathematic problem. Thank you for helping.

    Read the article

  • jsf output text with fn substring

    - by user2361862
    I want to format a date in jsf which is xmlgregoriancalendar type. I've come across post which say I need custom converter. Does anybody found solution which does not require custom date converter. I was trying following but I gives me error saying... Element type "h:outputText" must be followed by either attribute specifications, "" or "/". This is what I tried on jsf <h:outputText value="#{fn:substringBefore(aClip.lastTransmittedDate,"T")}"> <f:convertDateTime pattern="dd.MM.yyyy" /> </h:outputText> Can anybody point out the explain the error I'm getting?

    Read the article

  • Understanding NoSQL Data Modeling - blog application

    - by Rushabh RajeshKumar Padalia
    I am creating an blogging application in Node.js + MongoDB Database. I have used relational Database like MySQL before but this is my first experience with NoSQL database. So I would like to conform my MongoDB data models before I move further. I have decided my blogDB to have 3 collections post_collection - stores information about that article comment_collection - store information about comments on articles user_info_collection - contains user inforamtion PostDB { _"id" : ObjectID(...), "author": "author_name", "Date": new Date(....), "tag" : ["politics" , "war"], "post_title": "My first Article", "post_content": "Big big article" "likes": 23 "access": "public" } CommentDB { "_id" : Objectid(...), "POST": "My First Article", "comment_by": "User_name", "comment": "MY comments" } UserInfoDB { "_id": ObjectID(...), "user": "User_name", "password": "My_password" } I would appreciate your comments.

    Read the article

  • How to define Module and use it in dojo with AMD?

    - by Devdatta Tengshe
    I am maintaining and extending an old project which was pre-AMD. I wish to add an Chart to the application. for this, I have created a js file as follows: define(["dojox/charting/Chart",...."dijit/Dialog","dojo/dom-construct"], function (Chart) { function showDailyChart(data){ //code to show the chart in a dialog } return customModules.singleChart; }); I have saved this file as /customModules/singleChart.js In My main HTML Page, I have added it to the packages as follows: var dojoConfig = { parseOnLoad: true, packages: [....,{"name":"customModules", "location":location.pathname.replace(/\/[^/]+$/, "")+"/modules" } ]}; The function from which I want to call it, is pre-AMD. So I am calling it as follows: dojo.require("customModules.singleChart"); . . . customModules.singleChart.showDailyChart(data); I can see that /customModules/singleChart.js is loaded in the Firebug console as well as Net Tab. However there is no customModules.singleChart object. Strangely enough there is no error either. I have tested this in Firebug, as well as Google Chrome's developer tools. What is the correct way to call an AMD Module using dojo.require? Or is there a better way to do what I need?

    Read the article

  • not able to select hidden link - selenium

    - by Maddy
    I have to select web link when i mouse hover to particular frame in the webpage, the button(link to next page) will be visible. WebElement mainElement = driver.findElement(By.xpath(<frame xpath >)); Actions builder = new Actions(driver); builder.moveToElement(mainElement); WebElement button1 = driver.findElement(By.xpath("//*[@id='currentSkills']/div[1]/div/a")); builder.moveToElement(button1).click().perform(); I am still unable to select the particular link when i execute, the following error am getting org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 131 milliseconds But when i hover mouse pointer to the particular frame during AUT(just to move to particular frame without clicking anything), then test is executing sucessfully. I know this can be handled by JS. But i want to find out is there any solution within selenium webdriver Your help is much appreciated... Thanks Madan

    Read the article

  • Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401'

    - by Peak Reconstruction Wavelength
    I am using a php-script that has been working for years, but suddenly it aborts with Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401' NoLinkedYouTubeAccount Error 401 It starts like this <?php function anmelden_yt($name,$passwort) { $yt_source = 'known'; $yt_api_key = 'key'; $yt = null; $authenticationURL= 'https://www.google.com/accounts/ClientLogin'; $httpClient = Zend_Gdata_ClientLogin::getHttpClient( $username = $name, $password = $passwort, $service = 'youtube', $client = null, $source = $yt_source, // a short string identifying your application $loginToken = null, $loginCaptcha = null, $authenticationURL); abschnitt("Login"); return new Zend_Gdata_YouTube($httpClient, $yt_source, NULL, $yt_api_key); } require_once("Zend/Gdata/ClientLogin.php"); require_once("Zend/Gdata/HttpClient.php"); require_once("Zend/Gdata/YouTube.php"); require_once("Zend/Gdata/App/MediaFileSource.php"); require_once("Zend/Gdata/App/HttpException.php"); require_once('Zend/Uri/Http.php'); require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata_YouTube'); Zend_Loader::loadClass('Zend_Gdata_AuthSub'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); $yt = anmelden_yt($name,$pass); $videoFeed = $yt->getUserUploads('Google'); sleep(0.5); @ob_flush(); @flush(); ?> What could be the reason for this? ..................................................................................................

    Read the article

  • git pull gives error: 401 Authorization Required while accessing https://git.foo.com/bar.git

    - by spuder
    My macbook pro is able to clone/push/pull from the company git server. My cent 6.3 vm gets a 401 error git clone https://git.acme.com/git/torque-setup "error: The requested URL returned error: 401 Authorization Required while accessing https://git.acme.com/git/torque-setup/info/refs As a work around, I've tried creating a folder, with an empty repository, then setting the remote to the company server. I get the same error when trying a git pull The remotes are identical between the machines MacBook Pro (working) git --version git version 1.7.10.2 (Apple Git-33) git remote -v origin https://git.acme.com/git/torque-setup (fetch) origin https://git.acme.com/git/torque-setup (push) Cent 6.3 (not working) yum install -y git git --version git version 1.7.1 git remote -v origin https://git.acme.com/git/torque-setup (fetch) origin https://git.acme.com/git/torque-setup (push) The git server only allows https. Not git or ssh connections. Why is the macbook pro able to do a git pull, while the cent os machine can't? Solution Update 2013-5-15 As jku mentioned, the culprit is the old version of git installed on the cent box. Unfortunately, 1.7.1 is what you get when you run yum install git The work around is to manually install a newer version of git, or simply add the username to the repo git clone https://[email protected]/git/torque-setup

    Read the article

  • Is it possible to tell if there are any ongoing 'GET' requests with javascript?

    - by Lavabeams
    Is it possible to tell if there are any ongoing 'GET' requests with javascript? I have a feeling that it is not. Basically I don't want to make a seperate request while the other "more important" requests are going as this one is fairly heavy. So I was curious if it is possible to tell if there are currently 'get' requests going and if so I can tell my function to hold off for this update and do it again in 10-15secs. Any information etc would be appreciated.

    Read the article

  • Pluggable Rules for Entity Framework Code First

    - by Ricardo Peres
    Suppose you want a system that lets you plug custom validation rules on your Entity Framework context. The rules would control whether an entity can be saved, updated or deleted, and would be implemented in plain .NET. Yes, I know I already talked about plugable validation in Entity Framework Code First, but this is a different approach. An example API is in order, first, a ruleset, which will hold the collection of rules: 1: public interface IRuleset : IDisposable 2: { 3: void AddRule<T>(IRule<T> rule); 4: IEnumerable<IRule<T>> GetRules<T>(); 5: } Next, a rule: 1: public interface IRule<T> 2: { 3: Boolean CanSave(T entity, DbContext ctx); 4: Boolean CanUpdate(T entity, DbContext ctx); 5: Boolean CanDelete(T entity, DbContext ctx); 6: String Name 7: { 8: get; 9: } 10: } Let’s analyze what we have, starting with the ruleset: Only has methods for adding a rule, specific to an entity type, and to list all rules of this entity type; By implementing IDisposable, we allow it to be cancelled, by disposing of it when we no longer want its rules to be applied. A rule, on the other hand: Has discrete methods for checking if a given entity can be saved, updated or deleted, which receive as parameters the entity itself and a pointer to the DbContext to which the ruleset was applied; Has a name property for helping us identifying what failed. A ruleset really doesn’t need a public implementation, all we need is its interface. The private (internal) implementation might look like this: 1: sealed class Ruleset : IRuleset 2: { 3: private readonly IDictionary<Type, HashSet<Object>> rules = new Dictionary<Type, HashSet<Object>>(); 4: private ObjectContext octx = null; 5:  6: internal Ruleset(ObjectContext octx) 7: { 8: this.octx = octx; 9: } 10:  11: public void AddRule<T>(IRule<T> rule) 12: { 13: if (this.rules.ContainsKey(typeof(T)) == false) 14: { 15: this.rules[typeof(T)] = new HashSet<Object>(); 16: } 17:  18: this.rules[typeof(T)].Add(rule); 19: } 20:  21: public IEnumerable<IRule<T>> GetRules<T>() 22: { 23: if (this.rules.ContainsKey(typeof(T)) == true) 24: { 25: foreach (IRule<T> rule in this.rules[typeof(T)]) 26: { 27: yield return (rule); 28: } 29: } 30: } 31:  32: public void Dispose() 33: { 34: this.octx.SavingChanges -= RulesExtensions.OnSaving; 35: RulesExtensions.rulesets.Remove(this.octx); 36: this.octx = null; 37:  38: this.rules.Clear(); 39: } 40: } Basically, this implementation: Stores the ObjectContext of the DbContext to which it was created for, this is so that later we can remove the association; Has a collection - a set, actually, which does not allow duplication - of rules indexed by the real Type of an entity (because of proxying, an entity may be of a type that inherits from the class that we declared); Has generic methods for adding and enumerating rules of a given type; Has a Dispose method for cancelling the enforcement of the rules. A (really dumb) rule applied to Product might look like this: 1: class ProductRule : IRule<Product> 2: { 3: #region IRule<Product> Members 4:  5: public String Name 6: { 7: get 8: { 9: return ("Rule 1"); 10: } 11: } 12:  13: public Boolean CanSave(Product entity, DbContext ctx) 14: { 15: return (entity.Price > 10000); 16: } 17:  18: public Boolean CanUpdate(Product entity, DbContext ctx) 19: { 20: return (true); 21: } 22:  23: public Boolean CanDelete(Product entity, DbContext ctx) 24: { 25: return (true); 26: } 27:  28: #endregion 29: } The DbContext is there because we may need to check something else in the database before deciding whether to allow an operation or not. And here’s how to apply this mechanism to any DbContext, without requiring the usage of a subclass, by means of an extension method: 1: public static class RulesExtensions 2: { 3: private static readonly MethodInfo getRulesMethod = typeof(IRuleset).GetMethod("GetRules"); 4: internal static readonly IDictionary<ObjectContext, Tuple<IRuleset, DbContext>> rulesets = new Dictionary<ObjectContext, Tuple<IRuleset, DbContext>>(); 5:  6: private static Type GetRealType(Object entity) 7: { 8: return (entity.GetType().Assembly.IsDynamic == true ? entity.GetType().BaseType : entity.GetType()); 9: } 10:  11: internal static void OnSaving(Object sender, EventArgs e) 12: { 13: ObjectContext octx = sender as ObjectContext; 14: IRuleset ruleset = rulesets[octx].Item1; 15: DbContext ctx = rulesets[octx].Item2; 16:  17: foreach (ObjectStateEntry entry in octx.ObjectStateManager.GetObjectStateEntries(EntityState.Added)) 18: { 19: Object entity = entry.Entity; 20: Type realType = GetRealType(entity); 21:  22: foreach (dynamic rule in (getRulesMethod.MakeGenericMethod(realType).Invoke(ruleset, null) as IEnumerable)) 23: { 24: if (rule.CanSave(entity, ctx) == false) 25: { 26: throw (new Exception(String.Format("Cannot save entity {0} due to rule {1}", entity, rule.Name))); 27: } 28: } 29: } 30:  31: foreach (ObjectStateEntry entry in octx.ObjectStateManager.GetObjectStateEntries(EntityState.Deleted)) 32: { 33: Object entity = entry.Entity; 34: Type realType = GetRealType(entity); 35:  36: foreach (dynamic rule in (getRulesMethod.MakeGenericMethod(realType).Invoke(ruleset, null) as IEnumerable)) 37: { 38: if (rule.CanDelete(entity, ctx) == false) 39: { 40: throw (new Exception(String.Format("Cannot delete entity {0} due to rule {1}", entity, rule.Name))); 41: } 42: } 43: } 44:  45: foreach (ObjectStateEntry entry in octx.ObjectStateManager.GetObjectStateEntries(EntityState.Modified)) 46: { 47: Object entity = entry.Entity; 48: Type realType = GetRealType(entity); 49:  50: foreach (dynamic rule in (getRulesMethod.MakeGenericMethod(realType).Invoke(ruleset, null) as IEnumerable)) 51: { 52: if (rule.CanUpdate(entity, ctx) == false) 53: { 54: throw (new Exception(String.Format("Cannot update entity {0} due to rule {1}", entity, rule.Name))); 55: } 56: } 57: } 58: } 59:  60: public static IRuleset CreateRuleset(this DbContext context) 61: { 62: Tuple<IRuleset, DbContext> ruleset = null; 63: ObjectContext octx = (context as IObjectContextAdapter).ObjectContext; 64:  65: if (rulesets.TryGetValue(octx, out ruleset) == false) 66: { 67: ruleset = rulesets[octx] = new Tuple<IRuleset, DbContext>(new Ruleset(octx), context); 68: 69: octx.SavingChanges += OnSaving; 70: } 71:  72: return (ruleset.Item1); 73: } 74: } It relies on the SavingChanges event of the ObjectContext to intercept the saving operations before they are actually issued. Yes, it uses a bit of dynamic magic! Very handy, by the way! So, let’s put it all together: 1: using (MyContext ctx = new MyContext()) 2: { 3: IRuleset rules = ctx.CreateRuleset(); 4: rules.AddRule(new ProductRule()); 5:  6: ctx.Products.Add(new Product() { Name = "xyz", Price = 50000 }); 7:  8: ctx.SaveChanges(); //an exception is fired here 9:  10: //when we no longer need to apply the rules 11: rules.Dispose(); 12: } Feel free to use it and extend it any way you like, and do give me your feedback! As a final note, this can be easily changed to support plain old Entity Framework (not Code First, that is), if that is what you are using.

    Read the article

  • Static vs Singleton in C# (Difference between Singleton and Static)

    - by Jalpesh P. Vadgama
    Recently I have came across a question what is the difference between Static and Singleton classes. So I thought it will be a good idea to share blog post about it.Difference between Static and Singleton classes:A singleton classes allowed to create a only single instance or particular class. That instance can be treated as normal object. You can pass that object to a method as parameter or you can call the class method with that Singleton object. While static class can have only static methods and you can not pass static class as parameter.We can implement the interfaces with the Singleton class while we can not implement the interfaces with static classes.We can clone the object of Singleton classes we can not clone the object of static classes.Singleton objects stored on heap while static class stored in stack.more at my personal blog: dotnetjalps.com

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >