text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
you can change the state of the outer class as well as use its methods.
Gilad Bracha (one of the main java language designers) wrote a [paper](http://bracha.org/dyla.pdf) discussing that.
So, suppose you want to share some methods for internal use between some unrelated classes (e.g, for string manipulation), you can create sub classes of them as inner classes of a class that has all the needed methods, and the sub classes could use methods both from their super classes and from the outer class.
Anyway, it's tricky for complex classes, and you could get most of the functionality using static | [
0.13931402564048767,
-0.211969256401062,
-0.3359193801879883,
0.12359100580215454,
-0.12321408092975616,
0.04819425940513611,
0.41914671659469604,
-0.26945769786834717,
-0.4093490540981293,
-0.4739815890789032,
-0.18770964443683624,
0.0814252570271492,
-0.6846222281455994,
0.10246556997299... | |
imports (from java 5 on). Great question for job interviews and pub quizzes, though ;-) | [
0.168418288230896,
-0.004721008241176605,
0.006915398873388767,
0.03395611792802811,
0.055544137954711914,
0.022291678935289383,
0.1789417862892151,
0.23309557139873505,
-0.45878082513809204,
-0.4770444631576538,
-0.13106711208820343,
0.35341185331344604,
-0.22553811967372894,
-0.341444820... | |
I administrate several Oracle Apps environment, and currently check profile options in lots of environments by loading up forms in each environment, and manually checking each variable, which requires a lot of time.
Is there a snippet of code which will list profile options and at what level and who they are applied to?
You'll want to query `APPLSYS.FND_PROFILE_OPTIONS` and `FND_PROFILE_OPTION_VALUES`.
For a comprehensive script that you can pick up the SQL from, look here:
<http://tipsnscripts.com/?p=16> | [
0.9276127815246582,
0.31686678528785706,
0.4366679787635803,
-0.12290987372398376,
0.13943269848823547,
-0.04591205343604088,
-0.10694772750139236,
-0.1843993216753006,
0.15186770260334015,
-0.23530089855194092,
0.4348967671394348,
0.3365993797779083,
-0.01990225911140442,
-0.1303814202547... | |
I intend to use **RADIX / MTRIE** as my preferred data-structure for a routing implementation.
Is there a decent open source implementation available (apart from freebsd-net) which I can use for my purpose, or do I need to write one myself?
There is a radix-tree implementation available under the GNU General Public License version 2, or (at your option) any later version:
<http://www.gelato.unsw.edu.au/lxr/source/lib/radix-tree.c> | [
0.3569338023662567,
-0.01309799775481224,
0.036871518939733505,
-0.22531358897686005,
-0.13796143233776093,
0.048826076090335846,
-0.19575941562652588,
-0.19792474806308746,
-0.22490742802619934,
-0.6392561197280884,
0.036355044692754745,
0.24552452564239502,
-0.3916141390800476,
-0.016005... | |
And if you do, can you give some background information on the implementation and the reasons for implementing this pattern?
The pattern is described in more detail in these articles:
* [Microsoft Inductive User Interface
Guidelines](http://msdn.microsoft.com/en-us/library/ms997506.aspx)
* [IUIs and Web-Style
Navigation in Windows Forms, Part 1](http://msdn.microsoft.com/en-us/library/ms951103.aspx) & [Part 2](http://msdn.microsoft.com/en-us/library/ms951278.aspx)
Yes - we had a problem in that many of the administrators of our software found it too difficult to use. To solve this we used Microsoft's WinForms IUI framework build a new configuration and management tool for our software.
User feedback has been extremely positive, particularly with everything being task driven - i.e. the links on | [
0.17431116104125977,
-0.02340581826865673,
0.46520382165908813,
0.1083294078707695,
0.21124422550201416,
-0.21834126114845276,
0.4137724041938782,
-0.025934971868991852,
-0.26189693808555603,
-0.7498730421066284,
-0.07366170734167099,
0.34388232231140137,
-0.3507620394229889,
-0.0255592241... | |
our home page include thing like "Create new user", "Create new department" - rather then the user having to discover how to do this by clicking through a series of menus. Since the inductive interface is more similar to a web-browser (hypertext links, back/forward buttons) it seems much easier for new users to learn. | [
0.4779013395309448,
-0.0013273416552692652,
0.5490942597389221,
0.20584949851036072,
0.029380081221461296,
-0.34890198707580566,
-0.009616518393158913,
0.3621165454387665,
-0.045364994555711746,
-0.8830203413963318,
0.001840227167122066,
0.2234651744365692,
0.15107759833335876,
0.219366803... | |
What are the pros / cons of using `pthread_cond_wait` or using a semaphore ?
I am waiting for a state change like this :
```
pthread_mutex_lock(&cam->video_lock);
while(cam->status == WAIT_DISPLAY) {
pthread_cond_wait(&cam->video_cond, &cam->video_lock);
}
pthread_mutex_unlock(&cam->video_lock);
```
Using a properly initialised semaphore, I think I could do it like this :
```
while(cam->status == WAIT_DISPLAY) {
sem_wait(&some_semaphore);
}
```
What are the pros and cons of each method ?
A semaphore is suited cleanly to a producer-consumer model, although it has other uses. Your program logic is responsible for ensuring that the right number of posts are made for the number of waits. If you post a semaphore and nobody | [
0.6772050261497498,
-0.07489923387765884,
0.6874752044677734,
0.022216875106096268,
0.18138761818408966,
0.12367160618305206,
-0.02552725002169609,
-0.2584344744682312,
-0.14849582314491272,
-0.5970116853713989,
-0.08212357014417648,
0.3096153140068054,
-0.3109724223613739,
0.0308491382747... | |
is waiting on it yet, then when they do wait they continue immediately. If your problem is such that it can be explained in terms of the count value of a semaphore, then it should be easy to solve with a semaphore.
A condition variable is a bit more forgiving in some respects. You can for example use cond\_broadcast to wake up all waiters, without the producer knowing how many there are. And if you cond\_signal a condvar with nobody waiting on it then nothing happens. This is good if you don't know whether there's going to be a listener interested. | [
0.5279629230499268,
-0.17925894260406494,
0.4644166827201843,
-0.12432733923196793,
-0.10293930023908615,
-0.15008483827114105,
0.30164599418640137,
0.16924121975898743,
-0.40112021565437317,
-0.21801602840423584,
0.09582232683897018,
0.6275038123130798,
-0.2827122211456299,
0.285993993282... | |
It is also why the listener should always check the state with the mutex held before waiting - if they don't then they can miss a signal and not wake up until the next one (which could be never).
So a condition variable is suitable for notifying interested parties that state has changed: you acquire the mutex, change the state, signal (or broadcast) the condvar and release the mutex. If this describes your problem you're in condvar territory. If different listeners are interested in different states you can just broadcast and they'll each in turn wake up, figure out whether they've | [
0.09491448104381561,
-0.015568319708108902,
0.48107287287712097,
-0.020823214203119278,
-0.001998136518523097,
-0.021394720301032066,
0.44854214787483215,
-0.24711012840270996,
-0.4164212644100189,
-0.28092578053474426,
-0.13002561032772064,
0.6653257608413696,
-0.30086657404899597,
0.6255... | |
found the state they want, and if not wait again.
It's very gnarly indeed to attempt this sort of thing with a mutex and a semaphore. The problem comes when you want to take the mutex, check some state, then wait on the semaphore for changes. Unless you can atomically release the mutex and wait on the semaphore (which in pthreads you can't), you end up waiting on the semaphore while holding the mutex. This blocks the mutex, meaning that others can't take it to make the change you care about. So you will be tempted to add another mutex in | [
0.20373384654521942,
-0.02801496535539627,
0.14370885491371155,
0.1984282284975052,
0.313975989818573,
0.5693724155426025,
0.14048710465431213,
0.11398588865995407,
-0.24085941910743713,
-0.3653145134449005,
-0.00843784399330616,
0.24058684706687927,
-0.21800774335861206,
0.448509126901626... | |
a way which depends on your specific requirements. And maybe another semaphore. The result is generally incorrect code with harmful race conditions.
Condition variables escape this problem, because calling cond\_wait automatically releases the mutex, freeing it for use by others. The mutex is regained before cond\_wait returns.
IIRC it is possible to implement a kind of condvar using only semaphores, but if the mutex you're implementing to go with the condvar is required to have trylock, then it's a serious head-scratcher, and timed waits are out. Not recommended. So don't assume that anything you can do with a condvar can be done | [
0.2970650792121887,
-0.11412470042705536,
0.21500305831432343,
0.02597912587225437,
0.18601274490356445,
-0.14810845255851746,
0.35646602511405945,
-0.5307835936546326,
-0.0424065999686718,
-0.52114337682724,
-0.09798277914524078,
0.6151387095451355,
-0.2649692893028259,
0.1817343682050705... | |
with semaphores. Plus of course mutexes can have nice behaviours that semaphores lack, principally priority-inversion avoidance. | [
0.15401357412338257,
-0.09692411124706268,
-0.4676816761493683,
0.06279385089874268,
-0.6078984141349792,
0.48660552501678467,
0.6476849913597107,
0.15286670625209808,
-0.3988015353679657,
-0.2841361463069916,
-0.5048686265945435,
0.5305061936378479,
-0.4275496304035187,
-0.392359644174575... | |
I need to be able to quickly convert an image (inside a rails controller) so that the hosting company using managing our application can quickly test at any time to ensure that rmagick is not only successfully installed, but can be called throgh the rails stiack, what is the quickest clean code I can use to do this?
I wanted to do this so that I can easily hit it with a web browser, as I'm deployng to managed servers, which I do not have shell access onto (for increased security).
So this is what I did
```
class DiagnosticsController < ApplicationController
require | [
0.27747368812561035,
0.18141713738441467,
0.2856970429420471,
0.15409520268440247,
-0.03089025244116783,
-0.2239706963300705,
0.34461960196495056,
-0.1562911719083786,
-0.19987960159778595,
-0.7571004033088684,
0.2231934666633606,
0.7093487977981567,
-0.10516182333230972,
0.027648791670799... | |
'RMagick'
def rmagick
images_path = "public/images"
file_name = "rmagick_generated_thumb.jpg"
file_path = images_path + "/"+ file_name
File.delete file_path if File.exists? file_path
img = Magick::Image.read("lib/sample_images/magic.jpg").first
thumb = img.scale(0.25)
@path = file_name
thumb.write file_path
end
end #------
```
and then in rmagick.html.erb
```
<%= image_tag @path %>
```
Now I can hit the controller, and if I see an image, I know rmagic is installed. | [
-0.04283306747674942,
-0.16644372045993805,
1.0810705423355103,
-0.011714481748640537,
-0.21012721955776215,
-0.1214403584599495,
0.24884270131587982,
-0.676019549369812,
-0.39830493927001953,
-0.47433069348335266,
0.04100615158677101,
0.7609485983848572,
-0.15761823952198029,
-0.074763625... | |
I'm really interested to hear what you think about Model-driven Software Development for Java and/or .NET.
Does it save time? Does it improve quality?
I am using MDSD in a project with IBM Rational Rhapsody for C++. The model is pretty close to UML, so there we do not really have a Domain-Specific-Language. But still I would claim to use MDSD. From my experience, there are many benefits with MDSD:
a) Using MDSD helps to bring a SW architecture to a sophisticated level. You always work on a very abstract level, thinking about the big picture. Cowboy coding software usually lacks a good | [
0.8125613927841187,
0.015602163970470428,
-0.11853083968162537,
0.44416192173957825,
-0.08656511455774307,
-0.4016641080379486,
0.06286561489105225,
0.43499138951301575,
-0.14491702616214752,
-0.5016980171203613,
0.5651922821998596,
0.5304990410804749,
-0.3718164265155792,
-0.0922104790806... | |
architecture, because a developer is stuck in details. With MDSD, I see a tendency in my work, to solve problems with adequate sized classes, nice patterns, or simply better code.
b) Big picture documentation of the SW tends to be better with MDSD. Of course, there are tools that automatically generate a class diagram out of your code. But these diagrams consists of 1000 classes and you do not see the aspect of interest. With MDSD, you specifically draw one aspect of the system, and the very same diagram is also used to generate a part of your code.
c) Modelling helps | [
0.3677072823047638,
0.18484263122081757,
0.08458791673183441,
0.28031212091445923,
-0.0330914631485939,
0.3796534836292267,
0.19661463797092438,
-0.2788889408111572,
-0.30194494128227234,
-1.0973495244979858,
-0.16648539900779724,
0.45659980177879333,
-0.1508142352104187,
0.101091817021369... | |
to deal with an inherent system complexity. I would say, some systems are just too complex to be built without support from computer-aided design. Nobody would design a CPU without the help of huge SW tools. Use SW to help you write even more complex SW.
d) Using MDSD helps to adhere to coding style guidelines. There is no better way to get coherent code style than letting the code be generated by a rule set.
There are of course also some downsides of MDSD:
d) If you have a model, you want every line of code to come from that model. And | [
0.356860876083374,
0.22187697887420654,
0.20910100638866425,
0.2855178713798523,
-0.14088234305381775,
-0.20796841382980347,
0.2317122519016266,
-0.12751030921936035,
-0.09420865774154663,
-0.7991353273391724,
0.1276444047689438,
0.6025614738464355,
-0.22904124855995178,
0.1398513168096542... | |
it may be difficult to include external libraries to a project. So either you live with the fact, that your system is based on external components or you reinvent the wheel to get it into your model.
e) Modelling tools might suffer from problems using versioning tools. Source code is usually simpler to merge than a model diagram. This forces a team to move from the copy-edit-merge to a lock-edit-merge workflow. | [
0.16159053146839142,
-0.13859528303146362,
-0.11213572323322296,
0.5813162922859192,
0.025168301537632942,
-0.04883560538291931,
0.11668657511472702,
-0.24977795779705048,
-0.3948422372341156,
-0.6428173184394836,
-0.0075972494669258595,
0.5576725006103516,
-0.2165849357843399,
0.162606909... | |
For best performance, is it better to use a virtual IDE HDD or virtual SCSI HDD?
If, SCSI, does it matter whether you use an BusLogic or LSILogic?
Go for the SCSI and LSILogic. IDE and BusLogic are for compatibility reasons. Like when you do physical2virtual...
There's a whitepaper from vmware showing the difference between LSILogic and BusLogic, which in my opinion is rather small:
<http://www.vmware.com/pdf/ESX2_Storage_Performance.pdf>
Edit after like three years:
With current ESX environments it's best to use the Paravirtual SCSI device. | [
0.22238579392433167,
-0.31413334608078003,
0.5480857491493225,
0.23503915965557098,
-0.01607045717537403,
-0.13788101077079773,
-0.021270476281642914,
-0.13150765001773834,
-0.13349783420562744,
-1.0632123947143555,
-0.047922588884830475,
0.7529171705245972,
-0.04935876652598381,
-0.055886... | |
With Hibernate, can you create a composite ID where one of the columns you are mapping to the ID can have null values?
This is to deal with a legacy table that has a unique key which can have null values but no primary key.
I realise that I could just add a new primary key column to the table, but I'm wondering if there's any way to avoid doing this.
No. Primary keys can not be null. | [
0.26200729608535767,
-0.23099444806575775,
0.15521429479122162,
0.011327316053211689,
-0.31851816177368164,
-0.03098171018064022,
0.06946991384029388,
-0.22433622181415558,
-0.003794816555455327,
-0.5968020558357239,
0.21909436583518982,
0.415216863155365,
-0.4666014015674591,
-0.057390701... | |
I have a workbook with 20 different pivot tables. Is there any easy way to find all the pivot tables and refresh them in VBA?
Yes.
```
ThisWorkbook.RefreshAll
```
Or, if your Excel version is old enough,
```
Dim Sheet as WorkSheet, Pivot as PivotTable
For Each Sheet in ThisWorkbook.WorkSheets
For Each Pivot in Sheet.PivotTables
Pivot.RefreshTable
Pivot.Update
Next
Next
``` | [
0.3642488718032837,
0.2857767343521118,
0.6785885095596313,
-0.0008849899168126285,
-0.1513991802930832,
0.16400091350078583,
-0.045084111392498016,
-0.3927769958972931,
-0.3918650150299072,
-0.5623258352279663,
0.2457592934370041,
0.3853191137313843,
-0.17586730420589447,
-0.0090348888188... | |
I'm trying to create a Zip file from .Net that can be read from Java code.
I've used SharpZipLib to create the Zip file but also if the file generated is valid according to the CheckZip function of the #ZipLib library and can be successfully uncompressed via WinZip or WinRar I always get an error when trying to uncompress it using the Java.Utils.Zip class in Java.
Problem seems to be in the wrong header written by SharpZipLib, I've also posted a question on the SharpDevelop forum but with no results (see <http://community.sharpdevelop.net/forums/t/8272.aspx> for info) but with no result.
Has someone a code sample | [
0.4618441164493561,
0.14646203815937042,
-0.00017014011973515153,
0.0010596758220344782,
-0.1587093621492386,
0.036194536834955215,
0.40969541668891907,
-0.2658359110355377,
0.06162967532873154,
-0.5742761492729187,
0.30359748005867004,
0.5084786415100098,
-0.26663821935653687,
0.050110492... | |
of compressing a Zip file with .Net and de-compressing it with the Java.Utils.Zip class?
Regards
Massimo
I have used [DotNetZip library](http://www.codeplex.com/DotNetZip) and it seems to work properly. Typical code:
```
using (ZipFile zipFile = new ZipFile())
{
zipFile.AddDirectory(sourceFolderPath);
zipFile.Save(archiveFolderName);
}
``` | [
0.5600507855415344,
-0.4615437388420105,
0.6394522786140442,
-0.24182181060314178,
0.16763541102409363,
-0.1188264861702919,
-0.00805493164807558,
-0.7076712250709534,
-0.19121557474136353,
-0.47235092520713806,
0.29802635312080383,
0.6276659965515137,
-0.6968544125556946,
-0.1506209373474... | |
What is the difference, what is the official terms, are any terms obsolete in ASP.NET 3.5?
**UserControl**: A custom control, ending in .ascx, that is composed of other web controls. Its almost like a small version of an aspx webpage. It consists of a UI (the ascx) and codebehind. Cannot be reused in other projects by referencing a DLL.
**WebControl**: A control hosted on a webpage or in a UserControl. It consists of one or more classes, working in tandem, and is hosted on an aspx page or in a UserControl. WebControls don't have a UI "page" and must render their content | [
0.1221332848072052,
-0.21164150536060333,
0.41178208589553833,
0.5465521812438965,
-0.12597177922725677,
-0.09670126438140869,
-0.16822287440299988,
0.08420637995004654,
-0.10456366091966629,
-0.6498070359230042,
-0.3387795686721802,
0.0014148447662591934,
-0.2819206118583679,
0.0039180582... | |
directly. They can be reused in other applications by referencing their DLLs.
**RenderedControl**: Does not exist. May be synonymous to WebControl. Might indicate the control is written directly to the HttpResponse rather than rendered to an aspx page.
**[CompositeControl](http://msdn.microsoft.com/en-us/library/aa479016.aspx)**: Inbetween UserControls and WebControls. They code like UserControls, as they are composed of other controls. There is not any graphical UI for control compositing, and support for UI editing of CompositeControls must be coded by the control designer. Compositing is done in the codebehind. CompositeControls can be reused in other projects like WebControls. | [
0.17652776837348938,
0.09636882692575455,
0.3965080678462982,
0.29327112436294556,
0.0014892854960635304,
0.187847301363945,
-0.12947118282318115,
-0.21031512320041656,
-0.0005413744365796447,
-0.5518721342086792,
-0.2100963294506073,
0.4648030400276184,
-0.3915809094905853,
-0.24471677839... | |
Under what circumstances might you want to use multiple indirection (that is, a chain of pointers as in `Foo **`) in C++?
Most common usage as @aku pointed out is to allow a change to a pointer parameter to be visible after the function returns.
```
#include <iostream>
using namespace std;
struct Foo {
int a;
};
void CreateFoo(Foo** p) {
*p = new Foo();
(*p)->a = 12;
}
int main(int argc, char* argv[])
{
Foo* p = NULL;
CreateFoo(&p);
cout << p->a << endl;
delete p; | [
0.3383140563964844,
-0.05890481919050217,
0.48475706577301025,
-0.4704708158969879,
0.16020746529102325,
0.3640509843826294,
0.12675225734710693,
-0.37831124663352966,
-0.36629393696784973,
-0.249106302857399,
-0.3360605537891388,
0.5173425674438477,
-0.636162519454956,
0.04834155365824699... | |
return 0;
}
```
This will print
```
12
```
But there are several other useful usages as in the following example to iterate an array of strings and print them to the standard output.
```
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
const char* words[] = { "first", "second", NULL };
for (const char** p = words; *p != NULL; ++p) {
cout << *p << endl;
}
return 0;
}
``` | [
-0.06828132271766663,
0.32422152161598206,
0.4234543740749359,
-0.4763956665992737,
0.20305834710597992,
0.33124056458473206,
0.45351913571357727,
-0.1671944260597229,
-0.08044594526290894,
-0.560417115688324,
-0.46145203709602356,
0.6590522527694702,
-0.4753187894821167,
-0.14118851721286... | |
When viewing someone else's webpage containing an applet, how can I force Internet Explorer 6.0 to use a a particular JRE when I have several installed?
If you mean when you are not the person writing the web page, then you could disable the add ons you do not wish to use with the [Manage Add-Ons](http://windowsxp.mvps.org/addons.htm) IE Options screen added in Win XP SP2 | [
0.030808471143245697,
0.01030197087675333,
0.33630865812301636,
0.18640656769275665,
0.026073694229125977,
-0.07264363020658493,
0.28586381673812866,
-0.1329415738582611,
-0.3482268750667572,
-0.6381782293319702,
-0.12677477300167084,
0.7678552865982056,
-0.37809649109840393,
-0.0287575758... | |
How do I suspend a whole process (like the Process Explorer does when I click Suspend) in C#.
I'm starting the Process with Process.Start, and on a certain event, I want to suspend the process to be able to do some investigation on a "snapshot" of it.
Here's my suggestion:
```
[Flags]
public enum ThreadAccess : int
{
TERMINATE = (0x0001),
SUSPEND_RESUME = (0x0002),
GET_CONTEXT = (0x0008),
SET_CONTEXT = (0x0010),
SET_INFORMATION = | [
0.44111281633377075,
-0.29957637190818787,
0.6847707033157349,
-0.12106262892484665,
0.26719483733177185,
-0.27965182065963745,
0.0771310105919838,
0.22064970433712006,
-0.6600106954574585,
0.092190682888031,
-0.4117330014705658,
0.4285871386528015,
-0.43724730610847473,
0.3167228102684021... | |
(0x0020),
QUERY_INFORMATION = (0x0040),
SET_THREAD_TOKEN = (0x0080),
IMPERSONATE = (0x0100),
DIRECT_IMPERSONATION = (0x0200)
}
[DllImport("kernel32.dll")]
static extern IntPtr OpenThread(ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId);
[DllImport("kernel32.dll")]
static extern uint SuspendThread(IntPtr hThread);
[DllImport("kernel32.dll")]
static extern int ResumeThread(IntPtr hThread);
[DllImport("kernel32", CharSet = CharSet.Auto,SetLastError = true)]
static extern bool CloseHandle(IntPtr handle);
private static void SuspendProcess(int pid)
{
var | [
-0.1085115298628807,
-0.30742791295051575,
1.0442068576812744,
-0.18959176540374756,
-0.03962837532162666,
0.1908399611711502,
0.38478073477745056,
-0.15241946280002594,
-0.2851153314113617,
-0.09799565374851227,
-0.6291483640670776,
0.632434070110321,
-0.5364631414413452,
0.36433783173561... | |
process = Process.GetProcessById(pid); // throws exception if process does not exist
foreach (ProcessThread pT in process.Threads)
{
IntPtr pOpenThread = OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)pT.Id);
if (pOpenThread == IntPtr.Zero)
{
continue;
}
SuspendThread(pOpenThread);
CloseHandle(pOpenThread);
}
}
public static void ResumeProcess(int pid)
{
var process = Process.GetProcessById(pid);
if (process.ProcessName == string.Empty)
return;
foreach (ProcessThread pT in process.Threads)
{
IntPtr pOpenThread = OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)pT.Id);
if (pOpenThread == | [
0.10538939386606216,
0.03218187019228935,
0.879951000213623,
-0.34758469462394714,
0.45834335684776306,
0.3531753420829773,
0.5060223937034607,
-0.08443335443735123,
-0.4253261685371399,
-0.35686448216438293,
-0.4944518506526947,
0.5378523468971252,
-0.19216400384902954,
0.630396842956543,... | |
IntPtr.Zero)
{
continue;
}
var suspendCount = 0;
do
{
suspendCount = ResumeThread(pOpenThread);
} while (suspendCount > 0);
CloseHandle(pOpenThread);
}
}
``` | [
0.14037173986434937,
-0.2276834398508072,
0.8984434008598328,
-0.23426510393619537,
0.4914718270301819,
-0.13697832822799683,
0.4980151057243347,
-0.020934294909238815,
-0.1996631771326065,
0.021516665816307068,
-0.4763939380645752,
0.7304731607437134,
-0.16350767016410828,
0.2755925953388... | |
I want to develop some educational content, which I want to distribute to children using Adobe AIR. The content will contain videos. Now, from what I see, AIR will put the content onto the local file system, for anyone to see. I want to prevent this. Is there a way out?
One solution is to use DRM in conjunction with Flash Media Server (as mentioned by Stu).
Another option would be to stream the content at runtime, and not cache to the file system.
Finally, it might also be possible to store the bits for the FLV in the encrypted local data | [
0.6329862475395203,
0.33042627573013306,
0.43511834740638733,
0.464497447013855,
0.15135326981544495,
-0.29559266567230225,
-0.11895987391471863,
-0.016671249642968178,
-0.1538895070552826,
-0.37585562467575073,
-0.30267223715782166,
0.5609136819839478,
0.020408347249031067,
-0.07497598230... | |
store or SQLite database (which adds encryption support in AIR 1.5), however, this probably wouldnt work well for large videos (performance issues), and you may still need to write it out to the file system first before playing (although temporarily).
mike chambers | [
0.5234249234199524,
0.5169129967689514,
0.3706781566143036,
0.142347514629364,
0.5770759582519531,
-0.2016521841287613,
0.13011504709720612,
-0.15403033792972565,
-0.029529355466365814,
-0.7720481753349304,
-0.10281891375780106,
0.5326676368713379,
-0.7560385465621948,
-0.15989191830158234... | |
I am using git on a project, that generates lots of data-files (simulation-results).
I am "forced" to version and track all those results in the same repository. (This is a hard requirement and can not be changed)
However I don't need them. We have about 50 MB for the project and 5 GB results in the repository.
Is it feasible for me to create a branch, delete all the results, check this branch out and only work on that branch?
How hard would it be (what would I have to do), to push my local changes back into the fat branch?
Is there a | [
0.47254058718681335,
0.05076616257429123,
0.09070204943418503,
0.26611313223838806,
0.18772771954536438,
0.06969959288835526,
0.22096846997737885,
0.05807838588953018,
-0.41051962971687317,
-0.6144611239433289,
-0.03142700716853142,
0.44110721349716187,
-0.04325783625245094,
0.427693665027... | |
better solution to get rid of those 5 GB for my work?
If you were to make a branch and delete the result files from the branch, then merging your branch back into master would also try to delete the results from master. A file delete is a change just like any other.
Perhaps you could use the git submodule support to manage your code changes as a submodule of the fat repository. In this way, the fat repository would appear to contain everything, but you could work on just the small code bits independently. This may take some fiddling around to | [
0.31954512000083923,
-0.2863674759864807,
0.19769389927387238,
0.2857106029987335,
0.06548304855823517,
0.09229516237974167,
0.24927271902561188,
-0.17407453060150146,
-0.5060412883758545,
-0.6018937230110168,
0.03794610872864723,
0.4180868864059448,
-0.0700041875243187,
0.4013647735118866... | |
work smoothly. | [
0.5810644030570984,
0.246378555893898,
0.040781162679195404,
0.25443121790885925,
-0.017141038551926613,
-0.3357497751712799,
0.37493497133255005,
0.3731268644332886,
0.18235689401626587,
-0.8164606094360352,
-0.4383052587509155,
0.5656313896179199,
0.13807162642478943,
-0.3882592320442199... | |
I'm trying to replace each `,` in the current file by a new line:
```
:%s/,/\n/g
```
But it inserts what looks like a `^@` instead of an actual newline. The file is not in DOS mode or anything.
What should I do?
If you are curious, like me, check the question *[Why is \r a newline for Vim?](https://stackoverflow.com/questions/71417/why-is-r-a-newline-for-vim)* as well.
Use `\r` instead of `\n`.
-------------------------
Substituting by `\n` inserts a null character into the text. To get a newline, use `\r`. When *searching* for a newline, you’d still use `\n`, however. This asymmetry is due to the fact that `\n` and `\r` [do slightly different things](http://vim.wikia.com/wiki/Search_and_replace):
`\n` | [
0.12210499495267868,
-0.08139842748641968,
0.5564994812011719,
-0.19409896433353424,
0.10044890642166138,
-0.0034005797933787107,
0.3097786605358124,
-0.0575331375002861,
-0.39534273743629456,
-0.6294671297073364,
-0.316767156124115,
0.6861473321914673,
-0.2655048668384552,
0.2259907871484... | |
matches an end of line (newline), whereas `\r` matches a carriage return. On the other hand, in substitutions `\n` inserts a null character whereas `\r` inserts a newline (more precisely, it’s treated as the input `CR`). Here’s a small, non-interactive example to illustrate this, using the Vim command line feature (in other words, you can copy and paste the following into a terminal to run it). `xxd` shows a hexdump of the resulting file.
```
echo bar > test
(echo 'Before:'; xxd test) > output.txt
vim test '+s/b/\n/' '+s/a/\r/' +wq
(echo 'After:'; xxd test) >> output.txt
more output.txt
```
```
Before:
0000000: 6261 720a | [
0.00884256511926651,
0.04365261644124985,
0.4262073040008545,
-0.24313563108444214,
-0.12352593243122101,
0.3107497990131378,
0.2147345095872879,
-0.6684005856513977,
0.06363785266876221,
-0.4103241562843323,
-0.1786009967327118,
0.2959981858730316,
-0.5219919681549072,
0.2630290687084198,... | |
bar.
After:
0000000: 000a 720a ..r.
```
In other words, `\n` has inserted the byte 0x00 into the text; `\r` has inserted the byte 0x0a. | [
-0.1111365333199501,
0.5256572961807251,
0.4273415803909302,
-0.4517356753349304,
0.21510592103004456,
0.355524480342865,
0.10775547474622726,
-0.16324399411678314,
0.026500722393393517,
-0.5123047828674316,
-0.7595856189727783,
0.12698237597942352,
-0.2908197045326233,
0.04140433669090271... | |
I'm not sure if many people know about this text-editor?
jEdit was kinda big in 2004, but now, Notepad++ seems to have taken the lead(on Windows)
Many of the plugins haven't been updated since 2003 and the overal layout and usage is confusing...
I'm sure jEdit has many nifty features, but I'll be damned if I can find out where to find them and how to use them. Reading that manual is a fulltime job on it's own.
I've been using jEdit for a few years now, mainly on windows, but also on Ubuntu.
I use it for: SQL, awk, batch files, html, xml, javascript...
Just | [
-0.28664830327033997,
0.1424766480922699,
0.45875707268714905,
-0.2140032798051834,
-0.5852316617965698,
-0.09874743968248367,
-0.03526850789785385,
0.012846560217440128,
-0.1391587108373642,
-0.7140320539474487,
0.1127009317278862,
0.9079437255859375,
-0.2041463404893875,
-0.1408988535404... | |
about everything except .NET stuff (for which I use Visual Studio).
I love it.
summary
-------
I use jEdit because it has the right balance for me of **ease of setting up** vs. **features** and **customisability**. For me, no other editor strikes quite as good a balance.
cons
----
* It can be a bit hard to make it do the things you want.
pros
----
* I love the [plugins](http://plugins.jedit.org/list.php)
* Being able to define my own syntax highlighting etc. is just what I want from a text editor.
* The [manual](http://prdownloads.sourceforge.net/jedit/jedit4.3pre15manual-a4.pdf) is very good and quite readable. I strongly suggest reading it through to get an idea | [
0.5489318370819092,
0.12741199135780334,
0.12146775424480438,
0.07669910043478012,
-0.30857983231544495,
-0.17927828431129456,
0.058705445379018784,
0.1592656821012497,
-0.1607891321182251,
-0.7247190475463867,
-0.3073403537273407,
0.8260289430618286,
0.08052853494882584,
-0.47311714291572... | |
of what jEdit can do for you. (In fact, I suggest this for any software you use)
* It's cross-platform. I used it just on windows for a long time, but now I also use Ubuntu, and it works there: I can even copy the configuration files over from my windows machine, and everything works. Nice.
other editors
-------------
In the past I did take a look at **Notepad++**, but that was a while ago, and it didn't have a nice way to define your own syntax highlighting, which is important for me. I also paid for **Textmate** and **UltraEdit** at different times (both | [
0.07843868434429169,
-0.011664892546832561,
0.39217835664749146,
0.02673957496881485,
-0.37152084708213806,
0.106475830078125,
-0.10399424284696579,
-0.009004528634250164,
-0.10027450323104858,
-0.7620360255241394,
-0.059070885181427,
0.777149498462677,
-0.08746644109487534,
-0.28169080615... | |
very good), but in the end, jEdit comes out on top for me.
I also used **Eclipse** for a year or so. It's fantastic, and it'll do anything you want, *but* you have to be really into Eclipse to get the most out of it. | [
0.22902034223079681,
-0.19856716692447662,
0.32423853874206543,
0.1336948126554489,
-0.4156743288040161,
0.3263426721096039,
0.02935800515115261,
0.2615455389022827,
-0.003388555720448494,
-0.39304158091545105,
0.38115859031677246,
0.6693260073661804,
0.418030321598053,
0.04039653018116951... | |
We need to optimize the text rendering for a C# [Windows Forms](http://en.wikipedia.org/wiki/Windows_Forms) application displaying a large number of small strings in an irregular grid. At any time there can be well over 5000 cells visible that update 4 times per second. The font family and size is consistent across the cells, though the color may vary from cell to cell, as will bold/italic/plain.
I've seen conflicting information on the web about `TextRenderer.DrawText` vs. `Graphics.DrawString` being the fastest/best, which reduces to a [GDI](http://en.wikipedia.org/wiki/Graphics_Device_Interface) vs. [GDI+](http://en.wikipedia.org/wiki/Graphics_Device_Interface#GDI.2B) comparison at the [Win32](http://en.wikipedia.org/wiki/Windows_API) level.
I've also seen radically different results on Windows XP vs. Windows Vista, | [
0.24301186203956604,
-0.10473128408193588,
0.4972385764122009,
0.027399856597185135,
-0.10758358985185623,
0.20848584175109863,
-0.03289235755801201,
-0.37624531984329224,
-0.3566770553588867,
-1.0109273195266724,
0.004255249164998531,
0.33383679389953613,
-0.19110816717147827,
0.071773909... | |
but my main target is Windows XP. Articles promising great advances
under [WinFX](http://en.wikipedia.org/wiki/.NET_Framework_3.0#.NET_Framework_3.0) and [DirectX 10](http://en.wikipedia.org/wiki/DirectX#DirectX_10) aren't helpful here :-)
What's the best approach here? I'm not afraid of introducing a small C++/CLI layer and optimizing device context handling to squeeze out more performance, but I'd like some definitive advice about which direction to take.
EDIT:
Thanks for the initial responses. I'll be trying a combination of background bitmap rendering and sticking with the GDI equivalent calls.
A Microsoft developer has posted a [GDI vs. GDI+ Text Rendering Performance](http://blogs.msdn.com/cjacks/archive/2006/05/19/602021.aspx) article on his blog which answers the raw speed question: on his system, GDI DrawText | [
0.12412363290786743,
-0.02990000881254673,
0.5703310370445251,
0.05526214465498924,
-0.3956725597381592,
0.13829493522644043,
0.0021199355833232403,
0.050763584673404694,
-0.07154367119073868,
-0.833416223526001,
-0.1786300390958786,
0.602418065071106,
-0.12527115643024445,
-0.028561094775... | |
was about 6 times faster than GDI+ DrawString.
If you need to be a real speed demon, TextOut is faster than DrawText, but you'll have to take care of clipping and word-wrapping yourself. ExtTextOut supports clipping.
GDI rendering (TextRenderer) will be more consistent with other parts of Windows using GDI; GDI+ tries to be device-independent and so [some spacing and emboldening are inconsistent](http://windowsclient.net/articles/gdiptext.aspx). See the SQL Server 2005 Surface Area Configuration tool for an example of inconsistent rendering. | [
-0.4725956916809082,
-0.3855554461479187,
0.5391236543655396,
0.17766635119915009,
-0.6692736744880676,
0.01304851844906807,
0.5351803302764893,
-0.3436187207698822,
0.17086674273014069,
-0.8924983739852905,
0.038338735699653625,
0.8339840173721313,
-0.3174782693386078,
-0.5042296648025513... | |
Is it really advantageous to move to Rake from ant?
Anyone migrated from ant and find something monumental?
FYI: Current environment is Ant for J2ME builds
I would say yes, but I have a different perspective than a Java-environment guy, because I'm a .NET-environment guy. I had written and maintained a non-trivial build script (clean, generate-assembly-info, build, test, coverage, analysis, package) in msbuild (MS' XML-driven NAnt effort) and it was very painful:
* XML isn't friendly; it's very noisy
* No-one else on the team was interested in learning it to the point of performing more, and more useful, automations; so high bus factor (ie, | [
0.13921251893043518,
0.00881137140095234,
0.08595698326826096,
0.054980069398880005,
-0.2118666023015976,
0.16621389985084534,
0.08693408966064453,
-0.022925013676285744,
-0.02619851380586624,
-0.7790802717208862,
0.38779494166374207,
0.5117604732513428,
-0.1401660144329071,
-0.05931337177... | |
if I get hit by a bus, they're stuck with it)
* It did not lend itself to refactoring or improvement - it was one of those 'touch-at-your-peril' things, you know?
* It needed custom C# tasks to be written to run the various tools the build needed (though to be fair, often these are written by the vendors)
In about a work-week's worth of my time (got to love empty offices at Christmas time!), I've learned enough ruby+rake to replace the whole thing with a shorter (in terms of LOC) script with slightly more functionality, and more understandability (I hope, anyhow; haven't | [
0.3982689380645752,
-0.00031486767693422735,
0.31249627470970154,
0.0036075348034501076,
-0.3694029748439789,
0.24185964465141296,
0.5858917236328125,
0.4767117202281952,
-0.27292168140411377,
-0.4945681095123291,
0.1485195755958557,
0.08802831918001175,
0.050113677978515625,
-0.2585282027... | |
had it reviewed yet).
It benefits from:
- It's a new language, but a real language. My team-mates like learning new languages, and this, while a thin excuse, is still an excuse ;-) This might mitigate the bus-factor if I'm right.
- It's a short hop (I gather) from here to capistrano, the automated/remote/distributed deployment tool from the RoR world. Despite being an MS-stack shop, we're gonna be using that in combination with IIS7 finally having a CLI config tool.
So, yeah. Your mileage may vary, but it was worth it for me. | [
0.3490164279937744,
0.011258871294558048,
0.5746183395385742,
0.22790634632110596,
0.6077297925949097,
0.13900093734264374,
0.43053701519966125,
0.5777323842048645,
-0.3423829972743988,
-0.598998486995697,
-0.15719759464263916,
0.45347729325294495,
0.2543714940547943,
-0.2904147207736969,
... | |
From question *[How to replace a character for a newline in Vim?](https://stackoverflow.com/questions/71323/how-to-replace-a-character-for-a-newline-in-vim)*. You have to use \r when replacing text for a newline, like this
```
:%s/%/\r/g
```
But when replacing end of lines and newlines for a character, you can do it like:
```
:%s/\n/%/g
```
What section of the manual documents these behaviors, and what's the reasoning behind them?
From [vim docs on patterns](http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5Cr):
> `\r` matches <CR>
>
>
> `\n` matches an end-of-line -
> When matching in a string instead of
> buffer text a literal newline
> character is matched. | [
0.20774361491203308,
-0.2671896517276764,
0.45945611596107483,
0.08032476156949997,
-0.023978395387530327,
-0.0012148405658081174,
0.15909114480018616,
-0.37319326400756836,
-0.0913311094045639,
-0.6775515079498291,
-0.2686048448085785,
0.6157676577568054,
-0.49516046047210693,
-0.19632418... | |
Let's assume we've got the following Java code:
```
public class Maintainer {
private Map<Enum, List<Listener>> map;
public Maintainer() {
this.map = new java.util.ConcurrentHashMap<Enum, List<Listener>>();
}
public void addListener( Listener listener, Enum eventType ) {
List<Listener> listeners;
if( ( listeners = map.get( eventType ) ) == null ) {
listeners = new java.util.concurrent.CopyOnWriteArrayList<Listener>();
map.put( eventType, listeners );
} | [
0.354951947927475,
0.05864271521568298,
0.4445810914039612,
-0.28437158465385437,
0.011527693830430508,
-0.16179561614990234,
0.5674020648002625,
-0.5361291170120239,
-0.36020734906196594,
-0.6627901196479797,
-0.34612715244293213,
0.8375076651573181,
-0.23918506503105164,
0.33630648255348... | |
listeners.add( listener );
}
}
```
This code snippet is nothing but a bit improved listener pattern where each listener is telling what type of event it is interested in, and the provided method maintains a concurrent map of these relationships.
Initially, I wanted this method to be called via my own annotation framework, but bumped into a brick wall of various annotation limitations (e.g. you can't have *java.lang.Enum* as annotation param, also there's a set of various classloader issues) therefore decided to use Spring.
Could anyone tell me how do I Spring\_ify\_ this? What I want to | [
0.4759456217288971,
0.10360842943191528,
0.14486649632453918,
-0.24509024620056152,
-0.10820744931697845,
-0.1022992953658104,
0.1689145714044571,
-0.16307857632637024,
-0.31239351630210876,
-0.3049241900444031,
0.1560649424791336,
0.5889073610305786,
-0.375103622674942,
0.0644125938415527... | |
achive is:
1. Define *Maintainer* class as a Spring bean.
2. Make it so that all sorts of listeners would be able to register themselves to *Maintainer* via XML by using *addListener* method. Spring doc nor Google are very generous in examples.
Is there a way to achieve this easily?
What would be wrong with doing something like the following:
Defining a 'Maintainer' interface with the addListener(Listener, Enum) method.
Create a DefaultMaintainer class (as above) which implements Maintainer.
Then, in each Listener class, 'inject' the Maintainer interface (constructor injection might be a good choice). The listener can then register itself with the Maintainer.
other | [
0.2693205773830414,
-0.1018899604678154,
0.29809051752090454,
0.08660662174224854,
-0.29216206073760986,
-0.16965550184249878,
0.19525904953479767,
-0.29149383306503296,
0.18303819000720978,
0.015000199899077415,
-0.0265422984957695,
0.8659713864326477,
-0.33381858468055725,
0.006536730099... | |
than that, I'm not 100% clear on exactly what your difficulty is with Spring at the moment! :) | [
-0.07577042281627655,
-0.21089404821395874,
-0.10000446438789368,
0.20256167650222778,
-0.14833924174308777,
0.17345048487186432,
0.4899292588233948,
-0.0929117202758789,
-0.4216116666793823,
-0.08558715134859085,
0.19219407439231873,
0.329287052154541,
-0.07779420912265778,
-0.06218952685... | |
I've currently got a set of reports with a number of common functions sitting in code blocks within the .rdl files. This obviously presents a maintainability issue and I as wondering if anyone knew a way for these different reports to share a library of common code?
Ideally I'd like to have a .Net Assembly attached to my Reporting Services project, which all of my reports can access and call functions from. This would save the headache of trying to update and redeploy about 100 reports every time a change needs to be made to a common function.
Any suggestions?
From within Visual | [
0.7184188961982727,
0.14664949476718903,
0.22527602314949036,
0.2229737490415573,
-0.15751664340496063,
-0.09566840529441833,
0.09360945224761963,
-0.13859529793262482,
-0.3938175439834595,
-0.681031346321106,
0.08731933683156967,
0.5610111355781555,
-0.10495899617671967,
0.169817775487899... | |
Studio in the properties of the report, on the 'References' tab add the details for the assembly that contains the managed code. This code can be called from expressions within reports using the instance name that is specified.
This assembly can either be stored in the GAC or the PrivateAssemblies directory of Visual Studio, and be deployed to the Report Service 'bin' directory on the Reporting Services server. For more information refer to [How to use custom assemblies or embedded code in Reporting Services](http://support.microsoft.com/kb/920769) | [
0.8298396468162537,
0.2452555000782013,
-0.12679798901081085,
-0.02754336968064308,
-0.29918110370635986,
0.010832556523382664,
0.1338060051202774,
-0.2984805703163147,
-0.19828066229820251,
-0.4060046374797821,
-0.2892242968082428,
0.39237961173057556,
-0.07060642540454865,
-0.14464397728... | |
The [win32.perl.org](http://win32.perl.org/) web site provides references to several Perl distributions for MS Windows.
For a long time I have been using ActivePerl from
[ActiveState](http://www.activestate.com/) but recently I switched to
[Strawberry Perl](http://strawberryperl.com/).
IMHO The only advantage that Active Perl still has over Strawberry Perl is the fact that it comes with Perl Tk which means its easy to install
[Devel::ptkdb](http://search.cpan.org/dist/Devel-ptkdb/) the graphical debugger. Other than that, I think Strawberry Perl has all the advantages.
[Strawberry Perl](http://strawberryperl.com/) is just getting better and better. One problem I've repeatedly had with ActiveState is that my modules sometimes fail to install because I need an upgrade to a | [
0.25284019112586975,
-0.09932349622249603,
0.3611743450164795,
-0.10575806349515915,
-0.3867652714252472,
0.02750936523079872,
0.24940204620361328,
0.2759481370449066,
-0.28088030219078064,
-0.3886358141899109,
0.12850874662399292,
0.5622943043708801,
-0.14785760641098022,
0.29500457644462... | |
core module, but they won't allow that. Thus, everybody who *doesn't* use Windows can use my code, but they can't do that with ActiveState's Perl.
ActiveState also has a very dodgy build system which often fails to report exactly why a module failed to build. I got so tired of emailing and asking for this information that I eventually gave up. I want my code to run on Windows, but if ActiveState doesn't provide me with that information and doesn't give me any option for upgrading core modules, I just can't use it. Some of my modules have NO build failures | [
0.6026507616043091,
0.3060075342655182,
0.23601533472537994,
-0.14559951424598694,
0.12733003497123718,
-0.08366914838552475,
0.602815568447113,
0.024776631966233253,
-0.07175475358963013,
-0.5811659693717957,
-0.1301785707473755,
0.44978347420692444,
-0.31968310475349426,
0.33662188053131... | |
on any operating system -- except those with ActiveState Perl. Support Strawberry Perl and just don't worry about ActiveState.
If ActiveState has fixed their build system and their 'no upgrade to core modules' policy, it's worth revisiting. | [
0.31269025802612305,
-0.024674365296959877,
0.1612628698348999,
0.025995343923568726,
-0.006466612685471773,
-0.07914069294929504,
0.43624040484428406,
0.575228214263916,
-0.20927196741104126,
-0.31808745861053467,
-0.29520222544670105,
0.41667088866233826,
-0.2851177155971527,
-0.05787714... | |
I have a database in ISO-8859-2 format, but I need to create XML in UTF-8. This means that I must encode the database before prinitng in UTF-8. I know very little about ASP.Net, so I'm hoping someone can help.
In PHP I would do something like this:
```
db_connect();
mysql_query("SET NAMES 'UTF8'");
mysql_query("SET character_set_client='UTF8'");
```
This is my ASP.Net code for database connection:
```
'CONNECTION TO DATABASE
dim dbconn,sql,dbcomm
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("../baze/test.mdb"))
dbconn.Open()
sql="SELECT * FROM nekretnine, tipovinekretnina WHERE nekretnine.idtipnekretnine = tipovinekretnina.idtipnekretnine ORDER BY nekretnine.idnekretnine"
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteReader() | [
-0.0011883655097335577,
0.11119498312473297,
0.5329967737197876,
0.06545697897672653,
-0.20153722167015076,
-0.027038710191845894,
0.31205058097839355,
-0.36079710721969604,
-0.19300948083400726,
-0.738202691078186,
-0.01788783073425293,
0.4562743008136749,
-0.20835348963737488,
0.44226530... | |
while dbread.Read()
```
Where and how do I encode to UTF-8?
Assuming you have a value string in `str`, this is the pure-.NET way of doing this.
```
var encoding = System.Text.Encoding.GetEncoding("iso-8859-2");
var bytes = System.Text.Encoding.Convert(encoding, System.Text.Encoding.Default, encoding.GetBytes(str));
var newString = System.Text.Encoding.Default.GetString(bytes);
``` | [
0.1600281000137329,
0.12778815627098083,
0.37675848603248596,
-0.14539018273353577,
-0.10077395290136337,
-0.06644453853368759,
0.41183358430862427,
-0.26205626130104065,
0.13696298003196716,
-0.8011389970779419,
-0.40111032128334045,
0.4512978792190552,
-0.43397748470306396,
0.11099144071... | |
With this code I can show an animated gif while the server script is running:
```
function calculateTotals() {
$('#results').load('getResults.php', null, showStatusFinished);
showLoadStatus();
}
function showLoadStatus() {
$('#status').html('');
}
function showStatusFinished() {
$('#status').html('Finished.');
}
```
However, I would like to display a status of how far along the script is, e.g. "Processing line 342 of 20000..." and have it count up until it is finished.
How can I do that? I can make a server-script which constantly contains the updated information but where do I put the command to read this, say, every second?
After reading your comments to | [
0.2416008561849594,
-0.1738692969083786,
0.8407797813415527,
-0.0940767377614975,
0.025088168680667877,
0.04552726447582245,
0.2364918291568756,
-0.024828938767313957,
-0.18051820993423462,
-0.6673885583877563,
0.2771648168563843,
0.35037678480148315,
-0.09347157180309296,
-0.0247921571135... | |
Andrew's answer.
You would read the status like this:
```
function getStatus() {
$.getJSON("/status.php",{"session":0, "requestID":12345},
function(data) { //data is the returned JSON object from the server {name:"value"}
setStatus(data.status);
window.setTimeout("getStatus()",intervalInMS)
});
}
```
Using this method you can open several simultaneous XHR request on the server.
all your status.php as to output is :
```
{"status":"We are done row 1040/45983459"}
```
You can however output as many information you want in the response and to process it accordingly (feeding a progress bar for example | [
0.030727164819836617,
-0.14097003638744354,
0.8971845507621765,
0.12192954123020172,
0.04936683177947998,
0.2008403241634369,
0.37500473856925964,
-0.36543408036231995,
-0.2942177951335907,
-0.536346435546875,
-0.3505150377750397,
0.1868227869272232,
-0.2829299867153168,
0.0474739521741867... | |
or performing an animation..)
For more information on $.getJSON see <http://docs.jquery.com/Ajax/jQuery.getJSON> | [
0.17095360159873962,
-0.20504212379455566,
0.08885972946882248,
0.3138415813446045,
-0.09402647614479065,
0.05782045051455498,
0.2526451349258423,
0.29622218012809753,
-0.5458846092224121,
-0.5600098967552185,
-0.48819464445114136,
0.5382393002510071,
0.10980323702096939,
-0.46331116557121... | |
I'm building small web site in Java (Spring MVC with JSP views) and am trying to find best solution for making and including few reusable modules (like "latest news" "upcoming events"...).
So the question is: Portlets, tiles or some other technology?
If you are using Spring MVC, then I would recommend using Portlets. In Spring, portlets are just lightweight controllers since they are only responsible for a fragment of the whole page, and are very easy to write. If you are using Spring 2.5, then you can enjoy all the benefits of the new annotation support, and they fit nicely in the | [
-0.04488058015704155,
-0.2424803227186203,
0.4786362051963806,
0.2374860942363739,
-0.02212352119386196,
-0.41449040174484253,
-0.041897255927324295,
-0.05945560708642006,
-0.425584077835083,
-0.859219491481781,
-0.23045256733894348,
0.33578822016716003,
-0.12065305560827255,
-0.0140554495... | |
whole Spring application with dependency injection and the other benefits of using Spring.
A portlet controller is pretty much the same as a servlet controller, here is a simple example:
```
@RequestMapping("VIEW")
@Controller
public class NewsPortlet {
private NewsService newsService;
@Autowired
public NewsPortlet(NewsService newsService) {
this.newsService = newsService;
}
@RequestMapping(method = RequestMethod.GET)
public String view(Model model) {
model.addAttribute(newsService.getLatests(10));
return "news"; | [
0.08339273184537888,
-0.6601365804672241,
0.5536980628967285,
0.07817569375038147,
-0.03159801661968231,
-0.055593494325876236,
-0.02734639309346676,
-0.3217822015285492,
-0.4297438859939575,
-0.3748852014541626,
-0.3035734295845032,
0.5935934782028198,
-0.4722719192504883,
0.2694987058639... | |
}
}
```
Here, a NewsService will be automatically injected into the controller. The view method adds a List object to the model, which will be available as ${newsList} in the JSP. Spring will look for a view named news.jsp based on the return value of the method. The RequestMapping tells Spring that this contoller is for the VIEW mode of the portlet.
The XML configuration only needs to specify where the view and controllers are located:
```
<!-- look for controllers and services here -->
<context:component-scan base-package="com.example.news"/>
<!-- look for views here -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/news/"/> | [
0.07578030228614807,
-0.13084812462329865,
0.6793986558914185,
-0.07308072596788406,
-0.02181645669043064,
0.0805027112364769,
-0.22358955442905426,
-0.10162635892629623,
-0.3915252685546875,
-0.5488379597663879,
-0.31078898906707764,
0.48041877150535583,
-0.22958700358867645,
0.0903632566... | |
<property name="suffix" value=".jsp"/>
</bean>
```
If you want to simply embed the portlets in your existing application, the you can bundle a portlet container, such as [eXo](http://www.exoplatform.com), [Sun](https://portlet-container.dev.java.net/), or [Apache](http://portals.apache.org/pluto/). If you want to build your application as a set of portlets, the you might want to consider a full blown portlal solution, such as [Liferay Portal](http://liferay.com). | [
0.30655384063720703,
-0.08038773387670517,
0.625510036945343,
-0.015489611774682999,
-0.013326120562851429,
-0.15805460512638092,
-0.06653960049152374,
0.009602266363799572,
-0.42064782977104187,
-0.848160982131958,
-0.313594251871109,
0.3057727515697479,
-0.14844639599323273,
0.4813749492... | |
If I remove all the ' characters from a SQL query, is there some other way to do a SQL injection attack on the database?
How can it be done? Can anyone give me examples?
Yes, there is. An excerpt from [Wikipedia](http://en.wikipedia.org/wiki/SQL_injection)
`"SELECT * FROM data WHERE id = " + a_variable + ";"`
It is clear from this statement that the author intended a\_variable to be a number correlating to the "id" field. However, if it is in fact a string then the end user may manipulate the statement as they choose, thereby bypassing the need for escape characters. For example, setting a\_variable | [
0.20785082876682281,
0.04259476438164711,
-0.010569315403699875,
-0.20733392238616943,
-0.07747885584831238,
0.1779165416955948,
0.3549327552318573,
-0.28272566199302673,
0.013550451956689358,
-0.24884818494319916,
-0.2254500389099121,
0.5240792632102966,
-0.520350992679596,
0.163734957575... | |
to
`1;DROP TABLE users`
will drop (delete) the "users" table from the database, since the SQL would be rendered as follows:
`SELECT * FROM DATA WHERE id=1;DROP TABLE users;`
SQL injection is *not* a simple attack to fight. I would do very careful research if I were you. | [
0.3554108738899231,
0.03594280406832695,
0.2194700688123703,
-0.11425589770078659,
0.1081809401512146,
-0.03476198390126228,
0.09496571123600006,
-0.2363916039466858,
-0.2194138616323471,
-0.3050980865955353,
-0.24393664300441742,
0.5594184994697571,
-0.6930573582649231,
0.0986174419522285... | |
I have to read data from some files and insert the data into different tables in a database. Is Unix shell script powerful enough to do the job?
Is it easy to do the job in shell script or should I go about doing this in Java?
If the data you are trying to import is in a reasonable format -- comma-delimited, for example -- and your database server has reasonable command line utilities, this should be no problem. MySQL has the "mysqlimport" command-line tool that will accept various arguments describing the format of the file:
```sh
mysqlimport \
--fields-terminated-by=, \ | [
0.2312595695257187,
0.1317107081413269,
0.4732934534549713,
-0.007784359157085419,
0.05295787379145622,
-0.21223950386047363,
0.015574310906231403,
-0.23304645717144012,
0.055941250175237656,
-0.500831663608551,
0.02399381995201111,
0.7933477759361267,
-0.08294647932052612,
-0.078392200171... | |
--ignore-lines=1 \
--fields-optionally-enclosed-by='"' < datafile.txt
```
Passing the data through perl/sed/awk one-liners can help with getting it in the proper format, and the shell script can easily handle prompting for filenames, handling arguments, etc.
Using the various command-line tools provided by Unix is the entire point of bash scripting. Perl, mysql, etc. are all part of that toolkit. | [
0.26773327589035034,
0.08262860774993896,
0.25444915890693665,
-0.13571128249168396,
-0.18122214078903198,
-0.1681179404258728,
0.1529422551393509,
-0.05248146876692772,
-0.35882481932640076,
-0.40264061093330383,
-0.3123798668384552,
0.829508900642395,
-0.16231653094291687,
-0.19902808964... | |
I have 16,000 jpg's from a webcan screeb grabber that I let run for a year pointing into the back year. I want to find a way to grab every 4th image so that I can then put them into another directory so I can later turn them into a movie. Is there a simple bash script or other way under linux that I can do this.
They are named like so......
frame-44558.jpg
frame-44559.jpg
frame-44560.jpg
frame-44561.jpg
Thanks from a newb needing help.
---
Seems to have worked.
Couple of errors in my origonal post. There were actually 280,000 images and the naming was.
/home/baldy/Desktop/webcamimages/webcam\_2007-05-29\_163405.jpg
/home/baldy/Desktop/webcamimages/webcam\_2007-05-29\_163505.jpg
/home/baldy/Desktop/webcamimages/webcam\_2007-05-29\_163605.jpg
I ran.
cp $(ls | awk '{nr++; if | [
0.4265983998775482,
0.22522325813770294,
0.8527037501335144,
0.1599792093038559,
-0.29289254546165466,
0.24840512871742249,
0.3129412829875946,
-0.025966357439756393,
-0.595085084438324,
-0.29944369196891785,
0.07179182767868042,
0.2888341248035431,
-0.036831311881542206,
0.150031149387359... | |
(nr % 10 == 0) print $0}') ../newdirectory/
Which appears to have copied the images. 70-900 per day from the looks of it.
Now I'm running
mencoder mf://\*.jpg -mf w=640:h=480:fps=30:type=jpg -ovc lavc -lavcopts vcodec=msmpeg4v2 -nosound -o ../output-msmpeg4v2.avi
I'll let you know how the movie works out.
UPDATE: Movie did not work.
Only has images from 2007 in it even though the directory has 2008 as well.
webcam\_2008-02-17\_101403.jpg webcam\_2008-03-27\_192205.jpg
webcam\_2008-02-17\_102403.jpg webcam\_2008-03-27\_193205.jpg
webcam\_2008-02-17\_103403.jpg webcam\_2008-03-27\_194205.jpg
webcam\_2008-02-17\_104403.jpg webcam\_2008-03-27\_195205.jpg
How can I modify my mencoder line so that it uses all the images?
One simple way is:
```
$ touch a b c d e f g h i j k l m n o p | [
0.1821637600660324,
0.20016495883464813,
0.573919415473938,
0.1882098764181137,
-0.01833387464284897,
0.04382399097084999,
0.5593138337135315,
-0.4475509822368622,
-0.4468042850494385,
-0.4842950105667114,
-0.18885819613933563,
0.7010160684585571,
-0.22638726234436035,
0.012478082440793514... | |
q r s t u v w x y z
$ mv $(ls | awk '{nr++; if (nr % 4 == 0) print $0}') destdir
``` | [
0.028038613498210907,
0.0774574726819992,
0.5238540768623352,
-0.41087964177131653,
-0.005818732548505068,
0.35773956775665283,
0.5978181958198547,
-0.4820515215396881,
-0.04779575392603874,
-0.22951561212539673,
-0.3682100176811218,
0.6084574460983276,
-0.2933485209941864,
0.5246691107749... | |
I'm teaching (or trying to teach) computer programming to a grad-student. Her previous experience amounts to little more than writing spreadsheet formulae. Which IDE or text editor should I recommend?
Please bear in mind that:
* I only meet my student about once a week.
* She uses Windows and I use Linux.
* She doesn't have a community of users on hand.
* She doesn't have much money to spend.
---
**Edit:** The languages she's learning at the moment are *Perl* and *R*. (Sorry ... for forgetting to mention them earlier.)
---
**Edit:** Thanks for all your answers!
The most highly recommended editors are *jEdit* and *Notepad++*.
If I can | [
0.30218034982681274,
0.1347070336341858,
0.14189571142196655,
0.4730234444141388,
0.13202551007270813,
0.1755395531654358,
0.09061122685670853,
0.4028454124927521,
-0.1993912011384964,
-0.523534893989563,
-0.09214069694280624,
0.3405153155326843,
0.40352174639701843,
-0.12166290730237961,
... | |
find a way to give my student adequate support for *Notepad++* (e.g. by running it under *Wine*) or if I think that she can manage without support from me, then I'll recommend that. If not, I'll go for *jEdit*.
Apologies, once again, to those who saw the question before I got around to listing the languages that I'm teaching.
Start off simple. Do not not scare her with an IDE! They are overwhelming at first and are not core to developing software. I learnt rudimentary Java with [Crimson Editor](http://www.crimsoneditor.com/).
If I started again I'd probably go for [Notepad++](http://notepad-plus.sourceforge.net/). | [
-0.046629153192043304,
0.08342056721448898,
-0.042109403759241104,
-0.19451484084129333,
-0.3426036834716797,
0.20109869539737701,
0.5860645174980164,
0.058012705296278,
-0.000041645223973318934,
-0.843336284160614,
-0.10061662644147873,
0.8026711344718933,
0.28503507375717163,
-0.36729431... | |
The problem: I have a class which contains a template method `execute` which calls another method `_execute`. Subclasses are supposed to overwrite `_execute` to implement some specific functionality. This functionality should be documented in the docstring of `_execute`.
Advanced users can create their own subclasses to extend the library. However, another user dealing with such a subclass should only use `execute`, so he won't see the correct docstring if he uses `help(execute)`.
Therefore it would be nice to modify the base class in such a way that in a subclass the docstring of `execute` is automatically replaced with that of `_execute`. | [
0.2552710473537445,
0.11142250895500183,
0.009216205216944218,
-0.05028509348630905,
0.20923124253749847,
-0.2514854669570923,
0.2899273633956909,
-0.2512964606285095,
-0.17695195972919464,
-0.5838600397109985,
0.014081998728215694,
0.5542035698890686,
-0.36082199215888977,
0.3552212715148... | |
Any ideas how this might be done?
I was thinking of metaclasses to do this, to make this completely transparent to the user.
Well, if you don't mind copying the original method in the subclass, you can use the following technique.
```
import new
def copyfunc(func):
return new.function(func.func_code, func.func_globals, func.func_name,
func.func_defaults, func.func_closure)
class Metaclass(type):
def __new__(meta, name, bases, attrs):
for key in attrs.keys(): | [
0.1389523446559906,
0.0357716903090477,
0.24158547818660736,
-0.019352642819285393,
0.2170906662940979,
-0.0010457060998305678,
0.08389110863208771,
-0.12708674371242523,
-0.41005611419677734,
-0.5989031791687012,
-0.04119783639907837,
0.8254786133766174,
-0.4690256118774414,
0.29719701409... | |
if key[0] == '_':
skey = key[1:]
for base in bases:
original = getattr(base, skey, None)
if original is not None: | [
0.02321811579167843,
-0.22780518233776093,
0.35936036705970764,
0.030880998820066452,
0.162244975566864,
-0.042124420404434204,
0.16680090129375458,
-0.479979932308197,
-0.1783238798379898,
-0.02958020195364952,
-0.6870087385177612,
0.16220292448997498,
-0.21242743730545044,
-0.07601587474... | |
copy = copyfunc(original)
copy.__doc__ = attrs[key].__doc__
attrs[skey] = copy
break | [
0.05384427309036255,
0.4348072111606598,
0.1831115484237671,
0.1520775705575943,
0.43278294801712036,
-0.2686096131801605,
-0.00015258442726917565,
-0.01058619562536478,
-0.4665924608707428,
-0.10672572255134583,
-0.41941359639167786,
0.663284182548523,
-0.4726487994194031,
0.3565002083778... | |
return type.__new__(meta, name, bases, attrs)
class Class(object):
__metaclass__ = Metaclass
def execute(self):
'''original doc-string'''
return self._execute()
class Subclass(Class):
def _execute(self):
'''sub-class doc-string'''
pass
``` | [
-0.14692026376724243,
-0.023285480216145515,
0.31961551308631897,
-0.19171053171157837,
0.06167539581656456,
0.10010571777820587,
0.49653536081314087,
-0.35466399788856506,
-0.1134033054113388,
-0.45700395107269287,
-0.3377349376678467,
0.5648253560066223,
-0.464598149061203,
0.18379218876... | |
Does anyone know if the Infragistics UltraGrid control provides functionality similar to that of DataGridView.HitTestInfo?
Check [this](http://www.abstraction-systems.com/ttf/HTML/TTFactory_TaskBasedTutorials_UltraWinGrid.htm) out.
They don't convert the coordinates, but they use a special Infragistics grid event ([MouseEnterElement](http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/Infragistics2.Win.v8.2~Infragistics.Win.UltraComponentControlManagerBase~MouseEnterElement_EV.html)) to get the element, which the mouse currently hovers over.
Maybe it helps. | [
0.03584500402212143,
-0.3467932343482971,
0.5455576777458191,
0.26142197847366333,
0.29371777176856995,
-0.21268819272518158,
0.1274510771036148,
-0.37967780232429504,
-0.16476690769195557,
-0.3984522521495819,
0.2014903575181961,
0.5811572670936584,
-0.13874991238117218,
-0.18796709179878... | |
I want to delete all but the 4 newest directories in my parent directory. How would you do this in Bash?
```
ls -atrd */ | head --lines=-4 | xargs rm -rf
```
**Edit:** added 'a' argument to ls | [
0.10003453493118286,
0.4059741497039795,
0.4181379973888397,
-0.2200065404176712,
0.06372508406639099,
-0.006157258525490761,
0.3613942861557007,
-0.2326110452413559,
-0.27038705348968506,
-0.49912920594215393,
-0.28420913219451904,
0.6304987668991089,
-0.3701769709587097,
0.01768043637275... | |
How to implement a website with a recommendation system similar to stackoverflow/digg/reddit? I.e., users submit content and the website needs to calculate some sort of "hotness" according to how popular the item is. The flow is as follows:
* Users submit content
* Other users view and vote on the content (assume 90% of the users only views content and 10% actively votes up or down on content)
* New content is continuously submitted
How do I implement an algorithm that calculates the "hotness" of a submitted item, preferably in real-time? Are there any best-practices or design patterns?
I would assume that the algorithm takes | [
0.17922478914260864,
-0.0331803523004055,
0.3936501145362854,
0.2918175756931305,
-0.2756529748439789,
-0.15381000936031342,
0.014995343051850796,
-0.09223755449056625,
-0.09103728085756302,
-0.328310489654541,
-0.09882189333438873,
0.3463438153266907,
-0.2526772618293762,
-0.1914559900760... | |
the following into consideration:
* When an item was submitted
* When each vote was cast
* When the item was viewed
E.g. an item that gets a constant trickle of votes would stay somewhat "hot" constantly while an item that receives a burst of votes when it is first submitted will jump to the top of the "hotness"-list but then fall down as the votes stop coming in.
(I am using a MySQL+PHP but I am interested in general design patterns).
You could use something similar to the [Reddit algorithm](http://redflavor.com/reddit.cf.algorithm.png) - the basic principle of which is you compute a value for a post based | [
0.2554807960987091,
-0.30439189076423645,
0.17853441834449768,
0.48260173201560974,
-0.4736863374710083,
0.017864201217889786,
0.1664648801088333,
-0.09523813426494598,
-0.3682398796081543,
-0.36395642161369324,
0.06600241363048553,
0.17300069332122803,
-0.29912272095680237,
-0.01496940758... | |
on the time it was posted and the score. What's neat about the Reddit algorithm is that you only need recompute the value when the score of a post changes. When you want to display your front page, you just get the top n posts from your database based on that score. As time goes on the scores will naturally increase, so you don't have to do any special processing to remove items from the front page. | [
0.5535458326339722,
-0.26325640082359314,
0.3287203013896942,
0.3541952669620514,
-0.2965095043182373,
-0.18372200429439545,
0.0995592400431633,
0.24280484020709991,
-0.4554761052131653,
-0.45333606004714966,
0.2949904799461365,
0.14575603604316711,
-0.14284123480319977,
0.0744008496403694... | |
How can I copy a line 10 times easily in Emacs? I can't find a copy-line shortcut or function. I can use C-aC-spcC-eM-w to laboriously copy the line but how can I then paste it more than once?
Any ideas before I go and write my own functions.
**Copying**:
If you frequently work with lines, you might want to make copy (`kill-ring-save`) and cut (`kill-region`) work on lines when no region is selected:
```
(defadvice kill-ring-save (before slickcopy activate compile)
"When called interactively with no active region, copy a single line instead."
(interactive
(if mark-active (list (region-beginning) (region-end)) | [
0.46935051679611206,
-0.1832030862569809,
0.5229524970054626,
0.3221484124660492,
0.07725143432617188,
0.04779955744743347,
0.35933035612106323,
-0.08738524466753006,
-0.33799782395362854,
-0.878834068775177,
0.0424061194062233,
0.5973519086837769,
-0.21956098079681396,
-0.1469102650880813... | |
(list (line-beginning-position)
(line-beginning-position 2)))))
(defadvice kill-region (before slickcut activate compile)
"When called interactively with no active region, kill a single line instead."
(interactive
(if mark-active (list (region-beginning) (region-end))
(list (line-beginning-position)
(line-beginning-position 2)))))
```
Then you can copy the line with just M-w.
**Pasting**:
Often a prefix argument just performs an action multiple times, so you'd expect C-u 10 C-y to work, but in this case C-y uses its argument to mean which element of the kill-ring | [
0.4361392557621002,
-0.163968026638031,
0.5197749733924866,
-0.06187281012535095,
-0.2645826041698456,
0.0021066993940621614,
0.42787012457847595,
-0.4483700096607208,
-0.0649622455239296,
-0.2567538022994995,
-0.2747575640678406,
0.6047065854072571,
-0.2837202548980713,
-0.138496577739715... | |
to "yank" (paste). The only solution I can think of is what kronoz says: record a macro with C-x ( C-y C-x ) and then let the argument of C-u go to `kmacro-end-and-call-macro` instead (that's C-u 9 C-x e or even just C-9 C-x e or M-9 C-x e).
**Another way**:
You can also just stay in `M-x viper-mode` and use yy10p :) | [
0.18258868157863617,
-0.1223469078540802,
0.33124497532844543,
0.22378115355968475,
0.12922725081443787,
0.02838042564690113,
0.4035951495170593,
0.02625254914164543,
-0.47771763801574707,
-0.1573249101638794,
-0.002568704541772604,
0.8559974431991577,
-0.4633813500404358,
0.16964875161647... | |
Given the following example, why do I have to explicitly use the statement `b->A::DoSomething()` rather than just `b->DoSomething()`?
Shouldn't the compiler's overload resolution figure out which method I'm talking about?
I'm using Microsoft VS 2005. (Note: using virtual doesn't help in this case.)
```
class A
{
public:
int DoSomething() {return 0;};
};
class B : public A
{
public:
int DoSomething(int x) {return 1;};
};
int main()
{
B* b = new B();
b->A::DoSomething(); //Why this?
//b->DoSomething(); //Why not this? (Gives compiler error.)
delete b;
return 0;
}
```
The two “overloads” aren't in | [
0.29994621872901917,
-0.014978150837123394,
0.217116579413414,
-0.27072960138320923,
-0.1814814954996109,
-0.019192133098840714,
0.5596343874931335,
-0.5334250330924988,
-0.11270370334386826,
-0.46282336115837097,
-0.027051452547311783,
0.6406821012496948,
-0.504726767539978,
0.29885104298... | |
the same scope. By default, the compiler only considers the smallest possible name scope until it finds a name match. Argument matching is done *afterwards*. In your case this means that the compiler sees `B::DoSomething`. It then tries to match the argument list, which fails.
One solution would be to pull down the overload from `A` into `B`'s scope:
```
class B : public A {
public:
using A::DoSomething;
// …
}
``` | [
0.030340243130922318,
0.06104232743382454,
0.000053441144700627774,
-0.25104689598083496,
-0.003781265113502741,
-0.13713042438030243,
0.27777355909347534,
-0.34946349263191223,
-0.0726347342133522,
-0.6092941164970398,
-0.13235250115394592,
0.6424007415771484,
-0.6069394946098328,
0.19720... | |
How do I find out which sound files the user has configured in the control panel?
Example: I want to play the sound for "Device connected".
Which API can be used to query the control panel sound settings?
I see that there are some custom entries made by third party programs in the control panel dialog, so there has to be a way for these programs to communicate with the global sound settings.
Edit: Thank you. I did not know that PlaySound also just played appropriate sound file when specifying the name of the registry entry.
To play the "Device Conntected" sound:
```
::PlaySound( TEXT("DeviceConnect"), NULL, SND_ALIAS|SND_ASYNC | [
0.12263944000005722,
0.1996092051267624,
0.5632027983665466,
0.2339678853750229,
0.3302980065345764,
-0.3203599452972412,
-0.01123268622905016,
-0.18390049040317535,
-0.2556573748588562,
-0.6003659963607788,
0.027553826570510864,
1.158618688583374,
-0.0589151456952095,
0.29271212220191956,... | |
);
```
[`PlaySound`](https://learn.microsoft.com/en-us/previous-versions/ms712879(v=vs.85)) is the API.
Also see [Play System Sounds](https://learn.microsoft.com/en-us/windows/win32/multimedia/using-playsound-to-play-system-sounds). | [
0.14218996465206146,
-0.16037921607494354,
0.5688857436180115,
-0.06296902894973755,
0.4141371548175812,
0.02758793532848358,
-0.13878236711025238,
-0.12542295455932617,
-0.19116465747356415,
-0.26415154337882996,
-0.3371686637401581,
0.9952770471572876,
-0.3358520269393921,
0.124188072979... | |
LINQ simplifies database programming no doubt, but does it have a downside? Inline SQL requires one to communicate with the database in a certain way that opens the database to injections. Inline SQL must also be syntax-checked, have a plan built, and then executed, which takes precious cycles. Stored procedures have also been a rock-solid standard in great database application programming. Many programmers I know use a data layer that simplifies development, however, not to the extent LINQ does. Is it time to give up on the SP's and go LINQ?
LINQ to SQL actually presents some alarming performance problems in | [
0.1356251835823059,
0.3127267360687256,
0.5506435632705688,
0.4341598153114319,
-0.20903511345386505,
-0.5405716896057129,
0.18077589571475983,
-0.29712605476379395,
-0.02472502738237381,
-0.343578577041626,
0.38932129740715027,
0.6657759547233582,
-0.3873470425605774,
-0.3989003598690033,... | |
the database. Basically, it creates multiple execution plans based on the length of the parameter you are using. I posted about it a while back on my blog [LINQ to SQL may cause performance problems](http://facility9.com/2008/08/28/linq-to-sql-may-cause-performance-problems/).
Now, is that to say that LINQ doesn't have a place? Hardly. LINQ definitely has a place in the development toolkit, just like stored procedures. Ultimately, you want to use stored procedures when performance is absolutely necessary and use an ORM tool in any other situation.
As far as inline SQL goes, there are ways to execute inline SQL so that the plan is only built | [
0.4285680651664734,
0.17808032035827637,
0.23770815134048462,
0.3687269985675812,
0.01579585298895836,
-0.10388077050447464,
-0.061271101236343384,
-0.10845815390348434,
-0.22393302619457245,
-0.23227229714393616,
0.22487743198871613,
0.5715506076812744,
-0.36079779267311096,
-0.1508156955... | |
once and is never recompiled. Most ORMs should take care of this aspect of performance tuning as well and using these methods is usually the safest way to execute your SQL since it forces you to use parameterized queries.
Like most database solutions, the right answer depends on the problem you're trying to solve. If you favor development speed over database/application performance, then using LINQ or another DAL/ORM tool is the best way to go. If you favor performance over ease of development, then using stored procedures and pure datasets is going to be your best bet. LLBLGen even provides a | [
0.2993330657482147,
0.11252827197313309,
0.3632637560367584,
0.3333144783973694,
0.23852528631687164,
-0.19498001039028168,
-0.043267957866191864,
-0.0592188723385334,
-0.2991543710231781,
-0.6482676863670349,
-0.029325775802135468,
0.61058109998703,
-0.032948654145002365,
0.11101659387350... | |
LINQ to LLBLGen layer so you can use LINQ to query LLBLGen's objects and have LLBLGen actually handle building your queries and avoid some of the downfalls of LINQ. | [
-0.3399926722049713,
-0.16941888630390167,
1.067240595817566,
0.2937885820865631,
-0.10188372433185577,
-0.4610312581062317,
-0.2634967863559723,
-0.19440831243991852,
0.020993400365114212,
-0.8331237435340881,
-0.19383229315280914,
0.5337631702423096,
-0.1700117141008377,
-0.2804163396358... | |
This seemed like an easy thing to do. I just wanted to pop up a text window and display two columns of data -- a description on the left side and a corresponding value displayed on the right side. I haven't worked with Forms much so I just grabbed the first control that seemed appropriate, a TextBox. I thought using tabs would be an easy way to create the second column, but I discovered things just don't work that well.
There seems to be two problems with the way I tried to do this (see below). First, I read on numerous | [
0.34404295682907104,
0.10818678140640259,
0.17146119475364685,
0.44297096133232117,
-0.04249244183301926,
0.22413943707942963,
-0.1419256329536438,
-0.00009313497866969556,
-0.022420687600970268,
-0.6689237952232361,
0.43350258469581604,
0.2901783585548401,
-0.3092750012874603,
0.059126410... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.