w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
ASP.NET Authentication advice needed
I would flee the Membership provider from MS like the pest. It was already badly implemented when it came out with .NET 2.0, and the recent refresh is no better. Roles, Users, ..that's not bound to the Membership provider, you can use those on your own. Set up Authentification, create a httmodule that handles said Authentification (a simple userId for the Context.User.Identity suffices) All you need is a User that derives from IIdentity and in your httmodule string[] roles = new[] {"Admin", "CoolDude"}; HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(user, roles); ..and now in your mvc controller simply add the necessary authentication attributes, game played ! Make custom roles, custom mvc attributes, or query if a user is in a specific role directly if (

Categories : Asp Net Mvc

Advice needed! Cluster programs for Java?
There are a number of grid computing / cluster middleware out there. You might want to take a look at JPPF (master/worker), GridGain(map/reduce) or HTCondor

Categories : Java

mySql advice needed for query in cakephp
return all listings who DON'T have bookings booked during a certain time period The first step in generating an appropriate find, is to understand the sort of query that is required - i.e. start at the database. The query in the question is looking for all listings (matching conditions) with a booking that is outside the range of dates. I.e. a booking for belfast at any time except BETWEEN '18-07-2013' AND '10-07-2013'. That is not the same logic as the sentence above. There are multiple ways to achieve that, here are two in order of ease of implementation: Use a left join SELECT * FROM `nights2stay`.`listings` AS `Listing` LEFT JOIN # <- `nights2stay`.`bookings` AS `Booking` ON ( `Booking`.`list

Categories : PHP

Javascript RegEx and escaping advice needed
~ should probably be used to escape only a single character (which I think would be expected). Users of the template could write ~?~?~? to escape multiple characters. As for the replacement, [^~] still selects a character. translation.replace(/([^~])?+/g", "$1replacement") The $1 will insert the selected character back again

Categories : Javascript

Advice on how to catch "attempt to insert nil object" from a device needed
assume that you fetch data using JSON from server, some times a field in the JSON data is null,so you may get NSNull after coversion. so my advice is checking "null" situation in server, if it occurs, return the faild msg ,but not deliver the bad format data to APP. when APP receive such those data, APP won't know how to handle it. it's already abnormal. it's okay that you can catch the exception and ignore the abnormal data, but my way to do is to prevent it happens from the source.

Categories : IOS

MFC GUI application rewrite - threading, messaging, Document/View, etc. Advice needed
Re messages and message mapping: The windows message queue does not interrupt your program or thread. Messages wait in the queue until you return to the message loop, then it dequeues and dispatches the next message, if any is waiting. You are correct that the message map (in the main thread) is for windows. Your worker thread must post or send messages to a main thread window. If you have a lot of such messages it is probably best to post them all to the main window (CMainFrame). Put ON_MESSAGE items in the CMainFrame map for each message. Then the handler functions in CMainFrame can call other windows as appropriate to update GUI displays.

Categories : C++

Advice needed: simple cross platform (OS-X and Windows) + SQLite development without installation
Xojo will do everything, you need. It can create standalone apps that do not require a runtime for Windows and OS X. It also has built-in support for SQLite. It is free to use for development, but you'll need a license to create builds for deployment. http://www.xojo.com

Categories : Windows

Run time error in excel vba. last used range rows selects row 65536 instead of actual last used range
Near the bottom of your code replace: Sheets("Output").Select with: Sheets("Output").Select ActiveSheet.UsedRange this should "re-set" UsedRange

Categories : Vba

Python - Pandas: Get a group of mean values of a daily range in a longer range period
import datetime as DT import numpy as np import pandas as pd np.random.seed(2013) N = 10**4 df = pd.DataFrame( np.cumsum(np.random.random(N) - 0.5), index=pd.date_range('2010-8-31', freq='10T', periods=N)) # 0 # 2010-08-31 00:00:00 0.175448 # 2010-08-31 00:10:00 0.631796 # 2010-08-31 00:20:00 0.399373 # 2010-08-31 00:30:00 0.499184 # 2010-08-31 00:40:00 0.631005 # ... # 2010-11-08 09:50:00 -3.474801 # 2010-11-08 10:00:00 -3.172819 # 2010-11-08 10:10:00 -2.988451 # 2010-11-08 10:20:00 -3.101262 # 2010-11-08 10:30:00 -3.477685 eight_to_five = df.ix[df.index.indexer_between_time(DT.time(8), DT.time(17))] # 0 # 2010-08-31 08:00:00 1.440543 # 2010-08-31 08:10:00 1.450957 # 2010-08-31 08:20:00 1.746454 # 2010-08-31 08:30:0

Categories : Python

Only trigger proximity detector when object enters the range, not when he moves within range
You'll need to keep track of when the player leaves the range and set a flag, so you'll know when they're transitioning from "out of range" to "in range". Might also want to add a timer so that you can only alert once every N seconds.

Categories : Java

Dynamic chart range using INDIRECT: That function is not valid (despite range highlighted)
The way you are trying to do it is not possible. Chart data range has to have a fixed address. There is a way around this, and that's using named ranges Put the number of rows you want in your data in a cell (e.g., E1) So, using your example, I put Number of Rows in D1 and 6 in E1 In name manager, define the names for your data and titles I used xrange and yrange, and defined them as: xrange: =OFFSET(Sheet1!$A$2,0,0,Sheet1!$E$1) yrange: =OFFSET(Sheet1!$B$2,0,0,Sheet1!$E$1) now, to your chart - you need to know the name of the workbook (once you have it set up, Excel's function of tracking changes will make sure the reference remains correct, regardless of any rename) Leave the Chart data range blank for the Legend Entries (Series), enter the title as usual, and then th

