w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Meteor Streams : client doesn't receive streams
Ok, Ok, after doing some debugging, i now understand what is wrong in my code : it's easy in fact. The problem comes from the fact that i forgot to bind the Stream.on event to Deps.autorun. The result is that this part of code was not managed by reactivity so it was never re-run automatically when the Session changed. The solution is so easy with Meteor : just wrap this part of code inside the Deps.autorun Meteor.startup(function () { Deps.autorun(function funcReloadStreamListeningOnNewRoom () { PokerStream.on(Session.get('currentRoom') + ':currentRoom:vote', function (vote) { var voteFound = 0; // update is now allowed if (Session.get('pokerVoteStatus') === 'voting') { voteFound = Vote.find({subscriptionId: this.subscriptionId}); if (!voteFound.co

Categories : Meteor

Providing an OAuth Javascript API
This is done by passing value from child widow to parent window. Every child window which is opened by parent window has reference to his parent which is can be access by: var parent = window.opener.document.document; // by this you have reference to parent DOM var someParentElement = parent.getElementById("idOfParentDomElement"); // ex: accessing particular element on parent So by this you can pass value to parent by accessing it parent: var childDiv = document.getElemntById("SomeChildDiv").innerHTML; someParentElement.innerHTML = childDiv // passing html text to parent div Read more about this here Receiving access token is part of OAuth flow . Through oauth token is received and passes to parent window by window.opener and then window.close called by parent window to close window

Categories : Javascript

providing resources for different devices
The correct layout-identifier to use for the s2 is: layout-sw320 It's HDPI so the scaling factor is 1.5. The resolution is 480x800, so the calculation is (480 / 1.5), which equals 320.

Categories : Android

Providing 'this' via base constructor
This is a kind of Enums that I wouldn't use, but if you would like to do so then this would be the solution: public sealed class MyComplexObjEnum : Enumeration<ComplexObj> { public MyComplexObjEnum(ComplexObj enumVal) : base( enumVal) { } public static readonly MyComplexObjEnum EnumVal1 = new MyComplexObjEnum(new ComplexObj("val1", 455, null)); public static readonly MyComplexObjEnum EnumVal2 = new MyComplexObjEnum(new ComplexObj("val2", 456, null)); public static readonly MyComplexObjEnum EnumVal3 = new MyComplexObjEnum(new ComplexObj("val3", 457, null)); } public class ComplexObj { private readonly string _a; private readonly int _b; private readonly string _c; public ComplexObj(string a, int b, string c) { _a = a; _b = b;

Categories : C#

Programmatical log in by providing credentials
You can impersonate a logged on user to access the data folder, using the LogonUser, ImpersonateLoggedOnUser and RevertToSelf functions. Try this sample {$APPTYPE CONSOLE} uses Windows, SysUtils; function ConnectAs(const lpszUsername, lpszPassword: string): Boolean; var hToken : THandle; begin Result := LogonUser(PChar(lpszUsername), nil, PChar(lpszPassword), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hToken); if Result then Result := ImpersonateLoggedOnUser(hToken) else RaiseLastOSError; end; begin try ConnectAs('Admin','Password'); //do something here //terminates the impersonation RevertToSelf; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; readln; end.

Categories : Delphi

gps not providing correct co-ordinates
I highly suspect the role of GPS accuracy in this case, Android apps try to access precise location from location sources such as GPS, cell towers, and Wi-Fi when android.permission.ACCESS_FINE_LOCATION permission is given in manifest, the primary and (super) location provider are GPS satellites which have accuracy of 0m - 20m. when GPS satellites are out of range or phone is indoor, android will seek other means of location provider, one of them is cell ID, which uses cell phone tower triangulation to find the approximate location of the device with an accuracy of around 200m - 2000m. When there are more than 4 cell tower near your area the the cell triangulation shifts tower to tower causing the sensation of moving. Using old android permissions like android.permission.ACCESS_GPS an

Categories : Android

