text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
What is the correct way to call unmanaged code such as a COM API through .Net interop from a code that is being executed in a partially trusted environment?
While developing an ASP.Net WebPart for Microsoft SharePoint I had to communicate with another system through its COM API. I solved this issue temporarily by chan... | [
0.2981443703174591,
0.11989012360572815,
0.22260497510433197,
0.08074332773685455,
-0.09144222736358643,
-0.044529661536216736,
0.2309402972459793,
-0.2085374891757965,
-0.2888020873069763,
-0.5151046514511108,
0.05008222162723541,
0.7300379276275635,
-0.2633446753025055,
0.155267149209976... | |
probably need a fully trusted assembly which allows partially trusted callers and acts as a layer between the managed and unmanaged domains. Also I'd imagine there is a need for some extra settings which allow the partially trusted code call fully trusted code without the fully trusted code suffering from the permissio... | [
0.49169638752937317,
0.07119377702474594,
0.06676069647073746,
0.29093167185783386,
-0.0032458510249853134,
-0.26405441761016846,
0.4093165993690491,
-0.08985128998756409,
0.004564258269965649,
-0.6423553824424744,
-0.1055004820227623,
0.9093663692474365,
-0.10766755789518356,
-0.209766849... | |
code or operate from a partially trusted context, you should consider the following factors:
* Libraries must be signed with a strong name in order to be shared by multiple applications. Strong names allow your code to be placed in the global assembly cache and allow consumers to verify that a particular piece of mobi... | [
0.4225069284439087,
0.3038385212421417,
0.016196701675653458,
0.26682794094085693,
-0.0029782624915242195,
-0.15872237086296082,
0.6930874586105347,
-0.10935954749584198,
-0.010468627326190472,
-0.38801923394203186,
-0.41897210478782654,
0.2297702431678772,
-0.3890635073184967,
0.183156877... | |
SecurityException and the caller is not allowed to link to the library.
* In order to disable the automatic LinkDemand and prevent the exception from being thrown, you can place the AllowPartiallyTrustedCallersAttribute attribute on the assembly scope of a shared library. This attribute allows your libraries to be call... | [
0.11111703515052795,
-0.1118202731013298,
0.26010242104530334,
0.19066698849201202,
-0.06979706883430481,
-0.4247128367424011,
0.4938490092754364,
-0.16358916461467743,
-0.13675406575202942,
-0.4443758726119995,
-0.2586241662502289,
0.5321645140647888,
-0.3008809983730316,
0.23146836459636... | |
does not receive full trust by default, an administrator must choose to modify security policy and grant the application full trust before it can call such a library.
Source:
[MSDN: Using Libraries from Partially Trusted Code](http://msdn.microsoft.com/en-us/library/8skskf63(VS.71).aspx) | [
0.07282460480928421,
-0.07394082844257355,
0.15431998670101166,
0.24674783647060394,
0.2005528211593628,
-0.5638823509216309,
0.4833618700504303,
-0.07926573604345322,
-0.2325168251991272,
-0.13291294872760773,
-0.4501053988933563,
0.1353188008069992,
-0.33910226821899414,
0.04853843152523... | |
I've created a simple parameterless stored procedure which I've pasted below. I've imported the stored procedure to my Entity Model and created a Function Import. The function in the model is never created and I am unable to execute this stored procedure using the ADO.NET Entity Framework. I've opened the .edmx file in... | [
0.19755031168460846,
0.21673060953617096,
0.2733941674232483,
0.04895949363708496,
0.02236959896981716,
-0.13076286017894745,
0.39625421166419983,
-0.12220752239227295,
-0.07007662951946259,
-0.44531747698783875,
0.22474360466003418,
0.7806869149208069,
-0.5203554630279541,
0.2391759157180... | |
procedure does not need to return any recordsets or values.
Stored Procedure:
```
ALTER PROC [dbo].[Inventory_Snapshot_Create]
AS
SET NOCOUNT ON
DECLARE @Inventory_Snapshot_ID int
INSERT INTO Inventory_Snapshots (snapshot_timestamp)
VALUES (GETDATE())
SET @Inventory_Snapshot_ID = SCOPE_IDENTITY()
INSERT INTO In... | [
0.3323213458061218,
0.032655876129865646,
0.35816192626953125,
0.13207410275936127,
0.023179572075605392,
0.2042822241783142,
0.052321214228868484,
-0.31928929686546326,
-0.18780294060707092,
-0.40361925959587097,
-0.034749481827020645,
0.5237634181976318,
-0.30118826031684875,
0.146142527... | |
instead of LINQ to SQL and other DAL generators but EF *really* isn't where it needs to be at all. I won't be using it in future projects until it's a more complete solution.
Here's what I ended up doing:
```
Dim db As New MilkModel
'==
'Begin dirty hack to execute parameterless/resultless stored
'procedure using E... | [
0.3413129448890686,
0.18512824177742004,
0.6182743906974792,
-0.28270867466926575,
-0.10498951375484467,
-0.00261397915892303,
0.11971695721149445,
-0.3284943401813507,
-0.1508590131998062,
-0.23472124338150024,
0.0851464569568634,
0.5548083782196045,
-0.21938404440879822,
0.41175207495689... | |
I am trying to track what users are searching for on my site (from a simple search form on the front page) with PHP and MySQL.
At the end of all my queries I am using this query:
```
INSERT INTO `DiggerActivity_Searches` (
`SearchTerms`,
`SearchType`,
`NumResults`,
`Location`,
`Date`,
`Time`
) VALUES (
'SearchKeyword... | [
0.2296944111585617,
0.2987915873527527,
0.7257790565490723,
-0.10239537060260773,
-0.06988317519426346,
0.11912176012992859,
0.20139989256858826,
0.07710624486207962,
-0.12606172263622284,
-0.694020688533783,
0.03035436011850834,
0.34530606865882874,
0.0097504872828722,
0.2815665602684021,... | |
script is invoked three times (e.g. by some browser addons).
If you do not have a debugger installed you can use something like
```
function trace_log() {
static $magic = null;
if (is_null($magic)) {
$magic = uniqid();
}
$s = $magic . ' '. microtime(true) . ":\r\n";
foreach( debug_back... | [
-0.13081426918506622,
-0.41663864254951477,
0.49622735381126404,
-0.18571868538856506,
0.046422552317380905,
0.1206473633646965,
0.6725049018859863,
0.10279680788516998,
-0.022953137755393982,
-0.8024988174438477,
-0.18546070158481598,
0.5473892092704773,
-0.4342600703239441,
0.14511971175... | |
whatever you use to execute the query.
```
If the first value of each log entry (the "magic" id) in trace\_log.txt changes, your script is invoked multiple times. If it's the same for all three calls to trace\_log(), your script executes the query three times. | [
0.33553338050842285,
-0.10634168982505798,
0.5354974269866943,
-0.16762547194957733,
0.29566752910614014,
-0.03608196973800659,
0.32888633012771606,
-0.10072194039821625,
-0.3389049172401428,
-0.6809729337692261,
-0.19620253145694733,
0.7297917604446411,
-0.3291650116443634,
-0.11136902123... | |
Could any one suggest good Python-related podcasts out there, it could be anything about Python or its eco-system (like django, pylons, etc).
[Google Code University](http://code.google.com/edu/languages/index.html) (several languages there)
[Python Podcasts](http://advocacy.python.org/podcasts/)
[Python Learning... | [
0.3380173146724701,
0.010659493505954742,
0.11530924588441849,
0.20119908452033997,
-0.245237335562706,
-0.24352076649665833,
0.06768793612718582,
0.40268081426620483,
-0.6244140863418579,
-0.17721426486968994,
-0.48324689269065857,
0.48003867268562317,
0.0981810912489891,
-0.1044417619705... | |
I have the below methods:
```
public static byte[] ConvertFileToBytes(string filePath)
{
var fInfo = new FileInfo(filePath);
var numBytes = fInfo.Length;
var dLen = Convert.ToDouble(fInfo.Length / 1000000);
var fStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);... | [
-0.0866321474313736,
-0.1449594348669052,
0.7906784415245056,
-0.3590068519115448,
0.0164121575653553,
0.19268986582756042,
0.1155661791563034,
-0.5158606171607971,
-0.06488143652677536,
-0.6516027450561523,
-0.10472744703292847,
0.4880372881889343,
-0.2744385600090027,
0.3679468035697937,... | |
fStream.Close();
fStream.Dispose();
return data;
}
public static void ConvertBytesToFile(byte[] file, string filePath)
{
var ms = new MemoryStream(file);
var fs = new FileStream(filePath, FileMode.Create);
ms.WriteTo(fs);
ms.Close();
fs.Close();
... | [
-0.15318666398525238,
-0.30199846625328064,
0.846000611782074,
-0.4976160228252411,
0.3820981979370117,
0.15902093052864075,
0.20378656685352325,
-0.3096793293952942,
-0.051576290279626846,
-0.6735300421714783,
-0.4146062433719635,
0.5858621001243591,
-0.4396721124649048,
0.210450664162635... | |
}
```
**What is the correct to name these methods?** (because Convert*XXX*to*YYY* just doesn't cut it in a Utilities library)
How about [File.ReadAllBytes](http://msdn.microsoft.com/en-us/library/system.io.file.readallbytes.aspx) and [File.WriteAllBytes](http://msdn.microsoft.com/en-us/library/system.io.file.writeall... | [
0.27832645177841187,
0.027114907279610634,
0.13400639593601227,
-0.026486413553357124,
0.14463411271572113,
-0.025371475145220757,
-0.05098399519920349,
-0.34874480962753296,
-0.13469946384429932,
-0.5455966591835022,
-0.049710504710674286,
0.6135626435279846,
-0.18391405045986176,
-0.1180... | |
I'm trying to get into C++ programming, and I'm quite struggling against the little details. Right now, I'm trying to get the snippet below to work, and apparently it will compile, but not link. (error message is a the bottom of this post)
I'm using `libsndfile` to open audio files, and the linker doesn't seem to find... | [
0.3405158817768097,
0.3378452956676483,
0.4915262758731842,
0.10614922642707825,
0.11332615464925766,
-0.5198830366134644,
0.5014060139656067,
0.2020246386528015,
-0.039406828582286835,
-0.8230427503585815,
-0.24185985326766968,
1.1090095043182373,
-0.18845424056053162,
0.31264498829841614... | |
that's of any concern.
Here's my code:
```
#include <iostream>
#include <string>
#include <sndfile.h>
#include "stereoSplit.h"
using namespace std;
int stereoSplit(string filename)
{
cout << filename;
SF_INFO sfinfo;
sfinfo.format = 0;
SNDFILE * soundfile;
soundfile = sf_open( filename.c_str(), S... | [
0.3247548043727875,
0.3203817307949066,
0.38591504096984863,
-0.2919813394546509,
0.07931205630302429,
-0.0970119759440422,
0.19243621826171875,
-0.4147445261478424,
-0.047794267535209656,
-0.26413634419441223,
-0.16020475327968597,
0.6725698113441467,
-0.48950767517089844,
-0.109434328973... | |
command should look something like:
```
g++ mystuff.cpp -lsndfile
``` | [
-0.11343425512313843,
-0.02663382515311241,
0.4183260500431061,
0.21471545100212097,
0.12399221211671829,
-0.20265637338161469,
0.02767059952020645,
0.3667626976966858,
-0.09052589535713196,
-0.7082327008247375,
-0.4176516532897949,
0.6035261750221252,
-0.2159123420715332,
0.00275211175903... | |
I am interested in the floating effect of SO when pressing the newest link:

**Which library would you use in jQuery to make the floating effect?**
If you look at that page and view the source you can see exactly what they're doing. It's really only about 10 lines of jav... | [
0.15698949992656708,
0.06566043198108673,
0.8811259865760803,
-0.07663800567388535,
-0.1313776671886444,
-0.015882492065429688,
-0.1236690953373909,
-0.22646886110305786,
-0.13140769302845,
-0.585684061050415,
-0.09061155468225479,
0.40975597500801086,
-0.31065720319747925,
0.1064350828528... | |
you just scrolled to with the result:
```
var domelement = $(result);
$("#answers-table").html(domelement);
```
The actual tab styling is just specifying a different class for the link to change the color. This is also not *exactly* the order in which things are done but it's pretty close.
Someone please let me kno... | [
0.694356381893158,
-0.06143542006611824,
0.6295117139816284,
0.015133519656956196,
0.020861171185970306,
-0.2723420262336731,
-0.015673356130719185,
-0.10470432043075562,
-0.3169318437576294,
-0.674833357334137,
-0.04792699217796326,
0.7349018454551697,
-0.29106149077415466,
0.025746323168... | |
I have to fill a combobox with month in English: January, February, etc.
I did it next way:
```
private string[] AmericanMonths
{
get
{
var arr = new string[12];
var americanCulture = new CultureInfo("en-US");
for (int i = 0; i < 12; i++)
{
arr[i] = new DateTime(2000, i + 1, 1).ToString("MMMM... | [
0.45151713490486145,
-0.05154810845851898,
0.7488808631896973,
-0.16234846413135529,
0.13098104298114777,
0.2185458242893219,
0.5086789131164551,
-0.11380364000797272,
-0.22491292655467987,
-0.3437049090862274,
-0.03961962088942528,
0.16751769185066223,
-0.03918928653001785,
0.192825108766... | |
name?
The CultureInfo already contains the list of month names right in the framework. You could just write:
```
var americanCulture = new CultureInfo("en-US");
comboMonth.Items.AddRange(americanCulture.DateTimeFormat.MonthNames.Take(12)); //to remove last empty element
``` | [
0.525170624256134,
-0.05415809899568558,
0.6278539896011353,
-0.1519051492214203,
0.124591164290905,
-0.030979085713624954,
0.23153603076934814,
0.16288726031780243,
-0.2099614292383194,
-0.35559508204460144,
-0.12116340547800064,
0.08315515518188477,
0.11259347200393677,
0.429641306400299... | |
I'm experimenting with TextArea and inheritance to implement some additional functionality on the protected `textField` property.
Unfortunately, when I create a new instance of the subclass, this property is set to `null`. I'm probably misunderstanding the way `super()` works, but I thought it would have been instanti... | [
0.3810357451438904,
0.058913376182317734,
0.13193379342556,
-0.3354523181915283,
-0.007325701415538788,
-0.15355584025382996,
0.6277687549591064,
-0.35413599014282227,
0.14353710412979126,
-0.46914142370224,
-0.25599321722984314,
0.7910529971122742,
-0.3895959258079529,
0.03331455215811729... | |
code is simple:
```
var extTextArea:ExtTextArea = new ExtTextArea();
extTextArea.testTextField();
```
The `Alert` in `ExtTestArea` appears every time I run this code.
Why is this? Is there something more I need to do to access the `textField` property?
Since *textField* is "the internal UITextField that renders th... | [
0.33220064640045166,
0.14032752811908722,
0.2942230701446533,
-0.31964778900146484,
0.0050277551636099815,
-0.14004427194595337,
0.574781596660614,
-0.2302059829235077,
0.027665508911013603,
-0.5920822620391846,
-0.274665504693985,
0.6262623071670532,
-0.2972540557384491,
0.121828101575374... | |
think). | [
0.20185133814811707,
0.03112279251217842,
0.08192326128482819,
0.007031536661088467,
-0.029528940096497536,
0.4035172164440155,
0.17110702395439148,
-0.34440240263938904,
-0.1706458330154419,
-0.3472542464733124,
-0.08416587859392166,
0.30898046493530273,
-0.27231907844543457,
0.4190887510... | |
Comparison sort is opted for in most of the scenarios where data needs to be ordered. Techniques like merge sort, quick sort, insertion sort and other comparison sorts can handle different data types and efficiency with a lower limit of O(nLog(n)).
My questions are
1. Are there any limitations of comparison based sor... | [
0.030149955302476883,
-0.13389119505882263,
0.09254790097475052,
0.1705799549818039,
-0.5750812888145447,
0.33777278661727905,
-0.014039233326911926,
-0.25483185052871704,
-0.3751232922077179,
-0.6933482885360718,
0.18292604386806488,
0.39460447430610657,
-0.3105294406414032,
-0.0907632187... | |
domain must be better known and for that reason they aren't as versatile as comparison based techniques.
[Pigeonhole sort](http://en.wikipedia.org/wiki/Pigeonhole_sort) is a great and quite simple example which is pretty fast as long as the number of possible key values is close to the number of elements. | [
-0.04538970813155174,
-0.10146861523389816,
0.1540835201740265,
0.3322094976902008,
0.01784261129796505,
-0.6846219897270203,
-0.029347244650125504,
-0.17068339884281158,
-0.33942270278930664,
-0.657438337802887,
-0.06824978440999985,
0.09041901677846909,
-0.18657991290092468,
0.1931285113... | |
I would like to reflect the XML tree in my object structure, but I am quite a beginner in LINQ to XML
I have an XML with following structure:
```
<questions>
<question id="q1">
<number>1</number>
<text>some text11</text>
<answers>
<answer>
<v>some text11</v>
</answer>
<answer>
<v>some ... | [
0.1273840218782425,
0.42252615094184875,
0.3250962197780609,
-0.15397195518016815,
-0.21232925355434418,
-0.10619709640741348,
0.12278754264116287,
-0.1942387819290161,
0.051519282162189484,
-0.7239536643028259,
0.010051270946860313,
0.22584858536720276,
0.10720314085483551,
-0.08565417677... | |
<v>some text22</v>
</answer>
</answers>
</question>
<question id="q3">
<number>3</number>
<text>some text3</text>
<answers>
<answer>
<v>some text33</v>
</answer>
<answer>
<v>some text33</v>
</answer>
<answer>
<v>some text33</v>
<addDescription>some text333</addDes... | [
-0.2272695153951645,
0.02765832282602787,
0.2746215760707855,
-0.24758851528167725,
-0.6654016971588135,
0.3881089985370636,
0.3309497833251953,
-0.5848643183708191,
-0.23507817089557648,
-0.5014247298240662,
-0.24573591351509094,
0.4036499559879303,
-0.10684733092784882,
-0.19634146988391... | |
List<Anwser>();
}
public class Anwser
{
public string content { get; set; }
}
```
... and I have build a following (wrong) Linq query:
```
List<Question> questions = (from xml in xdoc.Element("survey").Elements("questions").Elements("question")
select new Question() | [
0.0712747797369957,
-0.13605095446109772,
0.44920244812965393,
0.12424901127815247,
-0.11432980000972748,
0.017132189124822617,
0.05682533606886864,
-0.5199843049049377,
-0.3179842531681061,
-0.280168741941452,
-0.31241971254348755,
0.3161754608154297,
-0.31993386149406433,
0.1612364649772... | |
{
text = xml.Element("text").Value, | [
-0.03144504129886627,
0.05391518026590347,
0.12621575593948364,
0.05209808051586151,
0.2115994542837143,
0.10238184034824371,
0.09613709151744843,
-0.16566713154315948,
0.05577165633440018,
-0.16829194128513336,
-0.3840738534927368,
0.6068045496940613,
-0.4406830668449402,
-0.2118766754865... | |
anwsers =
(from anwsers in | [
-0.1448633074760437,
0.22684049606323242,
0.08289959281682968,
-0.5173824429512024,
-0.5987152457237244,
0.2338559478521347,
0.4772663116455078,
-0.20918142795562744,
-0.5857178568840027,
-0.33503174781799316,
-0.2309376746416092,
0.14323262870311737,
0.052215367555618286,
-0.1408498883247... | |
xdoc.Element("survey").Elements("questions").Elements("question").Elements( | [
0.18891295790672302,
0.02750515565276146,
0.04545106366276741,
0.36222147941589355,
0.06641682237386703,
0.17854918539524078,
-0.12951147556304932,
-0.42732545733451843,
0.020218679681420326,
-0.07956287264823914,
-0.3798922598361969,
-0.16248109936714172,
-0.275301992893219,
-0.2191605269... | |
"answers").Elements(
"answer") | [
0.05616048350930214,
-0.11062099039554596,
-0.21416345238685608,
0.34202057123184204,
-0.2057199478149414,
0.1898483783006668,
0.2555224597454071,
-0.7317099571228027,
0.03440939262509346,
-0.249254509806633,
-0.2964250445365906,
0.024649208411574364,
-0.35966819524765015,
-0.2274747192859... | |
select new Anwser()
{ | [
-0.3034309148788452,
-0.2017916887998581,
0.03776400908827782,
-0.4496561288833618,
0.27564936876296997,
0.02305053174495697,
0.29950639605522156,
-0.09084541350603104,
-0.02786719985306263,
-0.49144574999809265,
-0.28681766986846924,
0.6439489126205444,
-0.35434868931770325,
0.17895549535... | |
content = anwsers.Element("v").Value | [
0.3735601007938385,
-0.004253470338881016,
0.3313741087913513,
0.10234435647726059,
-0.16117428243160248,
-0.16812387108802795,
0.31523916125297546,
-0.16680461168289185,
-0.12452292442321777,
-0.18320605158805847,
-0.04743011295795441,
0.3758922517299652,
-0.16241197288036346,
0.312119454... | |
}
).ToList() | [
0.04771151766180992,
-0.31081971526145935,
0.19437327980995178,
-0.2889403998851776,
0.6068010330200195,
-0.1074850782752037,
0.28023242950439453,
-0.32286712527275085,
-0.12975165247917175,
-0.40660375356674194,
-0.29818859696388245,
0.8230611681938171,
-0.7525278925895691,
0.052179925143... | |
}).ToList();
```
Of course this way I get each time all anwsers from all questions added to each list.
How to solve this? I can imagine that this is simple but I have no idea :)
Thank you in advance!
Your code isn't working because you are getting back all the answer elements because you didn't restrict them based o... | [
0.2725701630115509,
0.045511920005083084,
0.3799576461315155,
0.1223134845495224,
0.2501755356788635,
-0.3631928265094757,
0.16091778874397278,
-0.12402799725532532,
-0.09360409528017044,
-0.5391798615455627,
-0.22133763134479523,
0.6488019227981567,
-0.5124519467353821,
0.2557957470417022... | |
you can make the subquery based on the question element itself.
```
List<Question> questions = (from question in xdoc.Element("survey").Element("questions").Elements("question")
select new Question
{
text = question.Element("text").Value,
anwsers = (from answer in question.Eleme... | [
-0.1449156552553177,
-0.07276161015033722,
0.4134185314178467,
0.05734563618898392,
0.02979649417102337,
0.07095867395401001,
0.22260189056396484,
-0.3004477620124817,
-0.2861728370189667,
-0.4688013792037964,
-0.42751985788345337,
0.43888112902641296,
-0.31594231724739075,
0.0676216706633... | |
content = answer.Element("v").Value
}).ToList()
}).ToList();
``` | [
0.20793883502483368,
-0.10842888057231903,
0.6399033665657043,
0.107639841735363,
0.20628122985363007,
-0.2547188103199005,
0.21913494169712067,
-0.46417662501335144,
0.05724802613258362,
-0.1839277297258377,
-0.6020281314849854,
0.4899510443210602,
-0.5466312170028687,
0.40290892124176025... | |
Just to make sure I'm understanding shallow copies of reference types correctly and that I'm not constructing a huge memory leak here:
```
// Adds text to the beginning of the log RTB
// Also keeps the log RTB trimmed to 100 lines
var lines = new string[rtbLog.Lines.Length + 1];
lines[0] = "text";
Array.Copy(rtbLog.Li... | [
0.009712619706988335,
-0.01664861850440502,
0.7337232232093811,
-0.30707716941833496,
-0.1956639438867569,
0.2730284333229065,
0.4085484445095062,
-0.8784639239311218,
-0.06618621200323105,
-0.48111769556999207,
-0.06555309146642685,
0.5143538117408752,
-0.35543587803840637,
-0.10227236896... | |
referenced by lines (before the resize), and lastly any strings not contained in lines (after the resize), all get garbage collected. (I hope that makes sense)
Correct?
The Array.Resize method is a bit of a misnomer. It should really be named CopyToNewArrayWithSize. Under the hood, this API will create a new array and... | [
0.5083348751068115,
-0.2361718863248825,
0.6536699533462524,
0.14264832437038422,
0.09777237474918365,
-0.13575473427772522,
0.29162782430648804,
-0.322112113237381,
-0.13754497468471527,
-0.4988251328468323,
0.13453373312950134,
0.6065050959587097,
-0.29050174355506897,
0.2824603021144867... | |
will be garbage collected at some point in the future. | [
0.5928718447685242,
0.09968994557857513,
0.5027643442153931,
0.3553159534931183,
0.5120844841003418,
-0.11378602683544159,
-0.19943800568580627,
0.2884829342365265,
-0.07378875464200974,
-0.6548037528991699,
-0.06989549100399017,
0.1319303661584854,
-0.15662908554077148,
0.0187210924923419... | |
I need a TextBox or some type of Multi-Line Label control which will automatically adjust the font-size to make it as large as possible and yet have the entire message fit inside the bounds of the text area.
I wanted to see if anyone had implemented a user control like this before developing my own.
Example applicati... | [
0.11631462723016739,
0.06659527868032455,
0.1752125471830368,
-0.03930681198835373,
-0.047561295330524445,
0.14070147275924683,
0.06737414002418518,
-0.19921788573265076,
-0.11181921511888504,
-0.737576425075531,
0.0005886362050659955,
0.37716734409332275,
-0.1766996681690216,
-0.280746698... | |
which uses Mono Supported .NET libraries would be a plus.
If know one has implemented a control already... If someone knows how to test if a given text completely fits inside the text area that would be useful for if I roll my own control.
Edit: I ended up writing an extension to RichTextBox. I will post my code shor... | [
0.3908616900444031,
-0.08222051709890366,
0.1496821790933609,
0.08095476031303406,
-0.042853400111198425,
-0.1768745481967926,
0.20474275946617126,
-0.292827308177948,
-0.2299521267414093,
-0.27355751395225525,
-0.06659957766532898,
0.5472498536109924,
-0.43078112602233887,
-0.015148895792... | |
enhancements:
* Call the ScaleFontToFit() method after resizing or text changes.
* The Horizontal Alignment field can be used to center align the text.
* The Font attributes set in the designer will be used for the entire region. It is not possible to mix fonts as they will changed once the ScaleFontToFit method is c... | [
0.15100917220115662,
-0.18936386704444885,
0.8521133661270142,
-0.00552437175065279,
0.0227121002972126,
0.1555432826280594,
0.163640096783638,
-0.643735408782959,
-0.14088544249534607,
-0.7712799906730652,
0.05546845495700836,
0.7685906291007996,
-0.008416811004281044,
-0.1719259172677993... | |
a clever technique I found on one of [Patrick Smacchia's posts.](http://codebetter.com/blogs/patricksmacchia/archive/2008/07/07/some-richtextbox-tricks.aspx). When multiline isn't true, vertical scrollbars never appear so you need to use a different technique which relies on rendering the text using a the Graphics obje... | [
0.07706070691347122,
-0.08638989925384521,
0.3203718662261963,
0.12323763221502304,
0.007663854397833347,
0.15109646320343018,
0.5357507467269897,
-0.048352159559726715,
-0.18673914670944214,
-0.7627851963043213,
0.0770006775856018,
0.3745836615562439,
-0.28516149520874023,
-0.154083326458... | |
large as possible while still fitting in the text
/// area with out any scrollbars.
/// </summary>
public void ScaleFontToFit()
{
int fontSize = 10;
const int incrementDelta = 5; // amount to increase font by each loop iter.
const int decrementDelta = 1; // amount to decrease to ... | [
0.22938448190689087,
-0.2550094723701477,
1.0369764566421509,
-0.3328418731689453,
0.03371043503284454,
0.4496658146381378,
0.2910778820514679,
-0.5118584036827087,
-0.476958692073822,
-0.5819564461708069,
-0.09226242452859879,
0.4415109157562256,
-0.10210595279932022,
0.1392304003238678,
... | |
First we set the font size to the minimum. We assume at the minimum size no scrollbars will be visible.
SetFontSize(MinimumFontSize);
// Next, we increment font size until it doesn't fit (or max font size is reached).
for (fontSize = MinFontSize; fontSize < MaxFontSize; fontSize += incrementDe... | [
0.09084919095039368,
-0.29275253415107727,
0.8550178408622742,
-0.3372589647769928,
0.23356477916240692,
0.2883322834968567,
0.3065231740474701,
-0.22595509886741638,
0.11635733395814896,
-0.8529746532440186,
-0.4016810357570648,
0.8243328928947449,
-0.35616451501846313,
-0.239352852106094... | |
if (!DoesTextFit())
{
//Console.WriteLine("Text Doesn't fit at fontsize = " + fontSize);
break;
}
}
// Finally, we keep decreasing the font size until it fits again. | [
-0.1354449838399887,
-0.006688967812806368,
0.8661041855812073,
-0.4239182770252228,
0.23503810167312622,
0.05619944632053375,
0.3882315158843994,
-0.29960209131240845,
0.056409355252981186,
-0.7746304869651794,
-0.2378663867712021,
0.6051328778266907,
-0.10447612404823303,
-0.053746707737... | |
for (; fontSize > MinFontSize && !DoesTextFit(); fontSize -= decrementDelta)
{
SetFontSize(fontSize);
}
this.ResumeLayout();
}
#region Private Methods
private bool VScrollVisible
{
get
{
Rectangle clientRectangle = this.ClientRectangle; | [
-0.17680992186069489,
-0.631823718547821,
0.9969685673713684,
-0.2894538640975952,
0.27571243047714233,
0.24064788222312927,
0.26258018612861633,
-0.3179049491882324,
-0.2275141477584839,
-0.7541205883026123,
-0.5309740900993347,
0.4332660436630249,
-0.12578518688678741,
0.2073753476142883... | |
Size size = this.Size;
return (size.Width - clientRectangle.Width) >= SystemInformation.VerticalScrollBarWidth;
}
}
/**
* returns true when the Text no longer fits in the bounds of this control without scrollbars.
*/
private bool DoesTextFit()
{
if (VScrollVisib... | [
0.048769306391477585,
-0.20658408105373383,
0.777599036693573,
-0.3061920702457428,
0.24167270958423615,
-0.029461227357387543,
0.4710201025009155,
-0.3528650104999542,
-0.22213922441005707,
-0.43478357791900635,
-0.34278640151023865,
0.636143684387207,
-0.15548181533813477,
0.115768209099... | |
{
//Console.WriteLine("#1 Vscroll is visible");
return false;
}
// Special logic to handle the single line case... When multiline is false, we cannot rely on scrollbars so alternate methods.
if (this.Multiline == false) | [
-0.004903377033770084,
-0.2444596141576767,
0.5965404510498047,
-0.030417349189519882,
-0.015925321727991104,
0.04744601622223854,
0.4835008978843689,
-0.3023938238620758,
-0.00412291893735528,
-0.506923496723175,
-0.13555823266506195,
0.47585251927375793,
-0.30231696367263794,
0.199230074... | |
{
Graphics graphics = this.CreateGraphics();
Size stringSize = graphics.MeasureString(this.Text, this.SelectionFont).ToSize();
//Console.WriteLine("String Width/Height: " + stringSize.Width + " " + stringSize.Height + "form... " + this.Width + " " + this.Height); | [
-0.1992368996143341,
-0.06741884350776672,
0.7338517904281616,
-0.2710561752319336,
0.004137791693210602,
0.29887205362319946,
0.11589924246072769,
-0.31354841589927673,
-0.03055468387901783,
-0.6822955012321472,
-0.30297091603279114,
0.6883918642997742,
-0.08840145915746689,
-0.0459948144... | |
if (stringSize.Width > this.Width)
{
//Console.WriteLine("#2 Text Width is too big");
return false;
}
if (stringSize.Height | [
-0.06123470142483711,
-0.2321304827928543,
0.5509929060935974,
-0.3356435298919678,
0.34472036361694336,
-0.18700766563415527,
0.3241173326969147,
-0.28589197993278503,
0.013957800343632698,
-0.5650491118431091,
-0.41321566700935364,
0.6753061413764954,
0.01583917811512947,
0.0510977581143... | |
> this.Height)
{
//Console.WriteLine("#3 Text Height is too big");
return false;
}
if (this.Lines.Length > 1) | [
0.01571984589099884,
-0.05448313429951668,
0.7460994124412537,
-0.3032146990299225,
0.09678206592798233,
-0.046856384724378586,
0.716532289981842,
-0.45040011405944824,
-0.03790357708930969,
-0.499743789434433,
-0.35858863592147827,
0.3763609230518341,
-0.19291433691978455,
-0.032266646623... | |
{
//Console.WriteLine("#4 " + this.Lines[0] + " (2): " + this.Lines[1]); // I believe this condition could be removed.
return false;
} | [
0.1266166716814041,
-0.03528003767132759,
0.46538472175598145,
-0.27704116702079773,
0.5036959052085876,
0.13036838173866272,
0.7107366323471069,
-0.14712324738502502,
0.22048097848892212,
-0.44528311491012573,
-0.1848774403333664,
0.6049483418464661,
-0.24991081655025482,
0.28673690557479... | |
}
return true;
}
private void SetFontSize(int pFontSize)
{
SetFontSize((float)pFontSize);
}
private void SetFontSize(float pFontSize)
{
this.SelectAll();
this.SelectionFont = new Font(this.SelectionFont.FontFamily, pFontSize, this.SelectionFont.Style);
... | [
0.1702965945005417,
-0.3686710298061371,
0.8523191809654236,
-0.382965087890625,
0.4677731394767761,
0.4361845850944519,
0.1948082000017166,
-0.39059555530548096,
-0.17561715841293335,
-0.7967291474342346,
-0.44653403759002686,
0.583570659160614,
-0.3845824599266052,
0.18484371900558472,
... | |
could be optimized to improve performance but I kept it simple so it'd be easy to understand.
[Download the latest source code here.](http://www.blakerobertson.com/code/csharp/AutoScalingRichTextBox "Click here to get the source code and demo application") I am still actively working on the project which I developed t... | [
0.3930785059928894,
-0.019511355087161064,
0.2608656585216522,
0.23444029688835144,
0.13532821834087372,
-0.2824419140815735,
0.16694878041744232,
-0.026089971885085106,
-0.10202940553426743,
-0.6998415589332581,
0.22153565287590027,
0.7418700456619263,
-0.13287624716758728,
0.283295452594... | |
I have the following code in a Runnable that gets passed to a thread t:
```
public void run() {
logger.debug("Starting thread " + Thread.currentThread());
try {
doStuff();
} catch (Exception e) {
logger.debug("Exception in Thread " + Thread.currentThread());
}
... | [
0.16591250896453857,
-0.12089301645755768,
0.29728391766548157,
-0.18004699051380157,
0.38308703899383545,
-0.18587511777877808,
0.3861256241798401,
-0.13687272369861603,
0.0806967169046402,
-0.6028733849525452,
-0.3520299196243286,
0.32312995195388794,
-0.4791022539138794,
0.6100328564643... | |
}
```
I've hit a bug where I see deadlock with the following conditions
* only the start of thread message has been printed by my logs
* A thread dump shows that the thread t (supposed to be executing this) is no longer running
Is there some magical way this thread could have terminated early without either logging... | [
0.3325200378894806,
-0.09527180343866348,
0.04645542800426483,
-0.215815469622612,
0.254661500453949,
-0.41545650362968445,
0.5560758113861084,
0.17965541779994965,
-0.45087242126464844,
-0.4625498652458191,
-0.148116335272789,
0.7022028565406799,
-0.47094106674194336,
0.15168283879756927,... | |
When I started working on my first app, i assumed dragging files into xcode put them in my project's actual directory. Not so. Apparently Xcode references them all on the desktop.
Is there an easy way to copy all referenced files into the project directory? My desktop is a mess.
There really isn't a straightforward wa... | [
0.4527207612991333,
0.35151833295822144,
0.18474777042865753,
0.150433748960495,
0.25521159172058105,
0.02602958492934704,
0.12170706689357758,
0.09390860050916672,
-0.359015554189682,
-0.7113062739372253,
0.1754927784204483,
0.30816397070884705,
-0.47201839089393616,
0.267753541469574,
... | |
There are now so many ways to write windows apps, win32, MFC, ATL, .NET, WinForms, and probably some others that I don't know of. Which one should I choose? I'd like one that works on a fresh install of Vista, and is modern and easy to use.
If you are amateur with C++ you'll have much easier time learning WinForms than... | [
0.3030988276004791,
0.19245849549770355,
0.39288100600242615,
0.280343621969223,
-0.08262556791305542,
-0.01785200461745262,
0.07937988638877869,
0.07321278750896454,
-0.15045355260372162,
-0.902204155921936,
0.1405138373374939,
0.9260479211807251,
-0.09652727097272873,
0.01603228598833084... | |
mainly if you want to crunch the last bits of performance or need to keep the footprint small for stuff such as shell extensions.
I'd recommend checking WinForms at least first to get some quick understanding of the principles. If WinForms doesn't suit you, you can then move to either C++ if you feel you need more low... | [
0.5319393873214722,
-0.38678422570228577,
0.37568366527557373,
-0.13881659507751465,
-0.17595019936561584,
-0.11812343448400497,
0.10245811939239502,
-0.00894349254667759,
-0.047585293650627136,
-0.6885272264480591,
-0.20273377001285553,
0.9909613132476807,
-0.04895370453596115,
-0.2914594... | |
I have been putting off developing this part of my app for sometime purely because I want to do this in a circular way but get the feeling its a bad idea from what I remember my lecturers telling me back in school.
I have a design for an order system, ignoring the everything that doesn't pertain to this example I'm le... | [
0.3892268240451813,
-0.011928528547286987,
0.4083977937698364,
-0.14705708622932434,
0.11450368165969849,
0.5374647974967957,
-0.3736279606819153,
0.036595311015844345,
-0.4596746265888214,
-0.5682312846183777,
0.1644735336303711,
0.23245583474636078,
-0.19669584929943085,
0.11556185036897... | |
uniqueness of cc number, husband/wife may share cc instances ect)
Basically the last part is where the issue shows up, sometimes credit cards are declined and they wish to use a different one, this needs to update which their 'current' card is but this can only change the current card used for that order, not the othe... | [
0.29341113567352295,
0.10494446009397507,
0.4173124432563782,
0.3320077657699585,
0.10805999487638474,
-0.08661981672048569,
-0.500663161277771,
-0.21482393145561218,
-0.7231695652008057,
-0.28803765773773193,
0.29038533568382263,
0.1353088617324829,
-0.100758396089077,
0.6652069687843323,... | |
table that references all three table ids and put unique on the order so that only one cc may be current to that order at any time
Essentially both model the same design but translate differently, I am liking the latter option best at this point in time because it seems less circular and more central. (If that even ma... | [
0.4776992201805115,
0.27481746673583984,
0.3525794744491577,
0.38155341148376465,
0.010546952486038208,
-0.017090700566768646,
-0.28918761014938354,
0.12450696527957916,
-0.4477929472923279,
-0.47997337579727173,
0.4833170473575592,
0.2761422395706177,
-0.06455564498901367,
0.1852697134017... | |
let me know if there is anything you need clarified/explained.
--Update/Edit--
I have noticed an error in the requirements I stated. Basically dropped the ball when trying to simplify things for SO. There is another table there for Payments which adds another layer. The catch, Orders can have multiple payments, with ... | [
0.6582176685333252,
-0.08424244076013565,
0.39762580394744873,
0.21544919908046722,
0.0828685611486435,
-0.07650216668844223,
-0.08659425377845764,
0.08729289472103119,
-0.5057026147842407,
-0.49651196599006653,
0.1703224927186966,
0.36137086153030396,
-0.04476967453956604,
-0.055340874940... | |
is dynamic - it can come and go. And as you point out a credit card can be associated with more than one customer. So this ends up being an n:m table, maybe with a flag column for "active".
An order has a static relationship to 0 or 1 credit card, and after a sale is complete, you can't mess with the cc value, no matt... | [
0.36167216300964355,
-0.2840003967285156,
0.47855639457702637,
0.3896739184856415,
0.18429681658744812,
-0.13614699244499207,
-0.41655057668685913,
0.15137071907520294,
-0.6680231094360352,
0.04939396306872368,
-0.06265530735254288,
0.2812044620513916,
-0.3653213679790497,
0.24980053305625... | |
the sale with any other credit card column in any other table (which might change - but it wouldn't affect the sale). | [
0.2445998638868332,
-0.05682528018951416,
0.42891746759414673,
0.07117011398077011,
0.045346297323703766,
0.047892194241285324,
-0.40699294209480286,
-0.11827630549669266,
-0.44726479053497314,
0.02795141190290451,
0.044220201671123505,
0.6019397974014282,
0.21801809966564178,
-0.023139882... | |
Like most web developers these days, I'm thoroughly enjoying the benefits of solid MVC architecture for web apps and sites. When doing MVC with PHP, autoloading obviously comes in extremely handy.
I've become a fan of [`spl_autoload_register`](http://www.php.net/spl_autoload_register) over simply defining a single `__... | [
0.44469887018203735,
0.341998815536499,
0.26678305864334106,
-0.11844179034233093,
-0.26999813318252563,
-0.06939733773469925,
0.24116165935993195,
0.03698672726750374,
-0.5007513165473938,
-0.5948164463043213,
-0.08154857903718948,
0.8212698698043823,
-0.2389988899230957,
0.01148991938680... | |
that has a base path defined as `PATH_APP`, and a simple structure with directories named `models`, `views` and `controllers`. I often employ a naming structure whereby files are named `IndexView.php` and `IndexController.php` inside the appropriate directory, and models generally have no particular scheme by default. ... | [
0.060044657438993454,
-0.23686635494232178,
0.8614206910133362,
0.10217878967523575,
0.319744348526001,
-0.07912244647741318,
0.09743013978004456,
-0.4202800691127777,
-0.3023308515548706,
-0.649456262588501,
-0.2501082718372345,
0.6625039577484131,
-0.41456863284111023,
0.0243936926126480... | |
if (file_exists(PATH_APP.'/views/'.$class.'.php')) {
require_once(PATH_APP.'/views/'.$class.'.php');
return true;
}
}
else if (strpos($class,'Controller') !== false) {
if (file_exists(PATH_APP.'/controllers/'.$class.'.php')) {
require_once(PATH_APP.'/controlle... | [
-0.09356243163347244,
-0.19544894993305206,
0.6721845865249634,
0.05024484544992447,
0.4196670949459076,
-0.028052907437086105,
0.1925382912158966,
-0.6036997437477112,
-0.0311508197337389,
-0.6166794300079346,
-0.28065225481987,
0.561192512512207,
-0.24389556050300598,
-0.3475027978420257... | |
}
return false;
}
```
If it's not found after that, I might have another function to scan sub-directories in the models directory. However, all the if/else-ing, string checking and directory scanning seems inefficient to me, and I'd like to improve it.
I'm very curious what file naming and autoloading strategies... | [
0.10678156465291977,
-0.07428741455078125,
0.13640595972537994,
-0.2099355310201645,
0.14413106441497803,
-0.23568429052829742,
0.20278528332710266,
-0.11097782850265503,
-0.17701666057109833,
-0.6294580698013306,
-0.06977562606334686,
0.7514119148254395,
-0.43679431080818176,
0.1975843310... | |
$class . '.php',
str_replace('_', '/', $class) . '.php',
);
foreach (explode(PATH_SEPARATOR, ini_get('include_path')) as $base_path)
{
foreach ($files as $file)
{
$path = "$base_path/$file";
if (file_exists($path) && is_readable($path))
{ | [
0.09274989366531372,
0.13895264267921448,
0.24364081025123596,
-0.22520782053470612,
0.44600605964660645,
-0.16835463047027588,
0.40622901916503906,
-0.43330973386764526,
-0.023286568000912666,
-0.06818196922540665,
-0.3788521885871887,
0.5682229995727539,
-0.4804389178752899,
-0.021722821... | |
include_once $path;
return;
}
}
}
}
```
If I look for SomeClass\_SeperatedWith\_Underscores it will look for SomeClass\_SeperatedWith\_Underscores.php followed by SomeClass/SeperatedWith/Underscores.php rooted at each directory in the current include path.
**EDIT:** I just wan... | [
0.22377371788024902,
0.16199448704719543,
0.10117077082395554,
-0.4740849733352661,
0.0444788821041584,
-0.07261557132005692,
0.3522261381149292,
-0.0031884294003248215,
-0.27328330278396606,
-0.5594326853752136,
-0.012242180295288563,
0.5801217555999756,
-0.4801436960697174,
-0.0142923099... | |
on your path then with this you can just use the classes and don't have to include them when you need them.
I tend to keep my classes in a hierarchy of directories, with underscores breaking up namespaces... This code lets me keep the file structure nice and tidy if I want, or to inject a quick class file without nest... | [
0.3937254548072815,
-0.1488630771636963,
-0.18831144273281097,
0.4146009087562561,
-0.056573569774627686,
-0.04743100702762604,
0.20809273421764374,
-0.026188155636191368,
-0.208391010761261,
-1.0115907192230225,
0.17597351968288422,
0.44971781969070435,
-0.06323390454053879,
0.04109476506... | |
I'm having issues with ColdFusion's heap. Here's a little example application I'm experimenting with. I thought after `cfinvoke` calling the `init` method it destroys all variables local to the component. But apparently it's not the case. The application works as it is below but if I add a zero to the loop in `index.cf... | [
0.17817355692386627,
0.2618996500968933,
0.226711243391037,
-0.0342518612742424,
-0.2574230432510376,
-0.15096715092658997,
0.48440515995025635,
-0.23579886555671692,
0.013253647834062576,
-0.5916058421134949,
0.31493866443634033,
0.2884545624256134,
-0.5170860886573792,
-0.039129491895437... | |
<cfset var test = structNew()>
<cfloop from="1" to="1000" index="i">
<cfset test[i] = i>
</cfloop>
<cfreturn Now()>
</cffunction>
</cfcomponent>
```
**And here's the error message:**
```
SEVERE: Servlet.service() for servlet CfmServlet threw exception
javax.ser... | [
0.1593693494796753,
0.0716405138373375,
0.4403601586818695,
-0.3421987295150757,
-0.30343884229660034,
0.008704544976353645,
0.45240241289138794,
-0.37773194909095764,
-0.1736259162425995,
-0.5128257274627686,
-0.07213268429040909,
0.27271711826324463,
-0.41348934173583984,
0.1516873538494... | |
there is no way around it. It seems that CF DOES NOT handle garbage collection properly. As far as I can tell it will not destroy and free up memory used by component until after the request has finished.
Because of that, depending on how many properties your components has will determine how many of them you can crea... | [
0.5003011226654053,
0.48029249906539917,
0.2282729297876358,
0.18977950513362885,
-0.06511890143156052,
-0.3478591740131378,
0.3770843744277954,
0.11284579336643219,
-0.23121227324008942,
-0.458699494600296,
0.32733431458473206,
0.3006073534488678,
-0.15972764790058136,
0.49319714307785034... | |
What I'm suppose to do is use a trigger to update the quantity sold in the inventory table when an order is placed in the concessions\_sold table(an insert is used). I admit that I suck at PLSQL so I'm not sure if I'm going about this the right way. The error I'm getting is:
```
SQL> insert into concessions_sold
2 ... | [
0.4672602415084839,
0.3209371864795685,
0.16260778903961182,
0.015324975363910198,
0.22475068271160126,
0.030749445781111717,
-0.21796220541000366,
-0.27666038274765015,
-0.08105713129043579,
-0.25741592049598694,
0.23877426981925964,
0.7407292723655701,
-0.05863271653652191,
0.13586626946... | |
Concessions_sold
for each row
begin
if inserting then
update
(
select i.quantity
from inventory i, concessions_sold cs, concession c
where i.inventory_id = c.inventory_id and c.concession_id = cs.concession_id
)
set quantity = :new.quantity;
end if;
end LabEx5_1;
/
```
This is a known problem and CURRENTLY there is ... | [
0.5364388823509216,
0.38910773396492004,
0.25724244117736816,
0.036100294440984726,
-0.04275723546743393,
0.008905033580958843,
-0.3285253345966339,
-0.5028608441352844,
-0.19539710879325867,
-0.5263096690177917,
0.2664244771003723,
0.5928916335105896,
0.18867230415344238,
0.55832058191299... | |
your problem, but at least now you can take measures to prevent it. | [
0.16173040866851807,
0.061180513352155685,
0.148688405752182,
0.23629628121852875,
0.25405579805374146,
-0.10914455354213715,
0.30937662720680237,
0.14947423338890076,
-0.3458596467971802,
-0.41321495175361633,
0.18298181891441345,
0.47696423530578613,
-0.2377999722957611,
0.10475745797157... | |
For example the following cast can be found littered throughout the MSDN documentation:
```
(LPTSTR)&lpMsgBuf
```
Should I bother converting that to:
```
static_cast<LPTSTR>(&lpMsgBuf);
```
Or should I just leave all the idiomatic C-esque Win32 portions as they are typically found in the docs, and save the more i... | [
0.5743681788444519,
0.10403662919998169,
0.10844575613737106,
-0.19158874452114105,
-0.2375067174434662,
-0.004345592111349106,
0.04082286357879639,
-0.20803606510162354,
-0.02831723354756832,
-0.46431148052215576,
-0.057598263025283813,
0.6696500778198242,
-0.5291120409965515,
0.085342124... | |
and possibly not portable (reinterpret\_cast), I'm casting away constness (const\_cast), etc.).
They're purposefully long and ugly so that the cast jumps out at the reader (and to discourage a programming style that employs too much casting).
They're safer because, e.g., you can't cast away constness without explici... | [
0.21848177909851074,
0.15850774943828583,
0.12029727548360825,
0.025191763415932655,
0.019605671986937523,
0.15265966951847076,
0.36679452657699585,
-0.12111872434616089,
-0.1827211081981659,
-0.45251405239105225,
-0.25042426586151123,
0.39786961674690247,
-0.030104268342256546,
-0.0001019... | |
CF: **Carry Flag**
ZF: **Zero Flag**
i'm current read a book on intel x86 assembly on linux platform using AT&T syntax,and the book said,the effect of **setbe D** is qeuivalent to:
**D** ← **CF** & ~ **ZF**
i understood that,but could it simply write as:
**D ←** **CF**|**ZF**
this only different from ~ZF&CF when... | [
0.22977136075496674,
-0.09777326881885529,
0.5644939541816711,
-0.3461983799934387,
-0.17259718477725983,
-0.4839348793029785,
0.010892371647059917,
-0.6147516965866089,
-0.2528642416000366,
-0.3162570297718048,
-0.2220006138086319,
0.5065605044364929,
-0.4515559673309326,
-0.0046353344805... | |
the result of the preceding comparison was **b**elow-or-**e**qual, when compared as unsigned integers (the equivalent for signed integers would be `setle`, for **l**ess-or-**e**qual).
When `cmp` instruction is performed, the destination operand is subtracted from the source operand, and the result is discarded. The on... | [
-0.17367981374263763,
0.08846327662467957,
0.20073527097702026,
-0.07540855556726456,
-0.0331755168735981,
0.31467822194099426,
-0.012437757104635239,
-0.5705784559249878,
-0.020228175446391106,
-0.5115190148353577,
-0.3036845326423645,
0.3946564197540283,
-0.11645746231079102,
0.052315015... | |
+ 1
= 0x00000000 + 0xfffffffe + 1
= 0xffffffff ≠ 0, no carry
==> ZF = 0, CF = 0
Case 1: Compare 0 to 0
0 - 0
= 0 + ~0 + 1
= 0x00000000 + 0xffffffff + 1
= 0x00000000 = 0, with carry
==> ZF = 1, CF = 0
Case 2: Compare 0 to 1
1 - 0
= 1 + ~0 + 1
= 0x00000001 + 0xffffffff + 1
= 0x00000001 ≠ 0, ... | [
0.0027734418399631977,
0.1906118243932724,
0.6241246461868286,
-0.09154454618692398,
-0.32745835185050964,
0.17751894891262054,
0.03198610246181488,
-0.8946409225463867,
-0.029827775433659554,
-0.26764482259750366,
-0.10656837373971939,
0.2356618195772171,
-0.13866813480854034,
-0.14052146... | |
0, CF = 1
Case 3: Compare UINT_MAX to 0
0 - 4294967295
= 0 + ~4294967295 + 1
= 0x00000000 + 0x00000000 + 1
= 0x00000001 ≠ 0, no carry
==> ZF = 0, CF = 0
Case 4: Compare 0 to UINT_MAX
4294967295 - 0
= 4294967295 + ~0 + 1
= 0xffffffff + 0xffffffff + 1
= 0xffffffff ≠ 0, with carry
==> ZF = 0, CF ... | [
-0.07839661836624146,
0.3654313385486603,
0.7873294353485107,
-0.019715484231710434,
-0.19225099682807922,
0.15058718621730804,
0.061330005526542664,
-0.6605981588363647,
-0.08874774724245071,
-0.27563273906707764,
-0.15827608108520508,
0.08635711669921875,
-0.09806652367115021,
-0.0477940... | |
+ 1
= 0xffffffff + 0x00000000 + 1
= 0x00000000 = 0, with carry
==> ZF = 1, CF = 1
```
The cases in which the first argument is below-or-equal to the second are cases 1, 2, 4, and 5. All of these satisfy `(ZF=1) or (CF=1)`, and the remaining cases in which the comparison is false satisfy the opposite condition, ... | [
0.23160861432552338,
0.012416267767548561,
0.3760005533695221,
-0.4704229533672333,
0.030637426301836967,
-0.028171759098768234,
0.13315561413764954,
-0.6740576028823853,
0.0816207006573677,
-0.12727457284927368,
-0.3882085382938385,
0.6813235878944397,
-0.3853595554828644,
-0.146580308675... | |
What would be a good way to determine if a string contains an IPv4 address? Should I use `isdigit()`?
I asked [a similar question for C++](https://stackoverflow.com/questions/318236/how-do-you-validate-that-a-string-is-a-valid-ip-address-in-c). You should be able to use a slightly modified (for C) version of what I cam... | [
-0.025245336815714836,
0.09340903162956238,
0.5470978021621704,
-0.06806515157222748,
-0.08167238533496857,
-0.23055808246135712,
0.24684616923332214,
-0.3523566722869873,
-0.2688373029232025,
-0.4844551682472229,
-0.21936270594596863,
0.3275439739227295,
-0.3189851641654968,
-0.0294333174... | |
combine the two answers given so far. Use a regular expression to find patterns that roughly match an IP address, then use the function above to check the match to see if it's the real deal. | [
0.3075041174888611,
-0.35900649428367615,
0.1015646830201149,
0.23601284623146057,
0.18002784252166748,
-0.22187204658985138,
-0.009475119411945343,
-0.34624242782592773,
0.12097658216953278,
-0.5033901333808899,
0.09400147944688797,
0.3014325797557831,
-0.2663501799106598,
-0.079791218042... | |
I am not very familiar with Tomcat, in my head it is basically abstracted as a cgi server that saves the JVM between calls -- I know it can do a lot more than that, though.
I am looking for a way to launch a *background* thread when a Tomcat server starts, which would periodically update the Server Context (in my par... | [
0.6072260141372681,
-0.2680218815803528,
0.24109555780887604,
0.10066277533769608,
0.052507154643535614,
-0.1278362274169922,
0.12348057329654694,
0.40901944041252136,
-0.4996345639228821,
-0.16302916407585144,
0.22994419932365417,
0.47566717863082886,
-0.30965325236320496,
-0.080176316201... | |
and the updating/querying of the Context?
Any pointers to the relevant documentation and/or code samples would be much appreciated.
If you want to start a thread when your WAR is deployed, you can define a context listener within the web.xml:
```
<web-app>
<listener>
<listener-class>com.mypackage.MyServlet... | [
0.17483548820018768,
-0.13945259153842926,
0.26081717014312744,
0.003936613444238901,
-0.1370469182729721,
0.1440357118844986,
0.3753540813922882,
-0.475486695766449,
-0.37817177176475525,
-0.5566062331199646,
-0.1712765246629715,
0.6064692735671997,
-0.23017971217632294,
0.178504616022109... | |
myThread = new MyThreadClass();
myThread.start();
}
}
public void contextDestroyed(ServletContextEvent sce){
try {
myThread.doShutdown();
myThread.interrupt();
} catch (Exception ex) {
}
}
}
``` | [
-0.04540371149778366,
-0.22782878577709198,
0.12234470993280411,
0.10444603860378265,
0.18892401456832886,
0.033242568373680115,
0.603517472743988,
-0.20826609432697296,
-0.17812760174274445,
-0.4210343062877655,
-0.4937008321285248,
0.6019208431243896,
-0.2935500741004944,
0.4174333512783... | |
It's known that CF indicates unsigned carry out and OF indicates signed overflow. So how does an assembly program differentiate between unsigned and signed data since it's only a sequence of bits? (Through additional memory storage for type information, or through positional information or else?) And could these two fl... | [
0.21194303035736084,
0.15055304765701294,
0.12644481658935547,
-0.020942747592926025,
-0.12044861912727356,
0.1130673810839653,
0.07495366036891937,
-0.20508718490600586,
-0.41279393434524536,
-0.422470360994339,
0.09684393554925919,
0.35323572158813477,
-0.20439596474170685,
0.26166552305... | |
representation is the interpretation given to the most significant bit (also called the *sign bit*). For unsigned numbers the most significant bit is set when the number is in the upper half of the wholly positive range. For signed numbers the most significant bit is set when the number is in the lower and negative hal... | [
0.17647495865821838,
-0.21988026797771454,
0.2041030377149582,
0.1750173270702362,
-0.13790830969810486,
0.17253148555755615,
0.1574898362159729,
-0.3086772859096527,
-0.2726328372955322,
-0.4836527109146118,
-0.2314893901348114,
0.14615345001220703,
-0.30216580629348755,
-0.03549543023109... | |
tells whether a carry flipped the sign of the most significant bit in the result so that it is different from the most significant bits of the arguments. If numbers are interpreted as unsigned, the overflow flag is irrelevant, but if they are interpreted as signed, OF means, e.g., two large positive numbers were added ... | [
0.2641439735889435,
0.1495760828256607,
0.23537957668304443,
-0.0527682825922966,
-0.040975794196128845,
0.10283476114273071,
0.09856922179460526,
-0.36132189631462097,
-0.38714566826820374,
0.03256973996758461,
-0.37148168683052063,
-0.05062380060553551,
-0.10613380372524261,
-0.219150736... | |
to fit in a machine word. The overflow flag is irrelevant.
The answer to your question is that assembly code has several ways of distinguishing signed from unsigned data:
* It may choose either CF or OF to do signed or unsigned comparisons.
* It may choose either signed or unsigned multiply and divide instructions.
*... | [
0.3912346363067627,
-0.021278584375977516,
-0.04692263901233673,
-0.023229215294122696,
-0.020642591640353203,
0.369799941778183,
0.30329906940460205,
-0.3353179693222046,
0.0320730097591877,
-0.6478943228721619,
-0.17105989158153534,
0.2410200536251068,
-0.2715149521827698,
0.101288497447... | |
I just ran into a major issue for me with NHibernate. I have 2 objects, each with a collection of things. I need to move one thing from the collection from Object A to the collection of Object B. I get an error about a deleted object because, I believe, NHibernate attempts to delete the thing from the collection of Obj... | [
0.1863340139389038,
0.004794612992554903,
-0.010291253216564655,
0.05774879455566406,
-0.24382822215557098,
-0.0663425624370575,
0.14469657838344574,
-0.2087654173374176,
-0.2753942012786865,
-0.5026785731315613,
-0.014524324797093868,
0.11501401662826538,
-0.22599048912525177,
0.761189222... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.