Categories : Excel

Highcharts - set maximum range for yAxis but keep axis dynamic within that range
please use setExtremes to define a range. The JSfiddle has been updated. $('#button').click(function () { var chart = $('#container').highcharts( ); if ($(this).hasClass('big')) { $(this).removeClass('big'); chart.series[0].setData([29.9, 11.5, 36.4, 19.2, 4.0, 46.0, 48.2, 15.2, 16.4, 4.1, 5.6, 44.4]); //chart.setSize(null,100,true); chart.yAxis[0].setExtremes(0,50); } else { $(this).addClass('big'); chart.series[0].setData([129.2, 144.0, 176.0, 135.6, 248.5, 316.4, 694.1, 795.6, 954.4, 1029.9, 1171.5, 1506.4]); //chart.setSize(null,1600,true); chart.yAxis[0].setExtremes(0,1600); } }); });

Categories : Jquery

Select Range of Datetime Records while Including Last Record Outside of Range
You can use UNION clause for the desired result: ( SELECT id, date_time FROM t1 WHERE date_time < '2013-05-31 01:15:00' ORDER BY date_time DESC LIMIT 1 ) UNION ALL ( SELECT id, date_time FROM t1 WHERE date_time BETWEEN '2013-05-31 01:15:00' AND '2013-05-31 02:20:00' );

Categories : Mysql

Select the lowest date from a range and exclude another range
You could use the ROW_NUMBER() function to rank the records based on RecordId and mDate, then limit the results to where the first occurance is between your specified dates. WITH data AS ( SELECT a.relatedId, a.mdate, rn = ROW_NUMBER() OVER(PARTITION BY a.RecordId ORDER BY a.mdate) FROM audit a WHERE a.status in ('A','B','C') AND type = 'type1' ) SELECT r.source, [Count] = COUNT(*) FROM data d LEFT JOIN related r ON d.relatedId = r.id WHERE d.rn = 1 AND d.mdate >= '2013-04-04 00:00:00.000' AND d.mdate < '2013-04-05 00:00:00.000' GROUP BY r.source; I am not sure this will perform any better than your current solution, but will solve the problem of relying on chronological inserts. If chronological inserts are not a prob

Categories : SQL

VBA Macro to Copy Range and Paste range to PPT as Picture
something like this Sub BetterPicturePaste() '...other stuff... Windows(1).Sheets(1).Range("myrange").Copy Windows(2).View.PasteSpecial DataType:=ppPasteEnhancedMetafile End Sub

Categories : Excel

Auto increment COUNTIF range when inserting a row within the range
Another way to ensure that your reference will "follow" the size of your range is to define the range as a table, and then use the table column reference: Select the range. Go to Home > Format as Table Instead of =COUNTIF(C2:C24,"" & "CD-A-1" & "")-(COUNTIF(B2:B24,"E1")), use =COUNTIF(YourTable[YourSecondColumn],"" & "CD-A-1" & "")-(COUNTIF(YourTable[YourFirstColumn],"E1"))

Categories : Excel

Data validation for cell range in active row if range contains any value
Merge the second code with the first, replacing Selection on the first line with Cells(NextRow, 3), etc. You'll need to split your IF statements across lines: If cbxEnUs Then Cells(NextRow, 3) = "3 - en-us" ' apply validation to this cell With Cells(NextRow, 3).Validation 'etc.. End With End if 'etc..

Categories : Vba

Excel VBA - Take First Row from one Range and give it to the end of another Range. Array?
Resize modifies the size of the range (and thus the last row, in this case). It does not work in the second line because you don't want to change the last row, but the starting one; you can just redefine rng2 to meet the expected conditions. Dim rowsToAdd As Integer: rowsToAdd = 1 Dim colName As String: colName = "A" Set rng1 = rng1.Resize(rng1.Rows.Count + rowsToAdd, rng1.Columns.Count) Set rng2 = Range(colName & CStr(rng2.Row + rowsToAdd) & ":" & colName & CStr(rng2.Row + rng2.Rows.Count - 1)) This code delivers the functionality shown in your example, that is: increases rng1 last row by rowsToAdd and, in parallel, redefines rng2 such that rowsToAdd is added to its first row. The last row of rng2 is maintained unaltered. Bear in mind that this is a more adaptable stru

Categories : Arrays

How to Search for a total Range in another Range in Excel
You can use SUMIFS and SUMPRODUCT. Let's say Sheet1 column A has the countries, Sheet1 column B has the IDs, Sheet1 column C has the values, Sheet2 column A has the IDs to match and all tables have headers in row 1. This formula is being put on Sheet1. =SUMPRODUCT(SUMIFS($C$2:$C$100,$A$2:$A$100,"CountryName",$B$2:$B$100,Sheet2!$A$2:$A$100)) SUMIFS gives the sum of range C2:C100, for which the range A2:A100 corresponds to the text "Countryname", and for which the IDs in range B2:B100 correspond to the IDs on the other sheets. The values returned are in an array, and as such, you uses SUMPRODUCT to sum them up. Change the range references accordingly.

Categories : Excel

Advice on using GitHub
Your idea works fine, it sounds like you are just inexperienced with git. There are many tutorials available online, it takes a little getting used to. The issue you may be encountering is a git pull will bark at you if you have uncommitted changes locally when trying to pull. Make sure you have a clean, committed state when you pull and it'll work. Also, if you have committed but un-pushed changes, a pull will try to merge those changes, since that's what you asked it to do. Often this won't really be a problem, but conflicts can happen, and you'll need to resolve them when it does. This is just a normal occurrence with version control and something you should get used to dealing with.

Categories : GIT

Advice on CSS Positioning
I'd try to give some width to my divs. If your entire page is 800 px then; .page{your stuff} .top-div{width:800px; float:left; margin:0 auto;} .logo{float:left; width:200px;margin:0 auto;} .toparea{float:left; width:600px; margin:0 auto; } .sidebar{float:left; width:200px; margin:0 auto;} .mainpart{float:left; width:600px; margin:0 auto;} .bottompart{float:left; width:800px; margin:0 auto;} Imagine css as lego. if you put something on your 4 block size logo, it should stay there perfectly, if not check the size or your alignments. edit: this is not a solution, just a hint to give you idea about what to do.

Categories : CSS

C++: design advice
First advice is not to use protected atributes. Is is breaking incapsulation. The second advice is to make virtual void f()=0 pure virtual without implementation. In such there will be no error in the derived class.

Categories : C++

Set a variable from an AOP advice
I don't know if it's the right way to do it, so feel free to comment. I created an interface Authed and its implementation AuthedImpl. public interface Authed { void setOwner(Owner owner); } Then I made RealEstatePropertyV1 extends from AuthedImpl. I added a pointcut for all classes extending from AuthedImpl and also changed the pointcut so I can access to the target. @Pointcut("execution(* *..AuthedImpl+.*(..))") public void extendsAuthedImpl() { } @Pointcut("execution(* *.*(.., com.google.appengine.api.users.User)) && args(.., user) && target(callee)") public void allMethodsWithUserParameter(User user, Authed callee) { } Finally the advice uses all pointcuts: @Before("annotatedWithApiMethod() && allMethodsWithUserParameter(user, callee) && exte

Categories : Misc

asp.net cache advice
But.. how you can do it for a single row of the table.. In ASP.Net you can create SQl Server dependency which uses a broker Service.. and puts the data into the cache and whenever the table is updated.. the cache will be rejected and new data is taken from db and put into the cache.. i Hope this might give you some idea!

Categories : Asp Net

NASM with C mixed
Mixing C and assembly depends on how your compiler is configured to handle parameters. If you're using gcc, it also depends on if you're building for 16/32/64 bits. Same goes for C++. See http://en.wikipedia.org/wiki/X86_calling_conventions for more.

Categories : C

How to get RGB value for the mixed color?
With jQuery: // utility function to retrieve click position inside the canvas function findPos(obj) { var curleft = 0, curtop = 0; if (obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += obj.offsetTop; } while (obj = obj.offsetParent); return { x: curleft, y: curtop }; } return undefined; } $('#myCanvas').click(function(e) { var pos = findPos(this); var x = e.pageX - pos.x; var y = e.pageY - pos.y; var coord = "x=" + x + ", y=" + y; var c = this.getContext('2d'); var p = c.getImageData(x, y, 1, 1).data; // get 1x1 pixels area at the (x,y) position var red_value = p[0]; var green_value = p[1]; var blue_value = p[2]; });

Categories : Javascript

Advice on sql naming conventions
Lookup ISO-11179 for the international database naming standard. for this you can grab this online for free download (though sorry I forget where). There is a lot in it, so here are some some basic summary form it: Take your field description, remove joining words and write it backwards. Always end with a class name. There are standard abbreviations like ID for identifier and such. eg: Date of Entry: Entry_Date Seconds_For_Delivery: Delivery_Seconds Name of Widget: Widget_Name Location of Widget: Widget_Location Size of Widget: Widget_Size Also a field should have the same name if it is a primary key or a referenced foreign key. This will pay off in readability for people that come after you, and also most DB tools will assume they are matching keys so you will a

Categories : SQL

Python 2,7 Dictionary Advice
Use a list as value, list will allow you to append new items: >>> dic = {'PhysicalDrive0': ['0', '1', '2'], 'PhysicalDrive1': ['0', '1']} >>> dic['PhysicalDrive0'].append('3') >>> dic['PhysicalDrive1'].append('2') >>> dic {'PhysicalDrive1': ['0', '1', '2'], 'PhysicalDrive0': ['0', '1', '2', '3']} To append to a value to a missing key you can use dict.setdefault, if the key is already present then it'll append value to the already present list otherwise creates a key with an empty list and then appends the value to it. Demo: #creates a new key PhysicalDrive3' and appends a value to it. >>> dic.setdefault('PhysicalDrive3', []).append('3') >>> dic {'PhysicalDrive1': ['0', '1', '2'], 'PhysicalDrive0': ['0', '1', '2', '3'], 'PhysicalDri

Categories : Python

ArrayAdapter Advice or Suggestions
Once u have the Predictions rather than passing it pass create arraylist based on result. Code: ArrayList<String> al= new Arraylist<String>(); if (predictions.size() > 0 && predictions.get(0).score > 1.0) { String result = predictions.get(0).name; if ("A".equalsIgnoreCase(result)) { al.add(result); Toast.makeText(this, "A", Toast.LENGTH_SHORT).show(); } adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, al); edittext.setAdapter(adapter);

Categories : Android

Azure configuration advice
For your database, you'll want to run SQL Server in a Virtual Machine, as you'll then get all functionality of SQL Server, including FTS. It's very simple to get up and running with SQL Server VM's, as there's a gallery image with SQL Server preinstalled. Regarding your file system storage: This won't scale to multiple instances. You'll need another mechanism for storage. Typically this would be Blob Storage, but... it depends on what you're doing with the files. If you're just serving / storing content (you mentioned uploaded content), this works great, and it's accessible across many instances. If, on the other hand, it's some type of file-based database or index, that won't really work well. If you need to do some type of local processing on the files (e.g. photo or movie rendering),

Categories : Azure

Need some advice on regex in Sigil
I am not sure what you want. the href value for <a> ? if so ,you can try this: (?i)(?<=<a[^>]*?href=(['"]?))[^'"]*?_ftnd+[^'"]+(?=1)

Categories : Regex

Need Some Advice on HTML Forms
I'm pretty sure that you shouldn't be using parameters in your ORDER BY clause. If it were me I would implement an ObjectDataSource and create my ORDER BY clause dynamically using server-side hard-coded alternatives. If you go down that route, then make sure to ALWAYS USE PARAMETERS FOR USER-SUBMITTED DATA TO SECURE YOURSELF AGAINST SQL INJECTION ATTACKS. If you're not up to tackling the ObjectDataSource class, then consider implementing a different SQLDataSource for each of your sort options. Each one will implement a different ORDER BY clause. Set the DataSourceID based on the value of the query parameter. Not sure if that works as-is. You may have to set your GridView's DataSource explicitly. If so, remember to call Databind() explicitly too.

Categories : C#

Advice on where to import app.less in boostrap 3.0?
Why not make an additional LESS file that calls both your custom file and Bootstrap's. So within mystyles.less you will have @import "bootstrap.less"; @import "app.less"; Then when there is a newer version of Bootstrap, you will just replace files, keeping your file untouched.

Categories : Twitter

Python design advice
I think it'd be better to use Python itself as the top-level mapping from URL paths to validation modules. A configuration might look like this: import site1 import site2 def dispatch(uri): if uri.startswith('/site1/'): return site1.validate(uri) elif uri.startswith('/site2/): return site2.validate(uri) This simple example might tempt you to "abstract" it out into a more "generic framework" that turns strings into filenames to use as validation scripts. Here are some advantages of the doing the above instead: Performance: site modules are imported just once, we don't look up filenames per request. Flexibility: if you decide later that the dispatching logic is more complicated, you can easily use arbitrary Python code to deal with it. There will never be a ne

Categories : Python

Advice for POUR1 on SPOJ?
Consider the set of all a priori possibles states (eg [3, 7] meaning Vessel1 contains 3 litters and vessel2 contains 7 litters). You have a directed graph whose vertices are those states and whose edges are the possible moves. The question is to find a path in the graph joining the state [0, 0] to either a state of type [c, ?] or a state of type [?, c]. Such a path is typically searched by a BFS.

Categories : C++

Advice on SQL structure and maybe JOIN?
You could add a user_id column to your fish table like you said. When a user registers a fish, you'd have to insert his user_id at the same time. I suppose you use sessions to keep the users logged in, so you should have a session variable containing the user id.

Categories : PHP

Need some advice on C header inclusion
Everything you've described seems like the normal way to do things. Your two compilation units are only getting the same forward declarations of functions in those headers, not actual duplicate definitions from the libraries. My question is though, is the linker clever enough to only put these declarations in the executable file once? The linker certainly doesn't care what header files you include - it's a linker, not a compiler. So that even though I include these headers several places, it won't have any effect on file size and such? Extra/unused forward declarations of functions will have no effect on binary size. And is this even the correct way of handling common dependencies between several source files? Yes, you seem to be doing things in a completely normal way.

Categories : C

Website layout advice
Could you not just give the divs a max or min height depending on their purpose? I use a main container or wrapper div that the others would be contained in, that div is then my effective page or screen area. <div id="wrapper"> <div id="content"> <div id="sidebar"> </div> </div> </div> #wrapper{ min-height: Whatever value you want here; max-height: Whatever value you want here; } It might be a good idea to set up your page using main container divs, hot only for the content but for the header and footer as well. As an example, I have a main wrapper that is the whole page, within that is the header div, the content div, the nav div and the footer div. These are the main ones. Everything else can then be contained w

Categories : HTML

Advice with for loop programs
You're generating the random number outside of your loop. Therefore it will exist as the same number every time. The solution is to move the definition inside of the loop. public static void main(String[] args) { for(int counter = 0; counter < 30; counter++){ int random = (int) (Math.random() *50) +25; System.out.println(random); } } In this way, every time through the loop (30 iterations), your code will (1) generate some random number and (2) print that number.

Categories : Java

Structs and classes advice
This depends more on the purpose of your type than on the size. If you want to pass data around and want a copy for each call you should use a struct. But if you need to have your data stored at a central location and many other parts of your code should work on the same data, then you need a class. A class is passed by reference and does not duplicate any data. If you copy data around, as structs do, you can end up with an inconsistent state.

Categories : C#



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