Providing white space in a Swing GUI
There are a number of ways in a Swing GUI to provide a separation between components, and white space around components: JToolBar has the methods addSeparator() & addSeparator(Dimension). JMenu uses a spacing component better suited to menus, available through addSeparator(). But more generally, look to: The spacing as can be defined in the layout constructors. Borders. Here is an example of using the layout separator hGap & vGap values & borders (specifically an EmptyBorder) to provide 'white' (actually shown as 'red' to make it very obvious) space. Adjust the spinners to see the result. import java.awt.*; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.*; public class WhiteSpace { private JPanel gui = null; pri

Categories : Java

Is not providing an explicit destructor bad practice?
It depends on what your constructor is doing. C++ does not provide garbage collection so if your constructor is creating new objects it would be good to delete them in destructor. Memory used for class members is freed anyway so if you are not using "new" in constructor and not allocating memory in any other way, destructor is not mandatory.

Categories : C++

HTTP request is not providing a result
You should use a standarised api for transfer of data from your webservice, this will save you a lot of time and frustration parsing your own response as there are libraries like GSON ... which can convert JSON objects to JAVA objects for example. Using asynctask class is appropriate for doing what you are attempting to do. Solution to your problem using the asynctask class is included below with example. private void getString() { try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEn

Categories : Android

Angular: Providing methods to ng-model
Anything that you pass into ng-model is evaluated as an angular expression against the scope. That means that record.inner[0].text is evaluated as $scope.record.inner[0].text and then the result of that expression is used. When you use getText(record), angular evaluates $scope.getText(record) and ng-model gets access to the result of this evaluation. Keep in mind that ng-model does not evaluate the result of this function call. Your problem is that you are returning the result as an angular expression string, but never evaluating it, so ng-model is given a string that it cannot use. There are lots of ways to redesign your code to deal with this, but the simple (and probably not best) way would be to use something like ng-init to get the result of the function call and then insert that res

Categories : Javascript

Providing RESTful JSON API in Java
I would simply use Play to save me a lot of work that has already been done. The link is for Play 1.2 and while the current version is 2.1, it should be fit for that as well.

Categories : Java

Options for providing a dynamic filter
If you're using a DropDownList (named here yourDdl) and you want to fill it with data coming from a DB I suggest you to do something like this: yourDdl.DataSource = getListSelection("AtecoYear = 2004", true); yourDdl.DataTextField = "ComboText"; yourDdl.DataValueField = "ComboID"; yourDdl.DataBind(); The method getListSelection (the best way would be to put it in a proper class) connects to your DB, extracts the data and put it into a DataTable: public DataTable getListSelection(string filter_status) { DataTable dt; string cmdText = "select ExampleID as ComboID, ExampleName as ComboText from ExampleTable"; SqlConnection objIdbConnection = new SqlConnection(yourConnectionString); SqlCommand cmd = new SqlCommand(); cmd.CommandText = cmdText; cmd.Connection = objI

Categories : C#

Providing a third party with testable web services
App2 [...] needs to have a testable version of those services to use while implementing their side, to handle different use cases themselves It's not really clear what you want to test here. If you mean testing App2 plays well with App1, I tend to consider it's not a third party component's job to make itself "testable" - it's the consumer component that should test communication with the 3d party and verify if it can handle its results. In App2, create a proxy to App1's services. In your unit tests, you can stub the proxy's methods to return canned test data. These data can be more or less close to production data depending on the scenarios you want to cover. Then create integration tests between your proxy and the real services to verify everything runs smoothly.

Categories : Web Services

Providing no-js fallbacks for clientside MV* frameworks
We're in the middle of a pretty big Ember project right now, so here are my thoughts on your questions. We've found Ember to be really productive for creating rich UIs for our single page app, but I don't know that it's going to be that much more helpful if you're creating an app designed for traditional multi-page (viewing pages, submitting forms, etc) layout. I think this is the clincher - Ember is completely JS-based, so if you need to support browsers without JS, you'd basically have to write a parallel application. If this is a hard requirement for your app, I think Ember (or any MV* JS framework) would be out of the question We've had very few performance issues on mobile - our site is fully responsive and renders on everything from Blackberries to the latest Chrome on desktop w

Categories : Javascript

providing a profile for anonymous user
A simpler solution would be not tying the survey answers to the user ID. Give the survey response a separate, completely independent ID. When a real user is logged in, create a one-sided association from user to survey response. When the anonymous user registers, add this association as well. (That is, the "owner" of a survey will be optional.) Afterwards, periodically delete old survey responses that have no owner, and/or ignore outdated ones in queries. This shifts most of the complexity from the admin app to user registration only. (I.e. when an anonymous user answers a survey, store the response ID in the session. When a new user registers, check the session for response IDs, and then assign it to the user ID.)

Categories : Django

Providing feedback with mail in android
You could consider adding a separate API altogether and use their online client to view and manage the messages you receive: Apptentive LetThemVote Recon Instruments

Categories : Android

Other methods of providing static content
80Mb? Are you writing a novel? If you reuse certain lines multiple times then that is really the way to go. If not, break the sections down so you can reuse certain segments instead of having a bunch of repeats in your .xml file. You could have a class or enum that is used to hold all the string literals so you can enter the text via code, but that would still take up the same amount of space. Probably even more.

Categories : Android

Providing Access to Views in Hive
First it's important to understand what Hive really is. Hive is just a compiler (more or less) of SQL statements into MapReduce tasks, it does control data storage layer. So there is no such concept as access management in Hive. Also it's necessary to understand that "table" in Hive is just an HDFS folder with files. It means that you can manage access on per-table basis with standard set of HDFS access management tools. The best you can do is to limit access on HDFS level to database and export parts of your data into "public tables" for less privileged users to read.

Categories : Security

MessageBox not providing expected DialogResult
You're just creating a new DialogResult and ignoring the click from the dialog. Instead you need to get the DialogResult from the MessageBox String msg = "Number of records affected:" + numberOfRecordsroll + " Please check the data is correct before proceeding:"; DialogResult dr = MessageBox.Show(msg, "Please validate your changes", MessageBoxButtons.OKCancel);

Categories : C#

Why providing pagination information in API response?
It's RESTful! That is specifically part of HATEOAS, or Hypermedia as the Engine of Application State. Except for simple fixed entry points to the application, a client does not assume that any particular action is available for any particular resources beyond those described in representations previously received from the server. and: [HATEOAS] is a constraint of the REST application architecture that distinguishes it from most other network application architectures. The principle is that a client interacts with a network application entirely through hypermedia provided dynamically by application servers. A REST client needs no prior knowledge about how to interact with any particular application or server beyond a generic understanding of hypermedia. ... A REST client enter

Categories : Api

Providing CRM 2011 functionalities via Web Services
There's no real way to "extend" the Microsoft Web Services itself. It's a fixed framework that provides a fixed set of web services and methods. For CRM Online The only way you could provide something like this is by extending the platform and what's available to you on that front. The main areas that are "code" based and I would believe might be of significance to you are: Plugins Custom Workflow Activities HTML/Javascript/Silverlight Web Resources Some of these need to be backed of Entities (e.g. Plugins), but others can stand alone and just do some generic work (e.g. HTML and Silverlight pages) So basically, if they require a standard set of "functions" added to the framework you'd have to get inventive using the above methods to provide this for them. If it's on-premise then you

Categories : Web Services

Providing access to unstructured files in Hadoop
Hive kicks off a MapReduce job (or several) every time you execute a query. A latency introduced by setting up and tearing down a MapReduce job(s) exceeds any acceptable standards for a responsivness expected from a web interface. I recommend you keep the metadata for the files in a relational database. You would have to have a relational database, like PostgreSQL, to store Hive metadata. I sure hope you are not using default Derby for that!

Categories : Hadoop

TextCtrl providing an out of bound exception in wxPython
This may or may not be the reason for your crash, but if definitely will cause crashes, and they're likely to be exactly the kind of crash you're seeing (sometimes it works, sometimes it fails, sometimes it works for a while and then suddenly fails even though nothing visible has changed…). You cannot call methods that operate on UI objects from other threads. Every time you call self.textArea.AppendText from another thread, there is a chance of crashing—or, more fun, corrupting memory or other resources leading to a crash later. There are a few different ways around this: Use PostEvent to queue an event for the main UI thread (with the actual UI-changing code in the event handler). Use CallAfter or CallLater to schedule a function to be called on the main UI thread (with the actua

Categories : Python

Android Providing Styles Resources for Gingebread
<style name="LightTheme" parent="android:Theme.Light"></style> <style name="ColorsTheme" parent="android:Theme.Holo"></style> The main problem is that Gingerbread just doesn't have style resources from themes that you extending. Thats why it load default resources.

Categories : Java

Providing a default string parameter in JavaScript
First, note that they aren't all the same. #2 and #3 have precisely the same result: unless input is truthy, set it to an empty string. #1 means says "unless input is null, set it to an empty string. So if false was provided, input would be false in #1 but '' in #2 and #3. If nothing was provided to #1, (i.e. f(), input would be undefined, because that is the value that is passed when a parameter is missing, not null. One of these would fix this: if(input === undefined) if(input == null) Otherwise, yes, they are functionally equivalent. For me, the best way to write it would be input = input || ""; That is my preferred style. It may be yours; it may not. But, above all, be consistent.

Categories : Javascript

Is it possible to find-or-create without locking or providing a future?
You could use an array or ring buffer of Things, and atomic operations. Built in atomic intrinsic or processor specific CMPXCHG assembly opcodes. You would be sacrificing memory and essentially creating your own mutex and spin waits. In the simplest implementation your ThingId would be index into the array. Your "find or create" would be a compare+exchange atomic operation where if the spot in the array is empty you'd exchange in an already created new object however if the spot was not empty you would delete the precreated new object or save it for the next call but that would require more atomic operations for concurrency of your object store.

Categories : C++

Securely providing the database password in a Rails app
The way that heroku does it, and a vast majority of other rails shops are with ENV variables Export two variables to your environment, export POSTGRES_USERNAME='username' export POSTGRES_PASSWORD='password' then in your database.yml file you can do username: <%= ENV['POSTGRES_USERNAME'] %> password: <%= ENV['POSTGRES_PASSWORD'] %>

Categories : Ruby On Rails

Google Drive - Providing resource paths
Open up JavaScript console in any web browser of your choice. Look for errors - it's obvious you haven't corrected the paths (i.e. URIs) of resources. This is where you find errors in Chrome console: This is the error - Failed to load resource: the server responded with a status of 404 (Not Found) https://googledrive.com/host/0B7M-r5gOz6CVYmQwaGNkaC1xM1k/js/twitter-bootstrap-2.2.2/bootstrap.min.js

Categories : Javascript

Network provider not providing location updates
For network based location, they are a lot less inaccurate than GPS, meaning you need to move the device a much larger distance to allow the signal to hook on to another network tower before onLocationChanged() is called. Also not all network towers provide location.

Categories : Android

providing initial data to django model
Yes, you need to run: python manage.py syncdb which will create all tables and then run your sql script.. Update: Since you use south, it seems that south which takes control of syncdb and provide migrate instead does imitate syncdb and load sql files after creating tables. I found this snippet on DjangoSnippets which let you do the same thing with south. Take into consideration the notes on the right side of the page where you might need to change sql files names. This code posted on 2011 and I am not sure if this is still the case with south. http://djangosnippets.org/snippets/2311/

Categories : Django

tail not providing output in bash script
Try this: phonenumber=$(tail -f /var/log/asterisk/messages | awk 'match($12, /[^0-9]91([0-9]{10})@default/, a) {print a[1]; exit}') Your version doesn't work because tail -f and awk are in an infinite loop. Adding exit to the awk script terminates the loop when the first phone number is found. awk exits immediately and its output is put into the variable, and tail -f gets a SIGPIPE signal when it tries to write the next line to the pipe, which causes it to exit.

Categories : Linux

Spring Security in Grails providing authorization
You can use your Role class not only for generic roles (Admin,User, etc.), but for application specific ones as well. Simply allow the user to create a Role for a resource and then allow their invitees to be granted that role. Spring Security comes with a handy ifAnyGranted() method, which accepts a comma-delimited String of role names. At a resource entry-point simply ensure that a particular role is granted: class Conversation{ Role role } class ConversationController{ def enterConversation(){ // obtain conversation instance if(!SpringSecurityUtils.ifAnyGranted(conversationInstance.role.authority){response.sendError(401)} } }

Categories : Grails

Android app providing core services to other apps
Is this feasible ? It is technically possible. However: When the user uninstalls this magic app, all the other apps break Securing the IPC to the magic app is doable (use signature-level permissions) but important Usually, you don't create an app to address "horizontal concerns" -- you create a library. This is true for most operating systems and development frameworks that I have ever encountered, anyway. In Android's case, that would either be a JAR (if it is pure code) or an Android library project (if it needs resources).

Categories : Java

Providing partial input to a bash command
The main problem here is most likely that foo is not designed to take a filename as an argument. (Keep in mind that <(...) doesn't pass ...'s output on standard-input; rather, it gets expanded to a special filename that can be read from to obtain ...'s output.) To fix this, you can add another <: foo < <(echo -e "foo bar baz" ; cat /dev/stdin) or use a pipeline: { echo -e "foo bar baz" ; cat /dev/stdin ; } | foo (Note that I changed the & to ;, by the way. The former would work, but is a bit strange, given that you intend for echo to handle the first several inputs.)

Categories : Bash

Providing synchronous behaviour in CQRS when needed?
My take on this is that the actual endpoint should not be performing the work but be handing it off to some 'Task' (Application Service / Operation Script) object. That object is performing the work immediately. So for cases where you absolutely have to have 100% consistency rather call that same task object rather than sending a command for later processing. You may still want that command for other scenarios.

Categories : Asp Net Mvc

One shot Streams
Streams contain internal state that keeps track of the state of the stream--in the case of a file stream, you have a file descriptor object, a read buffer, and the current position the file has been read to. Thus, it doesn't make sense to "rewind" a Node.js stream because Node.js is an asynchronous environment--this is an important point to keep in mind, as it means that two HTTP requests can be in the middle of processing at the same time. If one HTTP request causes the stream to begin streaming from disk, and midway through the streaming process another HTTP request came in, there would be no way to use the same stream in the second HTTP request (the internal record-keeping would incorrectly send the second HTTP response the wrong data). Similarly, rewinding the stream when the second H

Categories : Node Js

Doing serialization using streams C++
Today you almost never need to implement your own low-level serialization. Try JSON, BSON, Protocol Buffers, MessagePack or XML. There are quite a lot of libraries, that will do it better than "roll-your-own"... You intended to write a binary serialization, but you insert EOL (' ') characters. That's not a good choice of dividing a binary stream into tokens.

Categories : C++

Providing synchronous and asynchronous versions of an API in library code
There are 3 "major" options for async patterns which are endorsed by MS. I'd recommend that you pick one of the patterns and adhere to it... It looks like you're already headed towards the "Task-based Asynchronous Pattern" so you'd have very few mods in order to conform to the pattern. This allows you to create your methods in a way that will be uniform and intuitive to other consumers... They'll know the pattern from the .NET libraries that MS has built. See this for details: Overview: http://msdn.microsoft.com/en-us/library/jj152938.aspx Task Async Pattern: http://msdn.microsoft.com/en-us/library/hh873175.aspx An example of your methods using the Task Asynchronous Pattern with support for cancellation tokens: public Task<string> GetSomeDataAsync(CancellationToken cancellationTo

Categories : C#

OS X: What might cause ssh-agent to stop providing passphrase for encrypted SSH private key?
I had the same thing happen and was likewise concerned about being hacked. I still don't know exactly what happened, which is disconcerting. Anyway, here's what I do whenever I'm suddenly asked for my passphrase: $ eval `ssh-agent -s` $ ssh-add It will ask me one more time for my passphrase then that's it.

Categories : Osx

Receiving null value error when providing a value to SQL Server table
You should add the DatabaseGeneratedAttribute to RequestCategoryID since you don't want it to auto increment: [Key] [Column("Request_Cat_ID")] [DatabaseGenerated(DatabaseGeneratedOption.None)] [public int RequestCategoryID { get; set; } Entity Framework auto increment int primary keys by convention.

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.