instruction stringlengths 0 30k ⌀ |
|---|
I *think* you can specify multiple thumbs for a single slider if you subclass UISlider, at least I vaguely remember that being possible in MacOSX. But Code Addict is right, you'll probably be better off using the standard controls - a double-thumbed slider seems like it'd be pretty difficult to deal with in the touchsc... |
phpgacl <http://phpgacl.sourceforge.net/> is a generic acl based access control framework
while I don't know about any CI specific implementation, i know that you only need the main class file to make phpgacl work. So i belive that integration with CI won't be any problem. (I've work passingly with CI) |
any hashing method that evenly distributes the hash value over the possible range is a good implementation. See effective java ( http://books.google.com.au/books?id=ZZOiqZQIbRMC&dq=effective+java&pg=PP1&ots=UZMZ2siN25&sig=kR0n73DHJOn-D77qGj0wOxAxiZw&hl=en&sa=X&oi=book_result&resnum=1&ct=result ) , there is a good tip i... |
Rails ar_mailer fails to send emails |
|ruby-on-rails|plugins|ar-mailer|smtp| |
I've just switched an application to use ar_mailer and when I run ar_sendmail (after a long pause) I get the following error:
Unhandled exception 530 5.7.0 Must issue a STARTTLS command first. h7sm16260325nfh.4
I am using Gmail SMTP to send the emails and I haven't changed any of the ActionMailer::Base.smtp_s... |
|ruby-on-rails|smtp|plugins|ar-mailer| |
I've just switched an application to use ar_mailer and when I run ar_sendmail (after a long pause) I get the following error:
Unhandled exception 530 5.7.0 Must issue a STARTTLS command first. h7sm16260325nfh.4
I am using Gmail SMTP to send the emails and I haven't changed any of the ActionMailer::Base.smtp_s... |
I can explain that effect in graphic terms.
0. Create an image around 3* the size of the icon.
1. Within this image, create a circle where (the height of the icon) < radius < 2*(the height of the icon).
2. Fill the circle with an alpha blend/transparency (to white) of say 10%.
3. Crop that circle im... |
There's always [vbunit][1]. Unit testing vb code (vb classic / VB6) and com objects is what it does.
[1]: http://www.vbunit.com/ |
I would modify a previously suggested reply like so:
rsync -avlzp /path/to/sfolder name@remote.server:/path/to/remote/dfolder
as follow:
-a (for archive) implies -rlptgoD so the l and p above are superfluous. I also like to include -H, which copies hard links. It is not part of -a by default because it's expe... |
I would modify a previously suggested reply:
rsync -avlzp /path/to/sfolder name@remote.server:/path/to/remote/dfolder
as follows:
-a (for archive) implies -rlptgoD so the l and p above are superfluous. I also like to include -H, which copies hard links. It is not part of -a by default because it's expensi... |
Can FxCop/StyleCop be limited to only analyze selected methods from with Visual Studio? |
|visual-studio|coding-style|fxcop|stylecop| |
I am taking on a maintenance team and would like to introduce tools like FxCop and StyleCop to help improve the code and introduce the developers to better programming techniques and standards. Since we are maintaining code and not making significant enhancements, we will probably only deal with a couple of methods/rou... |
I recommend you to play around with netbeans. It will allow you to build complete GUIs using only your mouse. Once you get familiar with Swing components, start using the Java API. Thats how I started. |
Most memory leaks are the result of not being clear about object ownership and lifetime.
The first thing to do is to allocate on the Stack whenever you can. This deals with most of the cases where you need to allocate a single object for some purpose.
If you do need to 'new' an object then most of the time it wil... |
The performance impact of using instanceof in Java |
|java|performance|instanceof| |
I am working on an application and one design approach involves extremely heavy use of the instanceof operator. While I know that OO design generally tries to avoid using instanceof, that is a different story and this question is purely related to performance. I was wondering if there is any performance impact? Is is j... |
The problem is that FogBugz will link to a web page, and file:///etc is not a web page. To get integration two ways, you need a web server for your subversion repository. Either set up Apache or something else that can host those things the proper way. |
Our build machine running FinalBuilder runs on a Windows XP Virtual Machine running in VMWare Server on Linux.
It is very practical to move it and also to backup, we just stop the Virtual Machine and copy the disk image.
Some days ago we needed to change the host pc, it took less than 2 hours to have our builder ... |
NOTE : NOT tested!
string[] test(string[] myStringArray)
{
List<String> myStringList = new List<string>();
foreach (string s in myStringArray)
{
if (!myStringList.Contains(s))
{
myStringList.Add(s);
}
}
retu... |
I don't think I can access the enumerations via .NET so instead I created the specific constant I needed. For what it's worth heres my code:
> Const ADS_GROUP_TYPE_GLOBAL_GROUP As Object = &H2
adNewGroup.Properties("groupType").Value = ADS_GROUP_TYPE_GLOBAL_GROUP
Refactoring welcome! |
I don't think I can access the enumerations via .NET so instead I created the specific constant I needed. For what it's worth here's my code:
> Const ADS_GROUP_TYPE_GLOBAL_GROUP As Object = &H2
adNewGroup.Properties("groupType").Value = ADS_GROUP_TYPE_GLOBAL_GROUP
Refactoring welcome! |
In the UK it's also best practice to include a real physical address for your company and its registered number.
That way it's all open and honest and they're less likely to manually mark it as spam. |
> `byte ReverseByte(byte b)
{
return b ^ 0xff;
}`
That works if `^` is XOR in your language, but not if it's `AND`, which it often is. |
The following will remove duplicates from an array. You must include the System.Collections namespace.
string[] sArray = {"a", "b", "b", "c", "c", "d", "e", "f", "f"};
var sList = new ArrayList();
for (int i = 0; i < sArray.Length; i++) {
if (sList.Contains(sArray[i]) == false) {
... |
The following tested and working code will remove duplicates from an array. You must include the System.Collections namespace.
string[] sArray = {"a", "b", "b", "c", "c", "d", "e", "f", "f"};
var sList = new ArrayList();
for (int i = 0; i < sArray.Length; i++) {
if (sList.Contains(sArray... |
Yeah, you can do RenderPartial. That's a good start. But eventually these guys will need logic and other controllery type stuff. Be on the lookout for a subcontroller implementation from the framework team. There should also be something in MvcContrib soon. Or roll your own.
Edit: I just posted about this here:... |
After reading the following:
<http://www.w3.org/International/questions/qa-escapes>
it looks like entity escapes are suggested everywhere (including in attributes) for < > and & |
My favorite "hidden" feature is the ability to dump all thread stack traces to standard out.
windows: ctrl-break in your java cmd/console window
unix: kill -3 PID |
My favorite: dump all thread stack traces to standard out.
windows: ctrl-break in your java cmd/console window
unix: kill -3 PID |
Here is an example of doing it with Net::DNS
use Net::DNS;
my $res = Net::DNS::Resolver->new;
# create the reverse lookup DNS name (note that the octets in the IP address need to be reversed).
$IP = "209.85.173.103";
my $target_IP = join('.', reverse split(/\./, $IP)).".in-addr.arpa";
... |
If you need more detailed DNS info use the [Net::DNS][1] module, here is an example:
use Net::DNS;
my $res = Net::DNS::Resolver->new;
# create the reverse lookup DNS name (note that the octets in the IP address need to be reversed).
my $IP = "209.85.173.103";
my $target_IP = join('.', r... |
Here we use [Trac][1] for one project and [@Task][2] for another.
In general, most forms of actually planning, documenting, and tracking tasks is going to take the fun out of working... But it is completely necessary to stay sane.
[1]: http://trac.edgewall.org/
[2]: http://www.attask.com/ |
Here we use [Trac][1] for one project and [@Task][2] for another.
At another company, we used Excel sheets with each person's tasks, printed and pinned to the wall.
In general, most forms of actually planning, documenting, and tracking tasks is going to take the fun out of working... But it is completely necessar... |
Nuclear/particle physics here.
* Major programing work used to be done mostly in fortran using CERNLIB (PAW, MINUIT, ...) and GEANT3, recently it has mostly been done in C++ with ROOT and GEANT4. There are a number of other libraries and tools in specialized use, and Labview sees some use here and there.
* Data acq... |
No. Which means I'm moving to vista this week as I have to use IIS7. |
No. Which means I'm moving to vista this week as I have to use IIS7.
EDIT: Ha - voted up! I assume it's a sympathy vote. :-) |
The main difference between the recommended layout and your proposed layout is that the recommended layout is somewhat self-documenting as to where to commit things, and how it behaves.
For example, in the recommended layout, it's obvious that all new development is committed to trunk, and most branches are made fro... |
From http://www.astrolog.org/labyrnth/algrithm.htm
> Recursive backtracker: This is somewhat related to the recursive backtracker solving method described below, and requires stack up to the size of the Maze. When carving, be as greedy as possible, and always carve into an unmade section if one is next to the current ... |
One thing I do in these cases is to use the 'Composed Method' pattern. See [Jeremy Miller's Blog Post](http://codebetter.com/blogs/jeremy.miller/archive/2006/12/03/Composed-Method-Pattern.aspx) on this subject. The basic idea is to use the refactoring tools in your IDE to extract small meaningful methods. Once you've d... |
You're getting memory leaks because you're freeing the first row of the matrix and the list of rows, but none of the 1 to nth rows. You need to call free in a loop.
There are a couple of alternatives, however:
- Allocate sizeof(int*)*rows + rows*cols*sizeof(int) bytes and use the first bytes for the row pointers. T... |
I like the "is System.DBNull" more because I hate the idea of comparing something to NULL and having it be true. Many other syntaxes (what the hell is the plural of that?) would have anything==NULL return NULL.
I understand that there's DBNull.Value for a reason. I know. I'm listing my PREFERENCE :) |
You should use the float and clear CSS attributes to get the desired effect.
First I defined styles for the called left and right for the two columns in my layout and a style called clearer used to reset the page flow.
<pre><code lang="html">
<style type="text/css">
.left {
float: left;
width: ... |
You should use the float and clear CSS attributes to get the desired effect.
First I defined styles for the called left and right for the two columns in my layout and a style called clearer used to reset the page flow.
<pre><code lang="html">
<style type="text/css">
.left {
float: left;
width: ... |
If you're using **Visual C++** do the following: You include intrin.h and call the following functions:
For 16 bit numbers:
unsigned short _byteswap_ushort(unsigned short value);
For 32 bit numbers:
unsigned long _byteswap_ulong(unsigned long value);
For 64 bit numbers:
unsigned __int64 _b... |
It sounds a bit to me like you are using the little Tomcat deployment manager thing. I basically have no experience with that, just so you know. That said, where I work we use two settings.
In the server.xml file, the context has the attribute *reloadable="true"*.
All we have to do is place the WAR file in the ri... |
This doesn't associate .sh files, but it might get you what you want. I started with the cygwin.bat batch file that launches the Cygwin bash shell, and modified it like so:
$ cat test.bat
@echo off
set MYDIR=C:\scripts
C:\cygwin\bin\bash --login -c "cd $MYDIR && echo 'Now in' `pwd`; s... |
More detailed discussion on this in this post and the comments
http://mikehadlow.blogspot.com/2008/09/managed-extensibility-framework-why.html |
I'd consider it a huge security flaw if that were possible! |
As mentioned by others, the rule of thumb is the [CSS box model][1]. This works generally as advertised by browsers such as Opera, Firefox & Safari. Internet Explorer is your exception, where the "width" includes the margins, padding and borders.
There are some great tools out there that visually depict how the br... |
GetUserName will get you the name, but the password you can't get. It's not even something Windows stores, AFAIK - only a hash of your password.
Depending on what you're trying to achieve (you can tell us a bit more..) it's possible to impersonate a logged on user and do stuff on his/her behalf. |
The best implementation? That is a hard questions because it depends on the usage pattern.
A for nearly all cases reasonable good implementation was proposed in Josh Bloch's "Effective Java" in item 8. The best thing is to look it up there because the author explains there why the approach is good.
A short versi... |
You can't get the password of a user since its encrypted (not to mention that its a standard practice not to store passwords in plaintext).
For getting the username, you can use [GetUserName][1] or [NPGetUser][2]
[1]: http://msdn.microsoft.com/en-us/library/ms724432.aspx
[2]: http://msdn.microsoft.com/en-u... |
I haven't really managed to understand what it is you're doing. But one thing I've found is that accessing MovieClip's children in the very first frame is a bit unreliable. For instance you can't gotoAndStop() and then access whatever children is on that frame, you have to wait a frame before they will be available. |
You can get the user name with GetUserName(), but you cannot get the password; this would violate security for dummies 101.
|
How do you serialize javascript objects with mehtods using JSON |
|asp.net|json|viewstate| |
I am looking for an enhancement to JSON that will also serialize methods. I have an object that acts as a collection of objects, and would like to serialize the methods of the collection object as well. So far I've located [ClassyJSON][1]. Any thoughts?
[1]: http://www.thomasfrank.se/classier_json.html |
How do you serialize javascript objects with methods using JSON |
How to logically organize recurring tasks? |
|calendar|logic|task| |
What's the best way to create recurring tasks?
Should I create some special syntax and parse it, kind of similar to Cronjobs on Linux or should I much rather just use a cronjob that runs every hour to create more of those recurring tasks with no end?
Keep in mind, that you can have endless recurring tasks and tas... |
[Autopatch][1] is what we are using. It works pretty well.
It allows sql patches, data patches, and java patches all applied to your sql database.
[1]: http://autopatch.sourceforge.net/ |
I wrote a post called ["Getting Started With Rails -- What I wish I knew"][1] that many people found helpful.
The basics:
* Agile development with Rails (book)
* InstantRails for quick ruby/rails environment on Windows
* Aptana as the IDE
* Subversion for version control
The online tutorials are decent but ... |
Try to get away without serializing javascript code. That way lies a world of pain. Debugging will be much easier if code can only come from static files, not from a database. Instead, walk your JSON responses after you receive them and pass the appropriate data to the appropriate object constructors.
If you absolut... |
If you use WCF framework to develop RESTful web service, that is very easy to achieve.
Simply create your data structure classes with your desired collection with DataContract, DataMember attributes.
[DataContract]
public class Foo
{
[DataMember]
public string FooName {get;set;}
... |
I don't think serializing methods is ever a good idea. If you intend to run the code serverside, you open yourself to attacks. If you want to run it client side, you are better off just the local methods, possibly referencing the name of the method you are going to use in the serialized objects.
I do believe though ... |
Some Unix flavors may have an API way to do this, but there is no way to do it that is portable across different variants. |
Just because the memory has been free'd doesn't mean you can't access it! Of course, it's a **very bad** idea to access it after it's been free'd, but that's why it works in your example.
Note that `free( *first_matrix )` only free's `first_matrix[0]`, not the other arrays. You probably want some kind of marker to s... |
The contents of an HTTP post upload stream and the mechanics of it don't seem to be what you are expecting them to be. You cannot just write a file as the post content, because POST has very specific RFC standards on how the data included in a POST request is supposed to be sent. It is not just the formatted of the con... |
I think it depends on what version of EJBs you're talking about. Let's discuss the only two relevant (IMO) versions.
EJB 2.1 might still be used by some people in a legacy system. They really have the most use as an RPC abstraction. They also provided a rudimentary ORM (Object-Relational Mapping) system as well. And... |
From http://www.astrolog.org/labyrnth/algrithm.htm
> Recursive backtracker: This is somewhat related to the recursive backtracker solving method described below, and requires stack up to the size of the Maze. When carving, be as greedy as possible, and always carve into an unmade section if one is next to the current ... |
Just to respond to the couple of comments on my above post:
**Domenic** - I'm on this site, and I care. Not for pedantry's sake, but because we - as programmers - typically care about precision. Using O( ) notation incorrectly in the style that some have done here renders it kind of meaningless; we may just as well ... |
Suggestions for implemetation of a commnd line application interface. |
|command-line|user-interface| |
I am redesigning a command line application and am looking for a way to make its use more intuitive. Are there any conventions for the format of parameters passed into a command line application? Or any other method that people have found useful? |
You can try something like this. I'm not 100% sure it will work because count() is a aggregate function but its worth a shot.
SELECT b
FROM table1
WHERE a = (
SELECT
CASE count(b)
WHEN 0 THEN :default_value
ELSE :passed_value
END
FROM table... |
There are only two good ones: [Doctrine](http://www.doctrine-project.org/) and [Propel](http://propel.phpdb.org/trac/). We favor Doctrine, it works well with Symfony. However if you're looking for DB support besides the main ones you'll have to write your own code. |
On a very high level of abstraction, there are two main caveats with mobile devices: (1) their screen is small, (2) their network connection is intermittent. This basically means that your need to present the content so that it looks fine even on a small (variable size) screen, and preferably make it cacheable too so t... |
What are indexes and how can I use them to optimize queries in my database? |
|sql|sql-server|database-design| |
I am maintaining a pretty sizable application and database and am noticing some poor database performance in a few of our stored procedures...
I always hear that "adding an index" can be done to help performance...I am certainly no DBA, and I do not understand what indexes are, why the help, and how to create them..... |
Enum.GetNames(Suits), I think... |
I use :
- [drop.io][1]
- [Dropbox][2]
[1]: http://www.drop.io
[2]: http://www.getdropbox.com |
You will need to add some capability to blacklist sites / domains or other things (IP ranges, ASN, etc) to avoid your spider getting bogged down with spam sites.
You'll need to have a HTTP implementation with a lot of control over timeout and behaviour. Expect a lot of sites to send back invalid responses, huge resp... |
If you are doing this for purposes of network/host compatability you should use:
ntohl() //Network to Host byte order (Long)
htonl() //Host to Network byte order (Long)
ntohs() //Network to Host byte order (Short)
htons() //Host to Network byte order (Short)
If you are doing this for some... |
Well thanks to all of your help especially @alexander I have discovered that all the extra memory that isn't visible via Process Explorer is being used by the Java Heap. In fact via other tests that I have run the JVM's memory consumption is included in what I see from the Process Explorer. So the heap is taking larg... |
I personally use [DropBox][1], but it doesn't have access control. [drop.io][2] has password protection, though, so that could be used for access control.
[1]: http://www.getdropbox.com/
[2]: http://drop.io/ |
You forgot a significant option that deserves a category of its own: a hybrid data mapping framework such as [iBatis][1].
I have been pleased with iBatis because it lets your OO code remain OO in nature, and your database remain relational in nature, and solves the impedance mismatch by adding a third abstraction (t... |
The baseline recommendation would be to:
- Inform the user that you are storing their SSN before they use your site/application. **Since the request appears to be to collect the information *after the fact*, the users should have a way to opt out of your system before they log in or before they put in their SSN**
... |
Brandon Savage gave a presentation on his PHP package "[ApplicationACL][1]" that may or may not accomplish role-based access. [PHPGACL][2] might work as well, but I can't tell you for sure.
What I can tell you, however, is the [Zend\_ACL][3] component of the Zend Framework will do role-based setups (however you'll h... |
On my computer, WIA was painstakingly sloooow... so i decided to give the <a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms713477(VS.80).aspx">Windows Multimedia Video Capture</a> a try.
You can find a demo <a href="http://www.timvw.be/wp-content/code/csharp/testavicap32.zip">here</a>. |
as mentioned above.. you are fixing the symptom, not the problem..
What you need is the separation of logic and presentation. Which can be done with some sort of mvc framework. Even if you don't want to go all the way with a mvc framework.. A templating engine is a must at least if your logic is complicated enoug... |
If it were me I'd avoid them like the plague, or figure out some very very secure way to store them. Additionally (not a legal expert by any extent but..) if you can put in writing somewhere that you are no way responsible if any of this gets out. |
>>> import re
>>> re.findall(r'\d+|\D+', '2+24*48/32=10')
['2', '+', '24', '*', '48', '/', '32', '=', '10']
Matches consecutive digits or consecutive non-digits.
Each match is returned as a new element in the list.
|
>>> import re
>>> re.findall(r'\d+|\D+', '2+24*48/32=10')
['2', '+', '24', '*', '48', '/', '32', '=', '10']
Matches consecutive digits or consecutive non-digits.
Each match is returned as a new element in the list.
Depending on the usage, you may need to alter the regular expression. Such as if... |
In WinForms, why can't you update UI controls from other threads? |