qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
266,803
|
<p>I have several static factory patterns in my PHP library. However, memory footprint is getting out of hand and we want to reduce the number of files required during execution time. Here is an example of where we are today:</p>
<pre><code>require_once('Car.php');
require_once('Truck.php');
abstract class Auto
{
// ... some stuff ...
public static function Create($type)
{
switch ($type) {
case 'Truck':
return new Truck();
break;
case 'Car':
default:
return new Car();
break;
}
}
}
</code></pre>
<p>This is undesirable because Car.php AND Truck.php will need to be included even though only one or the other may be needed. As far as I know, require/include and their ..._once variation include libraries at the same scope as it's call. Is this true?</p>
<p>If so, I believe this would lead to a memory leak:</p>
<pre><code> abstract class Auto
{
// ... some stuff ...
public static function Create($type)
{
switch ($type) {
case 'Truck':
require_once('Truck.php');
return new Truck();
break;
case 'Car':
default:
require_once('Car.php');
return new Car();
break;
}
}
}
</code></pre>
<p>It looks to me that in the 2nd example, multiple calls to Create() would lead to multiple requires because of the scope of the call even though the require_once flavor is used.</p>
<p>Is this true? What is the best way to include libraries dynamically in php in an example such as these?</p>
<p>Thanks!</p>
|
[
{
"answer_id": 266820,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 4,
"selected": true,
"text": "require(\"autoloader.php\"); \n$x = new Car(); \n$x = new Bike(); \n"
},
{
"answer_id": 266828,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 2,
"selected": false,
"text": "require_once() new Truck() new Car() require_once"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20176/"
] |
266,805
|
<p>I'm trying to get rid of some spurious warnings in my SSIS Progress log. I'm getting a bunch of warnings about unused columns in tasks that use raw SQL to do their work. I have a Data Flow responsible for archiving data in a staging table prior to loading new data. The Data Flow looks like this:</p>
<pre><code>+--------------------+
| OLEDB Source task: |
| read staging table |
+--------------------+
|
|
+---------------------------+
| OLEDB Command task: |
| upsert into history table |
+---------------------------+
|
|
+---------------------------+
| OLEDB Command task: |
| delete from staging table |
+---------------------------+
</code></pre>
<p>my 'upsert' task is something like:</p>
<pre><code>--------------------------------------
-- update existing rows first...
update history
set field1 = s.field1
...
from history h
inner join staging s
on h.id = s.id
where h.last_edit_date <> s.last_edit_date -- only update changed records
-- ... then insert new rows
insert into history
select s.*
from staging s
join history h
on h.id = s.id
where h.id is null
--------------------------------------
</code></pre>
<p>The cleanup task is also a SQL command:</p>
<pre><code>--------------------------------------
delete from staging
--------------------------------------
</code></pre>
<p>Since the upsert task doesn't have any output column definitions, I'm getting a bunch of warnings in the log:</p>
<pre><code>[DTS.Pipeline] Warning: The output column "product_id" (693) on output
"OLE DB Source Output" (692) and component "read Piv_product staging table" (681)
is not subsequently used in the Data Flow task. Removing this unused output column
can increase Data Flow task performance.
</code></pre>
<p>How can I eliminate the references to those columns? I've tried dropping in a few different tasks, but none of them seem to let me 'swallow' the input columns and suppress them from the task's output. I'd like to keep my logs clean so I only see real problems. Any ideas?</p>
<p>Thanks!</p>
|
[
{
"answer_id": 306393,
"author": "AdamH",
"author_id": 21081,
"author_profile": "https://Stackoverflow.com/users/21081",
"pm_score": 0,
"selected": false,
"text": "DataFlow Task Execute SQL Task DataFlow Task OLE DB Destination"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34861/"
] |
266,809
|
<p>I would like to make my Java/Swing application compatible with the Services-menu available on Mac OS X. For example, so that the user could select some text in JTextArea and have it converted into speech by <strong>Services -> Speech -> Start Speaking Text</strong>.
Is there a simple way to achieve that?
(The application should still be able to run on platforms other than Mac OS X.)</p>
|
[
{
"answer_id": 11675159,
"author": "Dave",
"author_id": 347237,
"author_profile": "https://Stackoverflow.com/users/347237",
"pm_score": 0,
"selected": false,
"text": "String stuffYouWantToSay = \"StackOverflow Rocks!\";\nProcess p = null;\ntry {\n ProcessBuilder pb = new ProcessBuilder(\"/usr/bin/say\", stuffYouWantToSay);\n p = pb.start();\n} catch (Exception e) {\n // handle the error\n return;\n}\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12547/"
] |
266,818
|
<p>I need to see if a string value matches with an object value, but why won't this work?</p>
<pre><code>public int countPacks(String flavour) {
int counter = 0;
for(int index = 0; index < packets.size(); index++) {
if (packets.equals(flavour)) {
counter ++;
}
else {
System.out.println("You have not entered a correct flavour");
}
}
return counter;
}
</code></pre>
|
[
{
"answer_id": 266827,
"author": "micro",
"author_id": 23275,
"author_profile": "https://Stackoverflow.com/users/23275",
"pm_score": 2,
"selected": false,
"text": "if (packets.get(index).equals(flavour)) {\n ...\n"
},
{
"answer_id": 266831,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": false,
"text": "if (packets.get(index).equals(flavour))\n counter == 0"
},
{
"answer_id": 266873,
"author": "branchgabriel",
"author_id": 30807,
"author_profile": "https://Stackoverflow.com/users/30807",
"pm_score": 0,
"selected": false,
"text": "public int countPacks(String flavour, List packets)\n {\n int counter = 0;\n for (Iterator iter = packets.iterator(); iter.hasNext();) {\n Map packet = (Map) iter.next();\n\n if (packet.get(\"flavour\").toString().equalsIgnoreCase(flavour)) {\n counter ++;\n }\n else {\n System.out.println(\"You have not entered a correct flavour\");\n }\n } \n return counter; \n }\n"
},
{
"answer_id": 266985,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "public int countPacks(String flavor) {\n int numOccurrences = java.util.Collections.frequency(packets, flavor);\n if(numOccurrences == 0) {\n System.out.println(\"You have not entered a correct flavor\");\n }\n return numOccurrences;\n}\n"
},
{
"answer_id": 269347,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 2,
"selected": false,
"text": "public int countPacks(String flavour) {\n // [ The field represents a count. ]\n int count = 0;\n for(int index=0; index<packets.size(); ++index) {\n String packet = packets.get(index);\n if (packet.equals(flavour)) {\n ++count;\n }\n } \n // [The error mesage was printed for each non-match.\n // Even this is probably wrong,\n // as it should be valid to have no packs of a valid flavour.\n // Having the message in this method is actually a bit confused.]\n if (count == 0) {\n System.out.println(\"You have not entered a correct flavour\");\n }\n return count; \n}\n public int countPacks(String flavour) {\n int count = 0;\n for(String packet : packets) {\n if (packet.equals(flavour)) {\n ++count;\n }\n } \n if (count == 0) {\n System.out.println(\"You have not entered a correct flavour\");\n }\n return count; \n}\n public int countPacks(String flavour) {\n int count = Collections.frequency(packets, flavour);\n if (count == 0) {\n System.out.println(\"You have not entered a correct flavour\");\n }\n return count; \n}\n Map<String,Integer>"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
266,819
|
<p>Where is the best place to add a method to the integer class in Rails?
I'd like to add a <code>to_meters</code> and <code>to_miles</code> methods.</p>
|
[
{
"answer_id": 266840,
"author": "Zak",
"author_id": 2112692,
"author_profile": "https://Stackoverflow.com/users/2112692",
"pm_score": 2,
"selected": false,
"text": "Float feetToMiles(integer I) miles = Feet.feetToMiles(5280); miles = 1.0"
},
{
"answer_id": 266845,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 2,
"selected": false,
"text": "5.getArtist(); \n10.getEvent(); \n100.getTrack(); \n \"Bob\".createUser(); \n convert( 3 , { :from=>:miles, :to=>:meters }); \n"
},
{
"answer_id": 266867,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": -1,
"selected": false,
"text": "config/initializers/add_methods_that_are_naughty_to_numeric.rb\n"
},
{
"answer_id": 267325,
"author": "Cameron Booth",
"author_id": 14873,
"author_profile": "https://Stackoverflow.com/users/14873",
"pm_score": 2,
"selected": false,
"text": "class Feet\n def self.in_miles(feet)\n feet/5280\n end\nend\n Feet.in_miles 2313\n class Miles\n def self.from_feet(feet)\n feet/5280\n end\nend\n\nMiles.from_feet 2313\n"
},
{
"answer_id": 271621,
"author": "dennisjbell",
"author_id": 35394,
"author_profile": "https://Stackoverflow.com/users/35394",
"pm_score": 5,
"selected": true,
"text": ">> x = 47.feet.to_meters\n=> 14.3256\n>> x.inspect\n=> #<Unit 0xb795efb8 @value=14.3256, @type=:meter>\n"
},
{
"answer_id": 15269518,
"author": "AJcodez",
"author_id": 824377,
"author_profile": "https://Stackoverflow.com/users/824377",
"pm_score": 0,
"selected": false,
"text": "@length @unit class Distance\n\n @@conversion_rates = {\n meters: {\n feet: 3.28084,\n meters: 1.0\n }\n }\n\n def to(new_unit)\n new_length = @length * @@conversion_rates[@unit][new_unit]\n Distance.new( new_length, new_unit ) \n end\n\nend\n Distance.new(3, :meters).to(:feet)\n 3.meters.to_feet\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6705/"
] |
266,825
|
<p>I'd like to format a duration in seconds using a pattern like H:MM:SS. The current utilities in java are designed to format a time but not a duration.</p>
|
[
{
"answer_id": 266846,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": true,
"text": "PeriodFormatter Duration toPeriod PeriodType Period java.time.Duration getSeconds() public static String formatDuration(Duration duration) {\n long seconds = duration.getSeconds();\n long absSeconds = Math.abs(seconds);\n String positive = String.format(\n \"%d:%02d:%02d\",\n absSeconds / 3600,\n (absSeconds % 3600) / 60,\n absSeconds % 60);\n return seconds < 0 ? \"-\" + positive : positive;\n}\n"
},
{
"answer_id": 266970,
"author": "bobince",
"author_id": 18936,
"author_profile": "https://Stackoverflow.com/users/18936",
"pm_score": 8,
"selected": false,
"text": " String.format(\"%d:%02d:%02d\", s / 3600, (s % 3600) / 60, (s % 60));\n"
},
{
"answer_id": 6090189,
"author": "Mihai Vasilache",
"author_id": 453178,
"author_profile": "https://Stackoverflow.com/users/453178",
"pm_score": 5,
"selected": false,
"text": "long duration = 4 * 60 * 60 * 1000;\nSimpleDateFormat sdf = new SimpleDateFormat(\"HH:mm:ss.SSS\", Locale.getDefault());\nlog.info(\"Duration: \" + sdf.format(new Date(duration - TimeZone.getDefault().getRawOffset())));\n"
},
{
"answer_id": 18633466,
"author": "Gili Nachum",
"author_id": 121956,
"author_profile": "https://Stackoverflow.com/users/121956",
"pm_score": 7,
"selected": false,
"text": "DurationFormatUtils.formatDuration(millis, \"**H:mm:ss**\", true);\n"
},
{
"answer_id": 22776038,
"author": "sbclint",
"author_id": 3483443,
"author_profile": "https://Stackoverflow.com/users/3483443",
"pm_score": 2,
"selected": false,
"text": "public static String showDuration(LocalTime otherTime){ \n DateTimeFormatter df = DateTimeFormatter.ISO_LOCAL_TIME;\n LocalTime now = LocalTime.now();\n System.out.println(\"now: \" + now);\n System.out.println(\"otherTime: \" + otherTime);\n System.out.println(\"otherTime: \" + otherTime.format(df));\n\n Duration span = Duration.between(otherTime, now);\n LocalTime fTime = LocalTime.ofNanoOfDay(span.toNanos());\n String output = fTime.format(df);\n\n System.out.println(output);\n return output;\n}\n System.out.println(showDuration(LocalTime.of(9, 30, 0, 0)));\n otherTime: 09:30\notherTime: 09:30:00\n11:31:27.463\n11:31:27.463\n"
},
{
"answer_id": 28131899,
"author": "patrick",
"author_id": 2263885,
"author_profile": "https://Stackoverflow.com/users/2263885",
"pm_score": 3,
"selected": false,
"text": "java.time import java.time.Duration;\nimport java.time.LocalDateTime;\nimport java.time.format.DateTimeFormatter;\nimport java.time.format.DateTimeFormatterBuilder;\nimport java.time.temporal.ChronoField;\nimport java.time.temporal.Temporal;\nimport java.time.temporal.TemporalAccessor;\nimport java.time.temporal.TemporalField;\nimport java.time.temporal.UnsupportedTemporalTypeException;\n\npublic class TemporalDuration implements TemporalAccessor {\n private static final Temporal BASE_TEMPORAL = LocalDateTime.of(0, 1, 1, 0, 0);\n\n private final Duration duration;\n private final Temporal temporal;\n\n public TemporalDuration(Duration duration) {\n this.duration = duration;\n this.temporal = duration.addTo(BASE_TEMPORAL);\n }\n\n @Override\n public boolean isSupported(TemporalField field) {\n if(!temporal.isSupported(field)) return false;\n long value = temporal.getLong(field)-BASE_TEMPORAL.getLong(field);\n return value!=0L;\n }\n\n @Override\n public long getLong(TemporalField field) {\n if(!isSupported(field)) throw new UnsupportedTemporalTypeException(new StringBuilder().append(field.toString()).toString());\n return temporal.getLong(field)-BASE_TEMPORAL.getLong(field);\n }\n\n public Duration getDuration() {\n return duration;\n }\n\n @Override\n public String toString() {\n return dtf.format(this);\n }\n\n private static final DateTimeFormatter dtf = new DateTimeFormatterBuilder()\n .optionalStart()//second\n .optionalStart()//minute\n .optionalStart()//hour\n .optionalStart()//day\n .optionalStart()//month\n .optionalStart()//year\n .appendValue(ChronoField.YEAR).appendLiteral(\" Years \").optionalEnd()\n .appendValue(ChronoField.MONTH_OF_YEAR).appendLiteral(\" Months \").optionalEnd()\n .appendValue(ChronoField.DAY_OF_MONTH).appendLiteral(\" Days \").optionalEnd()\n .appendValue(ChronoField.HOUR_OF_DAY).appendLiteral(\" Hours \").optionalEnd()\n .appendValue(ChronoField.MINUTE_OF_HOUR).appendLiteral(\" Minutes \").optionalEnd()\n .appendValue(ChronoField.SECOND_OF_MINUTE).appendLiteral(\" Seconds\").optionalEnd()\n .toFormatter();\n\n}\n"
},
{
"answer_id": 39344834,
"author": "Pavel_H",
"author_id": 1682715,
"author_profile": "https://Stackoverflow.com/users/1682715",
"pm_score": 3,
"selected": false,
"text": "import static java.time.temporal.ChronoUnit.DAYS;\nimport static java.time.temporal.ChronoUnit.HOURS;\nimport static java.time.temporal.ChronoUnit.MINUTES;\nimport static java.time.temporal.ChronoUnit.SECONDS;\n\nimport java.time.Duration;\n\npublic class DurationSample {\n public static void main(String[] args) {\n //Let's say duration of 2days 3hours 12minutes and 46seconds\n Duration d = Duration.ZERO.plus(2, DAYS).plus(3, HOURS).plus(12, MINUTES).plus(46, SECONDS);\n\n //in case of negative duration\n if(d.isNegative()) d = d.negated();\n\n //format DAYS HOURS MINUTES SECONDS \n System.out.printf(\"Total duration is %sdays %shrs %smin %ssec.\\n\", d.toDays(), d.toHours() % 24, d.toMinutes() % 60, d.getSeconds() % 60);\n\n //or format HOURS MINUTES SECONDS \n System.out.printf(\"Or total duration is %shrs %smin %sec.\\n\", d.toHours(), d.toMinutes() % 60, d.getSeconds() % 60);\n\n //or format MINUTES SECONDS \n System.out.printf(\"Or total duration is %smin %ssec.\\n\", d.toMinutes(), d.getSeconds() % 60);\n\n //or format SECONDS only \n System.out.printf(\"Or total duration is %ssec.\\n\", d.getSeconds());\n }\n}\n"
},
{
"answer_id": 40594963,
"author": "Meno Hochschild",
"author_id": 2491410,
"author_profile": "https://Stackoverflow.com/users/2491410",
"pm_score": 0,
"selected": false,
"text": "Apache DurationFormatUtils Duration<ClockUnit> duration =\n Duration.of(-573421, ClockUnit.SECONDS) // input in seconds only\n .with(Duration.STD_CLOCK_PERIOD); // performs normalization to h:mm:ss-structure\nString fs = Duration.formatter(ClockUnit.class, \"+##h:mm:ss\").format(duration);\nSystem.out.println(fs); // output => -159:17:01\n"
},
{
"answer_id": 43578628,
"author": "Bax",
"author_id": 868975,
"author_profile": "https://Stackoverflow.com/users/868975",
"pm_score": 2,
"selected": false,
"text": "String duration(Temporal from, Temporal to) {\n final StringBuilder builder = new StringBuilder();\n for (ChronoUnit unit : new ChronoUnit[]{YEARS, MONTHS, WEEKS, DAYS, HOURS, MINUTES, SECONDS}) {\n long amount = unit.between(from, to);\n if (amount == 0) {\n continue;\n }\n builder.append(' ')\n .append(amount)\n .append(' ')\n .append(unit.name().toLowerCase());\n from = from.plus(amount, unit);\n }\n return builder.toString().trim();\n}\n"
},
{
"answer_id": 44343699,
"author": "Ole V.V.",
"author_id": 5772882,
"author_profile": "https://Stackoverflow.com/users/5772882",
"pm_score": 6,
"selected": false,
"text": "Duration LocalDateTime start = LocalDateTime.of(2019, Month.JANUARY, 17, 15, 24, 12);\n LocalDateTime end = LocalDateTime.of(2019, Month.JANUARY, 18, 15, 43, 33);\n Duration diff = Duration.between(start, end);\n String hms = String.format(\"%d:%02d:%02d\", \n diff.toHours(), \n diff.toMinutesPart(), \n diff.toSecondsPart());\n System.out.println(hms);\n"
},
{
"answer_id": 44797053,
"author": "mksteve",
"author_id": 5129715,
"author_profile": "https://Stackoverflow.com/users/5129715",
"pm_score": 3,
"selected": false,
"text": "public static String formatInterval(final long interval, boolean millisecs )\n{\n final long hr = TimeUnit.MILLISECONDS.toHours(interval);\n final long min = TimeUnit.MILLISECONDS.toMinutes(interval) %60;\n final long sec = TimeUnit.MILLISECONDS.toSeconds(interval) %60;\n final long ms = TimeUnit.MILLISECONDS.toMillis(interval) %1000;\n if( millisecs ) {\n return String.format(\"%02d:%02d:%02d.%03d\", hr, min, sec, ms);\n } else {\n return String.format(\"%02d:%02d:%02d\", hr, min, sec );\n }\n}\n"
},
{
"answer_id": 49628638,
"author": "YourBestBet",
"author_id": 571856,
"author_profile": "https://Stackoverflow.com/users/571856",
"pm_score": -1,
"selected": false,
"text": "def prettyDuration(str:List[String],seconds:Long):List[String]={\n seconds match {\n case t if t < 60 => str:::List(s\"${t} seconds\")\n case t if (t >= 60 && t< 3600 ) => List(s\"${t / 60} minutes\"):::prettyDuration(str, t%60)\n case t if (t >= 3600 && t< 3600*24 ) => List(s\"${t / 3600} hours\"):::prettyDuration(str, t%3600)\n case t if (t>= 3600*24 ) => List(s\"${t / (3600*24)} days\"):::prettyDuration(str, t%(3600*24))\n }\n}\nval dur = prettyDuration(List.empty[String], 12345).mkString(\"\")\n"
},
{
"answer_id": 51091602,
"author": "lauhub",
"author_id": 1011366,
"author_profile": "https://Stackoverflow.com/users/1011366",
"pm_score": 4,
"selected": false,
"text": "Duration public static String format(Duration d) {\n long days = d.toDays();\n d = d.minusDays(days);\n long hours = d.toHours();\n d = d.minusHours(hours);\n long minutes = d.toMinutes();\n d = d.minusMinutes(minutes);\n long seconds = d.getSeconds() ;\n return \n (days == 0?\"\":days+\" days,\")+ \n (hours == 0?\"\":hours+\" hours,\")+ \n (minutes == 0?\"\":minutes+\" minutes,\")+ \n (seconds == 0?\"\":seconds+\" seconds,\");\n}\n"
},
{
"answer_id": 52992235,
"author": "dpoetzsch",
"author_id": 3594403,
"author_profile": "https://Stackoverflow.com/users/3594403",
"pm_score": -1,
"selected": false,
"text": "def prettyDuration(seconds: Long): List[String] = seconds match {\n case t if t < 60 => List(s\"${t} seconds\")\n case t if t < 3600 => s\"${t / 60} minutes\" :: prettyDuration(t % 60)\n case t if t < 3600*24 => s\"${t / 3600} hours\" :: prettyDuration(t % 3600)\n case t => s\"${t / (3600*24)} days\" :: prettyDuration(t % (3600*24))\n}\n\nval dur = prettyDuration(12345).mkString(\", \") // => 3 hours, 25 minutes, 45 seconds\n"
},
{
"answer_id": 54794030,
"author": "ctg",
"author_id": 6157999,
"author_profile": "https://Stackoverflow.com/users/6157999",
"pm_score": 4,
"selected": false,
"text": "DateTimeFormatter.ISO_LOCAL_TIME.format(value.addTo(LocalTime.of(0, 0)))"
},
{
"answer_id": 62466864,
"author": "Stephen",
"author_id": 37193,
"author_profile": "https://Stackoverflow.com/users/37193",
"pm_score": -1,
"selected": false,
"text": "def formatDuration(duration: Duration): String = {\n import duration._ // get access to all the members ;)\n f\"$toDaysPart $toHoursPart%02d:$toMinutesPart%02d:$toSecondsPart%02d:$toMillisPart%03d\"\n}\n $toHoursPart f\"...\" printf String.format $ 1 14:06:32.583 f String.format(\"1 %02d:%02d:%02d.%03d\", 14, 6, 32, 583)"
},
{
"answer_id": 62702984,
"author": "ipserc",
"author_id": 12701130,
"author_profile": "https://Stackoverflow.com/users/12701130",
"pm_score": 1,
"selected": false,
"text": "private static String strDuration(long duration) {\n int ms, s, m, h, d;\n double dec;\n double time = duration * 1.0;\n\n time = (time / 1000.0);\n dec = time % 1;\n time = time - dec;\n ms = (int)(dec * 1000);\n\n time = (time / 60.0);\n dec = time % 1;\n time = time - dec;\n s = (int)(dec * 60);\n\n time = (time / 60.0);\n dec = time % 1;\n time = time - dec;\n m = (int)(dec * 60);\n\n time = (time / 24.0);\n dec = time % 1;\n time = time - dec;\n h = (int)(dec * 24);\n \n d = (int)time;\n \n return (String.format(\"%d d - %02d:%02d:%02d.%03d\", d, h, m, s, ms));\n}\n"
},
{
"answer_id": 63711661,
"author": "Sergei Maleev",
"author_id": 12761967,
"author_profile": "https://Stackoverflow.com/users/12761967",
"pm_score": 3,
"selected": false,
"text": "import android.text.format.DateUtils\n DateUtils.formatElapsedTime()"
},
{
"answer_id": 65501046,
"author": "Arvind Kumar Avinash",
"author_id": 10819573,
"author_profile": "https://Stackoverflow.com/users/10819573",
"pm_score": 3,
"selected": false,
"text": "java.time.Duration import java.time.Duration;\nimport java.time.LocalDateTime;\nimport java.time.Month;\n\npublic class Main {\n public static void main(String[] args) {\n LocalDateTime startDateTime = LocalDateTime.of(2020, Month.DECEMBER, 10, 15, 20, 25);\n LocalDateTime endDateTime = LocalDateTime.of(2020, Month.DECEMBER, 10, 18, 24, 30);\n\n Duration duration = Duration.between(startDateTime, endDateTime);\n // Default format\n System.out.println(duration);\n\n // Custom format\n // ####################################Java-8####################################\n String formattedElapsedTime = String.format(\"%02d:%02d:%02d\", duration.toHours() % 24,\n duration.toMinutes() % 60, duration.toSeconds() % 60);\n System.out.println(formattedElapsedTime);\n // ##############################################################################\n\n // ####################################Java-9####################################\n formattedElapsedTime = String.format(\"%02d:%02d:%02d\", duration.toHoursPart(), duration.toMinutesPart(),\n duration.toSecondsPart());\n System.out.println(formattedElapsedTime);\n // ##############################################################################\n }\n}\n PT3H4M5S\n03:04:05\n03:04:05\n"
},
{
"answer_id": 65586659,
"author": "stanley",
"author_id": 14947476,
"author_profile": "https://Stackoverflow.com/users/14947476",
"pm_score": 3,
"selected": false,
"text": "public String formatDuration(Duration duration) {\n DateTimeFormatter formatter = DateTimeFormatter.ofPattern(\"h:mm.SSS\");\n return LocalTime.ofNanoOfDay(duration.toNanos()).format(formatter);\n}\n"
},
{
"answer_id": 66066413,
"author": "sschrass",
"author_id": 1087479,
"author_profile": "https://Stackoverflow.com/users/1087479",
"pm_score": 0,
"selected": false,
"text": ".toFooPart() Duration.ofMinutes(110L).toMinutesPart() == 50\n"
},
{
"answer_id": 69717677,
"author": "Graham Lea",
"author_id": 243104,
"author_profile": "https://Stackoverflow.com/users/243104",
"pm_score": 2,
"selected": false,
"text": "java.time.Duration duration.run {\n \"%d:%02d:%02d.%03d\".format(toHours(), toMinutesPart(), toSecondsPart(), toMillisPart())\n}\n 120:56:03.004"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
266,849
|
<p>I'm conducting experiments regarding e-mail spam. One of these experiments require sending mail thru Tor. Since I'm using Python and smtplib for my experiments, I'm looking for a way to use the Tor proxy (or other method) to perform that mail sending.
Ideas how this can be done?</p>
|
[
{
"answer_id": 266846,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": true,
"text": "PeriodFormatter Duration toPeriod PeriodType Period java.time.Duration getSeconds() public static String formatDuration(Duration duration) {\n long seconds = duration.getSeconds();\n long absSeconds = Math.abs(seconds);\n String positive = String.format(\n \"%d:%02d:%02d\",\n absSeconds / 3600,\n (absSeconds % 3600) / 60,\n absSeconds % 60);\n return seconds < 0 ? \"-\" + positive : positive;\n}\n"
},
{
"answer_id": 266970,
"author": "bobince",
"author_id": 18936,
"author_profile": "https://Stackoverflow.com/users/18936",
"pm_score": 8,
"selected": false,
"text": " String.format(\"%d:%02d:%02d\", s / 3600, (s % 3600) / 60, (s % 60));\n"
},
{
"answer_id": 6090189,
"author": "Mihai Vasilache",
"author_id": 453178,
"author_profile": "https://Stackoverflow.com/users/453178",
"pm_score": 5,
"selected": false,
"text": "long duration = 4 * 60 * 60 * 1000;\nSimpleDateFormat sdf = new SimpleDateFormat(\"HH:mm:ss.SSS\", Locale.getDefault());\nlog.info(\"Duration: \" + sdf.format(new Date(duration - TimeZone.getDefault().getRawOffset())));\n"
},
{
"answer_id": 18633466,
"author": "Gili Nachum",
"author_id": 121956,
"author_profile": "https://Stackoverflow.com/users/121956",
"pm_score": 7,
"selected": false,
"text": "DurationFormatUtils.formatDuration(millis, \"**H:mm:ss**\", true);\n"
},
{
"answer_id": 22776038,
"author": "sbclint",
"author_id": 3483443,
"author_profile": "https://Stackoverflow.com/users/3483443",
"pm_score": 2,
"selected": false,
"text": "public static String showDuration(LocalTime otherTime){ \n DateTimeFormatter df = DateTimeFormatter.ISO_LOCAL_TIME;\n LocalTime now = LocalTime.now();\n System.out.println(\"now: \" + now);\n System.out.println(\"otherTime: \" + otherTime);\n System.out.println(\"otherTime: \" + otherTime.format(df));\n\n Duration span = Duration.between(otherTime, now);\n LocalTime fTime = LocalTime.ofNanoOfDay(span.toNanos());\n String output = fTime.format(df);\n\n System.out.println(output);\n return output;\n}\n System.out.println(showDuration(LocalTime.of(9, 30, 0, 0)));\n otherTime: 09:30\notherTime: 09:30:00\n11:31:27.463\n11:31:27.463\n"
},
{
"answer_id": 28131899,
"author": "patrick",
"author_id": 2263885,
"author_profile": "https://Stackoverflow.com/users/2263885",
"pm_score": 3,
"selected": false,
"text": "java.time import java.time.Duration;\nimport java.time.LocalDateTime;\nimport java.time.format.DateTimeFormatter;\nimport java.time.format.DateTimeFormatterBuilder;\nimport java.time.temporal.ChronoField;\nimport java.time.temporal.Temporal;\nimport java.time.temporal.TemporalAccessor;\nimport java.time.temporal.TemporalField;\nimport java.time.temporal.UnsupportedTemporalTypeException;\n\npublic class TemporalDuration implements TemporalAccessor {\n private static final Temporal BASE_TEMPORAL = LocalDateTime.of(0, 1, 1, 0, 0);\n\n private final Duration duration;\n private final Temporal temporal;\n\n public TemporalDuration(Duration duration) {\n this.duration = duration;\n this.temporal = duration.addTo(BASE_TEMPORAL);\n }\n\n @Override\n public boolean isSupported(TemporalField field) {\n if(!temporal.isSupported(field)) return false;\n long value = temporal.getLong(field)-BASE_TEMPORAL.getLong(field);\n return value!=0L;\n }\n\n @Override\n public long getLong(TemporalField field) {\n if(!isSupported(field)) throw new UnsupportedTemporalTypeException(new StringBuilder().append(field.toString()).toString());\n return temporal.getLong(field)-BASE_TEMPORAL.getLong(field);\n }\n\n public Duration getDuration() {\n return duration;\n }\n\n @Override\n public String toString() {\n return dtf.format(this);\n }\n\n private static final DateTimeFormatter dtf = new DateTimeFormatterBuilder()\n .optionalStart()//second\n .optionalStart()//minute\n .optionalStart()//hour\n .optionalStart()//day\n .optionalStart()//month\n .optionalStart()//year\n .appendValue(ChronoField.YEAR).appendLiteral(\" Years \").optionalEnd()\n .appendValue(ChronoField.MONTH_OF_YEAR).appendLiteral(\" Months \").optionalEnd()\n .appendValue(ChronoField.DAY_OF_MONTH).appendLiteral(\" Days \").optionalEnd()\n .appendValue(ChronoField.HOUR_OF_DAY).appendLiteral(\" Hours \").optionalEnd()\n .appendValue(ChronoField.MINUTE_OF_HOUR).appendLiteral(\" Minutes \").optionalEnd()\n .appendValue(ChronoField.SECOND_OF_MINUTE).appendLiteral(\" Seconds\").optionalEnd()\n .toFormatter();\n\n}\n"
},
{
"answer_id": 39344834,
"author": "Pavel_H",
"author_id": 1682715,
"author_profile": "https://Stackoverflow.com/users/1682715",
"pm_score": 3,
"selected": false,
"text": "import static java.time.temporal.ChronoUnit.DAYS;\nimport static java.time.temporal.ChronoUnit.HOURS;\nimport static java.time.temporal.ChronoUnit.MINUTES;\nimport static java.time.temporal.ChronoUnit.SECONDS;\n\nimport java.time.Duration;\n\npublic class DurationSample {\n public static void main(String[] args) {\n //Let's say duration of 2days 3hours 12minutes and 46seconds\n Duration d = Duration.ZERO.plus(2, DAYS).plus(3, HOURS).plus(12, MINUTES).plus(46, SECONDS);\n\n //in case of negative duration\n if(d.isNegative()) d = d.negated();\n\n //format DAYS HOURS MINUTES SECONDS \n System.out.printf(\"Total duration is %sdays %shrs %smin %ssec.\\n\", d.toDays(), d.toHours() % 24, d.toMinutes() % 60, d.getSeconds() % 60);\n\n //or format HOURS MINUTES SECONDS \n System.out.printf(\"Or total duration is %shrs %smin %sec.\\n\", d.toHours(), d.toMinutes() % 60, d.getSeconds() % 60);\n\n //or format MINUTES SECONDS \n System.out.printf(\"Or total duration is %smin %ssec.\\n\", d.toMinutes(), d.getSeconds() % 60);\n\n //or format SECONDS only \n System.out.printf(\"Or total duration is %ssec.\\n\", d.getSeconds());\n }\n}\n"
},
{
"answer_id": 40594963,
"author": "Meno Hochschild",
"author_id": 2491410,
"author_profile": "https://Stackoverflow.com/users/2491410",
"pm_score": 0,
"selected": false,
"text": "Apache DurationFormatUtils Duration<ClockUnit> duration =\n Duration.of(-573421, ClockUnit.SECONDS) // input in seconds only\n .with(Duration.STD_CLOCK_PERIOD); // performs normalization to h:mm:ss-structure\nString fs = Duration.formatter(ClockUnit.class, \"+##h:mm:ss\").format(duration);\nSystem.out.println(fs); // output => -159:17:01\n"
},
{
"answer_id": 43578628,
"author": "Bax",
"author_id": 868975,
"author_profile": "https://Stackoverflow.com/users/868975",
"pm_score": 2,
"selected": false,
"text": "String duration(Temporal from, Temporal to) {\n final StringBuilder builder = new StringBuilder();\n for (ChronoUnit unit : new ChronoUnit[]{YEARS, MONTHS, WEEKS, DAYS, HOURS, MINUTES, SECONDS}) {\n long amount = unit.between(from, to);\n if (amount == 0) {\n continue;\n }\n builder.append(' ')\n .append(amount)\n .append(' ')\n .append(unit.name().toLowerCase());\n from = from.plus(amount, unit);\n }\n return builder.toString().trim();\n}\n"
},
{
"answer_id": 44343699,
"author": "Ole V.V.",
"author_id": 5772882,
"author_profile": "https://Stackoverflow.com/users/5772882",
"pm_score": 6,
"selected": false,
"text": "Duration LocalDateTime start = LocalDateTime.of(2019, Month.JANUARY, 17, 15, 24, 12);\n LocalDateTime end = LocalDateTime.of(2019, Month.JANUARY, 18, 15, 43, 33);\n Duration diff = Duration.between(start, end);\n String hms = String.format(\"%d:%02d:%02d\", \n diff.toHours(), \n diff.toMinutesPart(), \n diff.toSecondsPart());\n System.out.println(hms);\n"
},
{
"answer_id": 44797053,
"author": "mksteve",
"author_id": 5129715,
"author_profile": "https://Stackoverflow.com/users/5129715",
"pm_score": 3,
"selected": false,
"text": "public static String formatInterval(final long interval, boolean millisecs )\n{\n final long hr = TimeUnit.MILLISECONDS.toHours(interval);\n final long min = TimeUnit.MILLISECONDS.toMinutes(interval) %60;\n final long sec = TimeUnit.MILLISECONDS.toSeconds(interval) %60;\n final long ms = TimeUnit.MILLISECONDS.toMillis(interval) %1000;\n if( millisecs ) {\n return String.format(\"%02d:%02d:%02d.%03d\", hr, min, sec, ms);\n } else {\n return String.format(\"%02d:%02d:%02d\", hr, min, sec );\n }\n}\n"
},
{
"answer_id": 49628638,
"author": "YourBestBet",
"author_id": 571856,
"author_profile": "https://Stackoverflow.com/users/571856",
"pm_score": -1,
"selected": false,
"text": "def prettyDuration(str:List[String],seconds:Long):List[String]={\n seconds match {\n case t if t < 60 => str:::List(s\"${t} seconds\")\n case t if (t >= 60 && t< 3600 ) => List(s\"${t / 60} minutes\"):::prettyDuration(str, t%60)\n case t if (t >= 3600 && t< 3600*24 ) => List(s\"${t / 3600} hours\"):::prettyDuration(str, t%3600)\n case t if (t>= 3600*24 ) => List(s\"${t / (3600*24)} days\"):::prettyDuration(str, t%(3600*24))\n }\n}\nval dur = prettyDuration(List.empty[String], 12345).mkString(\"\")\n"
},
{
"answer_id": 51091602,
"author": "lauhub",
"author_id": 1011366,
"author_profile": "https://Stackoverflow.com/users/1011366",
"pm_score": 4,
"selected": false,
"text": "Duration public static String format(Duration d) {\n long days = d.toDays();\n d = d.minusDays(days);\n long hours = d.toHours();\n d = d.minusHours(hours);\n long minutes = d.toMinutes();\n d = d.minusMinutes(minutes);\n long seconds = d.getSeconds() ;\n return \n (days == 0?\"\":days+\" days,\")+ \n (hours == 0?\"\":hours+\" hours,\")+ \n (minutes == 0?\"\":minutes+\" minutes,\")+ \n (seconds == 0?\"\":seconds+\" seconds,\");\n}\n"
},
{
"answer_id": 52992235,
"author": "dpoetzsch",
"author_id": 3594403,
"author_profile": "https://Stackoverflow.com/users/3594403",
"pm_score": -1,
"selected": false,
"text": "def prettyDuration(seconds: Long): List[String] = seconds match {\n case t if t < 60 => List(s\"${t} seconds\")\n case t if t < 3600 => s\"${t / 60} minutes\" :: prettyDuration(t % 60)\n case t if t < 3600*24 => s\"${t / 3600} hours\" :: prettyDuration(t % 3600)\n case t => s\"${t / (3600*24)} days\" :: prettyDuration(t % (3600*24))\n}\n\nval dur = prettyDuration(12345).mkString(\", \") // => 3 hours, 25 minutes, 45 seconds\n"
},
{
"answer_id": 54794030,
"author": "ctg",
"author_id": 6157999,
"author_profile": "https://Stackoverflow.com/users/6157999",
"pm_score": 4,
"selected": false,
"text": "DateTimeFormatter.ISO_LOCAL_TIME.format(value.addTo(LocalTime.of(0, 0)))"
},
{
"answer_id": 62466864,
"author": "Stephen",
"author_id": 37193,
"author_profile": "https://Stackoverflow.com/users/37193",
"pm_score": -1,
"selected": false,
"text": "def formatDuration(duration: Duration): String = {\n import duration._ // get access to all the members ;)\n f\"$toDaysPart $toHoursPart%02d:$toMinutesPart%02d:$toSecondsPart%02d:$toMillisPart%03d\"\n}\n $toHoursPart f\"...\" printf String.format $ 1 14:06:32.583 f String.format(\"1 %02d:%02d:%02d.%03d\", 14, 6, 32, 583)"
},
{
"answer_id": 62702984,
"author": "ipserc",
"author_id": 12701130,
"author_profile": "https://Stackoverflow.com/users/12701130",
"pm_score": 1,
"selected": false,
"text": "private static String strDuration(long duration) {\n int ms, s, m, h, d;\n double dec;\n double time = duration * 1.0;\n\n time = (time / 1000.0);\n dec = time % 1;\n time = time - dec;\n ms = (int)(dec * 1000);\n\n time = (time / 60.0);\n dec = time % 1;\n time = time - dec;\n s = (int)(dec * 60);\n\n time = (time / 60.0);\n dec = time % 1;\n time = time - dec;\n m = (int)(dec * 60);\n\n time = (time / 24.0);\n dec = time % 1;\n time = time - dec;\n h = (int)(dec * 24);\n \n d = (int)time;\n \n return (String.format(\"%d d - %02d:%02d:%02d.%03d\", d, h, m, s, ms));\n}\n"
},
{
"answer_id": 63711661,
"author": "Sergei Maleev",
"author_id": 12761967,
"author_profile": "https://Stackoverflow.com/users/12761967",
"pm_score": 3,
"selected": false,
"text": "import android.text.format.DateUtils\n DateUtils.formatElapsedTime()"
},
{
"answer_id": 65501046,
"author": "Arvind Kumar Avinash",
"author_id": 10819573,
"author_profile": "https://Stackoverflow.com/users/10819573",
"pm_score": 3,
"selected": false,
"text": "java.time.Duration import java.time.Duration;\nimport java.time.LocalDateTime;\nimport java.time.Month;\n\npublic class Main {\n public static void main(String[] args) {\n LocalDateTime startDateTime = LocalDateTime.of(2020, Month.DECEMBER, 10, 15, 20, 25);\n LocalDateTime endDateTime = LocalDateTime.of(2020, Month.DECEMBER, 10, 18, 24, 30);\n\n Duration duration = Duration.between(startDateTime, endDateTime);\n // Default format\n System.out.println(duration);\n\n // Custom format\n // ####################################Java-8####################################\n String formattedElapsedTime = String.format(\"%02d:%02d:%02d\", duration.toHours() % 24,\n duration.toMinutes() % 60, duration.toSeconds() % 60);\n System.out.println(formattedElapsedTime);\n // ##############################################################################\n\n // ####################################Java-9####################################\n formattedElapsedTime = String.format(\"%02d:%02d:%02d\", duration.toHoursPart(), duration.toMinutesPart(),\n duration.toSecondsPart());\n System.out.println(formattedElapsedTime);\n // ##############################################################################\n }\n}\n PT3H4M5S\n03:04:05\n03:04:05\n"
},
{
"answer_id": 65586659,
"author": "stanley",
"author_id": 14947476,
"author_profile": "https://Stackoverflow.com/users/14947476",
"pm_score": 3,
"selected": false,
"text": "public String formatDuration(Duration duration) {\n DateTimeFormatter formatter = DateTimeFormatter.ofPattern(\"h:mm.SSS\");\n return LocalTime.ofNanoOfDay(duration.toNanos()).format(formatter);\n}\n"
},
{
"answer_id": 66066413,
"author": "sschrass",
"author_id": 1087479,
"author_profile": "https://Stackoverflow.com/users/1087479",
"pm_score": 0,
"selected": false,
"text": ".toFooPart() Duration.ofMinutes(110L).toMinutesPart() == 50\n"
},
{
"answer_id": 69717677,
"author": "Graham Lea",
"author_id": 243104,
"author_profile": "https://Stackoverflow.com/users/243104",
"pm_score": 2,
"selected": false,
"text": "java.time.Duration duration.run {\n \"%d:%02d:%02d.%03d\".format(toHours(), toMinutesPart(), toSecondsPart(), toMillisPart())\n}\n 120:56:03.004"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9941/"
] |
266,854
|
<p>I frequently run into large, non-template classes in C++ where simple methods are defined directly in the class body in the header file instead of separately in the implementation file. For example:</p>
<pre><code>class Foo {
int getBar() const { return bar; }
...
};
</code></pre>
<p>Why do this? It seems like there are disadvantages. The implementation is not as hidden as it should be, the code is less readable, and there would also be an increased burden on the compiler if the class's header file is included in many different places.</p>
<p>My guess is that people intend for these functions to be inlined in other modules, which could improve performance significantly. However, I've heard newer compilers can do inlining (and other interprocedural optimizations) at link-time across modules. How broad is the support for this kind of link-time optimization, and does it actually make these kind of definitions unnecessary? Are there any other good reasons for these definitions?</p>
|
[
{
"answer_id": 266868,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 5,
"selected": true,
"text": "inline"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1891/"
] |
266,857
|
<p>I'm writing a Rails plugin that includes some partials. I'd like to test the partials, but I'm having a hard time setting up a test that will render them. There's no associated controller, so I'm just faking one:</p>
<pre><code>require 'action_controller'
require 'active_support'
require 'action_pack'
require 'action_view'
class MyTest < Test::Unit::TestCase
def setup
@renderer = ActionController::Base.new
@renderer.append_view_path File.expand_path(File.join(File.dirname(__FILE__), '..', 'views'))
end
def test_renders_link
result = @renderer.render(:partial => '/something')
assert ...
end
end
</code></pre>
<p>But that <code>:render</code> call always blows up. I've tried using an <code>ActionView::Base</code> instead of an <code>ActionController::Base</code>, but that gets even less far.</p>
<p>Has anyone had any success?</p>
|
[
{
"answer_id": 267055,
"author": "James A. Rosen",
"author_id": 1190,
"author_profile": "https://Stackoverflow.com/users/1190",
"pm_score": 0,
"selected": false,
"text": "require 'action_controller'\nrequire 'active_support'\nrequire 'action_pack'\nrequire 'action_view'\nrequire 'action_controller/test_case'\n\nclass StubController < ActionController::Base\n append_view_path '...'\n def _renderizer; render params[:args]; end\n def rescue_action(e) raise e end;\nend\n\nclass MyTest < ActionController::TestCase\n self.controller_class = StubController\n def render(args); get :_renderizer, :args => args; end \n def test_xxx\n render :partial => ...\n end\nend\n ActionController::RoutingError: No route matches {:action=>\"_renderizer\", :controller=>\"\", :args=>{:locals=>{:...}, :partial=>\"/my_partial\"}}"
},
{
"answer_id": 267121,
"author": "James A. Rosen",
"author_id": 1190,
"author_profile": "https://Stackoverflow.com/users/1190",
"pm_score": 2,
"selected": true,
"text": "require 'action_controller'\nrequire 'active_support'\nrequire 'action_pack'\nrequire 'action_view'\nrequire 'action_controller/test_case'\n\nclass StubController < ActionController::Base\n helper MyHelper\n append_view_path '...'\n attr_accessor :thing\n def my_partial\n render :partial => '/my_partial', :locals => { :thing => thing }\n end\n def rescue_action(e) raise e end;\nend\n\nclass MyTestCase < ActionController::TestCase\n self.controller_class = StubController\n def setup\n @controller.thing = ...\n get :my_partial\n assert ...\n end\nend\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] |
266,870
|
<p>I'm reading <em>The C++ Programming Language.</em> In it Stroustrup states that <code>sizeof(char) == 1</code> and <code>1 <= sizeof(bool)</code>. The specifics depend on the implementation. Why would such a simple value as a boolean take the same space as a char?</p>
|
[
{
"answer_id": 268329,
"author": "sep",
"author_id": 30333,
"author_profile": "https://Stackoverflow.com/users/30333",
"pm_score": 2,
"selected": false,
"text": " bool b[9];\n bool *pb0 = &b[0];\n bool *pb1 = &b[1];\n\n for (int counter=0; counter<9; ++counter)\n {\n // some code here to fill b with values\n b[counter] = true;\n\n }\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32944/"
] |
266,874
|
<p>I'm setting the below variables in my vimrc to control how windows get split when I bring up the file explorer plugin for vim. But it appears these variables are not being read because they have no effect on how the file explorer window is displayed. I'm new to vim. I know the vimrc file is being read because I can make other setting changes and they get picked up but these don't work. What am I missing?</p>
<p><code>let g:explWinSize=10</code></p>
<p><code>let g:explSplitBelow=1</code></p>
<p><code>let g:explDetailedHelp=0</code></p>
|
[
{
"answer_id": 269952,
"author": "Zathrus",
"author_id": 16220,
"author_profile": "https://Stackoverflow.com/users/16220",
"pm_score": 2,
"selected": true,
"text": "let g:netrw_winsize=10\nlet g:netrw_alto=1\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16973/"
] |
266,877
|
<p>I have a very specific html table construct that seems to reveal a Gecko bug.</p>
<p>Here's a distilled version of the problem. Observe the following table in a gecko-based browser (FF, for example): (you'll have to copy and paste this into a new file)</p>
<pre><code><style>
table.example{
border-collapse:collapse;
}
table.example td {
border:1px solid red;
}
</style>
<table class="example">
<thead>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td rowspan="3">3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>1</td>
<td rowspan="2">2</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
</tr>
</tbody>
</table>
</code></pre>
<p>There's a line missing over the "3" in the bottom-right cell -- view it in any other browser and the line will appear as expected. Interestingly, ditch the thead section of the table and look what we get:</p>
<pre><code><style>
table.example{
border-collapse:collapse;
}
table.example td {
border:1px solid red;
}
</style>
<table class="example">
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td rowspan="3">3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>1</td>
<td rowspan="2">2</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
</tr>
</tbody>
</table>
</code></pre>
<p>Doing that makes it work. Has anyone seen this? I suppose I'll just get rid of my thead section for now as a workaround though it makes the table rather less accessible.</p>
|
[
{
"answer_id": 266906,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 4,
"selected": true,
"text": "style=\"border-color: ...;\" <td rowspan=\"3\">"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34832/"
] |
266,888
|
<p>I have a situation where I want to copy the output assembly from one project into the output directory of my target application using MSBuild, without hard-coding paths in my MSBuild Copy task. Here's the scenario:</p>
<ul>
<li>Project A - Web Application Project</li>
<li>Project B - Dal Interface Project</li>
<li>Project C - Dal Implementation Project</li>
</ul>
<p>There is a Business layer too, but has no relevance for the MSBuild problem I'm looking to solve.</p>
<p>My business layer has a reference to my Dal.Interface project. My web project has a reference to the Business layer and as it stands, doing a build will pull the business layer and Dal.Interface projects into the output. So far, so good. Now in order for the web app to run, it needs the Dal implementation. I don't want the implementation referenced anywhere since I want to enforce coding to the interface and not having a reference means it won't show up in intellisense, etc.</p>
<p>So I figured I could handle this through the MSBuild copy operation as an AfterBuild task (I have the Dal Implementation setup to build when the web project builds, just not referenced). I don't want to hard code paths or anything else in the MSBuild params, so I'm trying to figure out how to reference the output of the Dal project from the Web Application Project's MSBuild file.</p>
<p>So based on the projects mentioned above this is what I want to see happen:</p>
<ol>
<li>Web app build is kicked off</li>
<li>All required projects build (already configured, so this is done)</li>
<li>MSBuild "AfterBuild" task kicks off and the output from Project C (Dal Implementation) is copied to the Bin directory of Project A (web app)</li>
</ol>
<p>Part 3 is where I'm stuck. </p>
<p>I'm sure this can be done, I'm just not finding a good reference to help out. Thanks in advance for any help.</p>
|
[
{
"answer_id": 266956,
"author": "Andrew Van Slaars",
"author_id": 8087,
"author_profile": "https://Stackoverflow.com/users/8087",
"pm_score": 4,
"selected": true,
"text": "<Target Name=\"AfterBuild\">\n<Copy SourceFiles=\"$(SolutionDir)MyProject.Dal.Linq\\bin\\$(Configuration)\\MyProject.Dal.Linq.dll\" DestinationFolder=\"$(TargetDir)\"/>\n</Target>\n"
},
{
"answer_id": 21377647,
"author": "Jonathan",
"author_id": 552510,
"author_profile": "https://Stackoverflow.com/users/552510",
"pm_score": 2,
"selected": false,
"text": "Content <Target Name=\"IncludeDALImplementation\" BeforeTargets=\"AfterBuild\">\n <MSBuild Projects=\"..\\DalImplementation\\DAL.csproj\" BuildInParallel=\"$(BuildInParallel)\" Targets=\"Build\">\n <Output TaskParameter=\"TargetOutputs\" ItemName=\"DalImplementationOutput\" />\n </MSBuild>\n\n <ItemGroup>\n <Content Include=\"@(DalImplementationOutput)\" />\n </ItemGroup>\n</Target>\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8087/"
] |
266,901
|
<p>Just wondering if there is any way to do the following:</p>
<pre><code>public Interface IDataField
{
object GetValue();
}
public Interface IComplexDataField : IDataField
{
object GetDefaultValue();
}
public class MyBase
{
private IDataField _DataField;
public MyBase()
{
this._DataField = this.CreateDataField();
}
public virtual IDataField CreateDataField()
{
return new DataField(); //Implements IDataField
}
**public virtual IDataField GetDataField()**
{
return this._DataField;
}
public void SomeMethod()
{
this.GetDataField().GetValue();
}
}
public class MyComplexBase : MyBase
{
public override IDataField CreateDataField()
{
return new ComplexDataField(); //Implements IComplexDataField which Implements IDataField
}
**public override IComplexDataField GetDataField()**
{
return (IComplexDataField)base.GetDataField();
}
public void SomeComplexSpecificMethod()
{
this.GetDataField().GetValue();
this.GetDataField().GetDefaultValue();
}
}
</code></pre>
<p>Cheers
Anthony</p>
|
[
{
"answer_id": 266911,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "MyBase public class MyBase<T> where T : IDataField\n{\n public virtual T CreateDataField()\n {\n ... etc ...\n }\n}\n"
},
{
"answer_id": 266915,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "virtual CreateDataField new public IDataField GetDataField()\n{\n return GetDataFieldImpl();\n}\nprotected virtual IDataField GetDataFieldImpl()\n{\n // return a basic version\n}\n protected override IDataField GetDataFieldImpl()\n{\n // do something more fun\n}\npublic new IComplexDataField GetDataField()\n{\n return (IComplexDataField)GetDataFieldImpl();\n}\n"
},
{
"answer_id": 266941,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "public class MyBase<T> where T : IDataField, new()\n{\n public virtual T CreateDataField()\n {\n return new T();\n }\n\n public virtual T GetDataField()\n {\n return this._DataField;\n }\n\n}\n\npublic class MyComplexBase : MyBase<ComplexDataField>\n{\n ...\n}\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30572/"
] |
266,903
|
<p>How can I create an instance of the following annotation (with all fields set to their default value).</p>
<pre><code> @Retention( RetentionPolicy.RUNTIME )
public @interface Settings {
String a() default "AAA";
String b() default "BBB";
String c() default "CCC";
}
</code></pre>
<p>I tried <code>new Settings()</code>, but that does not seem to work...</p>
|
[
{
"answer_id": 266945,
"author": "Florin",
"author_id": 34565,
"author_profile": "https://Stackoverflow.com/users/34565",
"pm_score": 1,
"selected": false,
"text": "@Settings\npublic void myMethod() {\n}\n"
},
{
"answer_id": 613469,
"author": "akuhn",
"author_id": 24468,
"author_profile": "https://Stackoverflow.com/users/24468",
"pm_score": 6,
"selected": true,
"text": "Settings.class.getMethod(\"a\").getDefaultValue()\nSettings.class.getMethod(\"b\").getDefaultValue()\nSettings.class.getMethod(\"c\").getDefaultValue()\n class Defaults implements InvocationHandler {\n public static <A extends Annotation> A of(Class<A> annotation) {\n return (A) Proxy.newProxyInstance(annotation.getClassLoader(),\n new Class[] {annotation}, new Defaults());\n }\n public Object invoke(Object proxy, Method method, Object[] args)\n throws Throwable {\n return method.getDefaultValue();\n }\n}\n\nSettings s = Defaults.of(Settings.class);\nSystem.out.printf(\"%s\\n%s\\n%s\\n\", s.a(), s.b(), s.c());\n"
},
{
"answer_id": 2909984,
"author": "emory",
"author_id": 348975,
"author_profile": "https://Stackoverflow.com/users/348975",
"pm_score": 5,
"selected": false,
"text": "class GetSettings {\n public static void main (String[] args){\n @Settings final class c { }\n Settings settings = c.class.getAnnotation(Settings.class);\n System.out.println(settings.aaa());\n }\n}\n"
},
{
"answer_id": 7067833,
"author": "Ralph",
"author_id": 280244,
"author_profile": "https://Stackoverflow.com/users/280244",
"pm_score": 5,
"selected": false,
"text": "java.lang.annotation.Annotation public class MySettings implements Annotation, Settings equals hashCode Annotation Settings.class.getMethod(\"a\").getDefaultValue()"
},
{
"answer_id": 17088810,
"author": "ex0b1t",
"author_id": 1031007,
"author_profile": "https://Stackoverflow.com/users/1031007",
"pm_score": 2,
"selected": false,
"text": "public static FieldGroup getDefaultFieldGroup() {\n @FieldGroup\n class settring {\n }\n return settring.class.getAnnotation(FieldGroup.class);\n}\n"
},
{
"answer_id": 29694223,
"author": "Thomas Darimont",
"author_id": 2123680,
"author_profile": "https://Stackoverflow.com/users/2123680",
"pm_score": 0,
"selected": false,
"text": "package demo;\n\nimport sun.reflect.annotation.AnnotationParser;\n\nimport java.lang.annotation.*;\nimport java.lang.reflect.Method;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class AnnotationProxyExample\n{\n\n public static void main(String[] args)\n {\n\n System.out.printf(\"Custom annotation creation: %s%n\", \n createAnnotationInstance(Collections.singletonMap(\"value\", \"required\"), Example.class));\n\n System.out.printf(\"Traditional annotation creation: %s%n\", \n X.class.getAnnotation(Example.class));\n }\n\n private static <A extends Annotation> A createAnnotationInstance(Map<String, Object> customValues, Class<A> annotationType)\n {\n\n Map<String, Object> values = new HashMap<>();\n\n //Extract default values from annotation\n for (Method method : annotationType.getDeclaredMethods())\n {\n values.put(method.getName(), method.getDefaultValue());\n }\n\n //Populate required values\n values.putAll(customValues);\n\n return (A) AnnotationParser.annotationForMap(annotationType, values);\n }\n\n @Example(\"required\")\n static class X\n {\n }\n\n @Retention(RetentionPolicy.RUNTIME)\n @Target(ElementType.TYPE)\n @interface Example\n {\n String value();\n int foo() default 42;\n boolean bar() default true;\n }\n}\n Custom annotation creation: @demo.AnnotationProxyExample$Example(bar=true, foo=42, value=required)\nTraditional annotation creation: @demo.AnnotationProxyExample$Example(bar=true, foo=42, value=required)\n"
},
{
"answer_id": 38311677,
"author": "mindas",
"author_id": 7345,
"author_profile": "https://Stackoverflow.com/users/7345",
"pm_score": 1,
"selected": false,
"text": "Settings @Retention( RetentionPolicy.RUNTIME )\npublic @interface Settings {\n String DEFAULT_A = \"AAA\";\n String DEFAULT_B = \"BBB\";\n String DEFAULT_C = \"CCC\";\n\n String a() default DEFAULT_A;\n String b() default DEFAULT_B;\n String c() default DEFAULT_C;\n}\n Settings.DEFAULT_A"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24468/"
] |
266,913
|
<p>I'm looking to stream lots of data (up to ~1 Gbit) from Java to a C++ application (both on the same machine). I'm currently using a FIFO on Linux but need a Windows solution too.</p>
<p>The most cross-platform method seems to be a local socket, but:
a) won't I get huge overhead from TCP checksumming and copying to & from kernel space, and
b) won't the average user's firewall try to inspect the and maybe block the connection?</p>
<p>It seems like a safer solution may be to use JNI and the Named Pipe API (\.\pipe\blah), making a god-awful platform-specific mess of both sides of the connection.</p>
<p>Are these really my 2 best options (and which would people recommend?)
Thanks!</p>
|
[
{
"answer_id": 3557247,
"author": "Vincent",
"author_id": 137511,
"author_profile": "https://Stackoverflow.com/users/137511",
"pm_score": 1,
"selected": false,
"text": "const char[] rawData = {0,1,2,3,4,5,6,7,8,9}; //Or get some raw data from somewhere\nint dataSize = sizeof(rawData);\nprintf(\"Building raw data array copy\\n\");\njbyteArray rawDataCopy = env->NewByteArray(dataSize);\nenv->SetByteArrayRegion(rawDataCopy, 0, dataSize, rawData);\n printf(\"Finding callback method\\n\");\n//Assumes obj is the Java instance that will receive the raw data via callback\njmethodID aMethodId = env->GetMethodID(env->GetObjectClass(obj),\"handleData\",\"([B)V\");\nif(0==aMethodId) throw MyRuntimeException(\"Method not found error\");\nprintf(\"Invoking the callback\\n\");\nenv->CallVoidMethod(obj,aMethodId, &rawDataCopy);\n public class MyDataHandler {\n OutputStream dataStream;\n public MyDataHandler(OutputStream writeTo) { dataStream = writeTo;}\n public void handleData(byte[] incomingData) { dataStream.write(incomingData); }\n}\n public class NativeIntegration {\n public native void generateBinaryWithHandler(MyDataHandler handler);\n\n //Here we assume response is something like a network stream\n public void doCallNativeFunction(ResponseStream response) {\n MyDataHandler handler = new MyDataHandler(response);\n generateBinaryWithHandler(handler);\n }\n}\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
266,923
|
<p>In C# which is more memory efficient: Option #1 or Option #2?</p>
<pre><code>public void TestStringBuilder()
{
//potentially a collection with several hundred items:
string[] outputStrings = new string[] { "test1", "test2", "test3" };
//Option #1
StringBuilder formattedOutput = new StringBuilder();
foreach (string outputString in outputStrings)
{
formattedOutput.Append("prefix ");
formattedOutput.Append(outputString);
formattedOutput.Append(" postfix");
string output = formattedOutput.ToString();
ExistingOutputMethodThatOnlyTakesAString(output);
//Clear existing string to make ready for next iteration:
formattedOutput.Remove(0, output.Length);
}
//Option #2
foreach (string outputString in outputStrings)
{
StringBuilder formattedOutputInsideALoop = new StringBuilder();
formattedOutputInsideALoop.Append("prefix ");
formattedOutputInsideALoop.Append(outputString);
formattedOutputInsideALoop.Append(" postfix");
ExistingOutputMethodThatOnlyTakesAString(
formattedOutputInsideALoop.ToString());
}
}
private void ExistingOutputMethodThatOnlyTakesAString(string output)
{
//This method actually writes out to a file.
System.Console.WriteLine(output);
}
</code></pre>
|
[
{
"answer_id": 266936,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "Remove"
},
{
"answer_id": 266991,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 1,
"selected": false,
"text": "Option #1 (10000000 iterations): 11264ms\nOption #2 (10000000 iterations): 12779ms\n class Program\n{\n const int __iterations = 10000000;\n\n static void Main(string[] args)\n {\n TestStringBuilder();\n Console.ReadLine();\n }\n\n public static void TestStringBuilder()\n {\n //potentially a collection with several hundred items:\n var outputStrings = new [] { \"test1\", \"test2\", \"test3\" };\n\n var stopWatch = new Stopwatch();\n\n //Option #1\n stopWatch.Start();\n var formattedOutput = new StringBuilder();\n\n for (var i = 0; i < __iterations; i++)\n {\n foreach (var outputString in outputStrings)\n {\n formattedOutput.Append(\"prefix \");\n formattedOutput.Append(outputString);\n formattedOutput.Append(\" postfix\");\n\n var output = formattedOutput.ToString();\n ExistingOutputMethodThatOnlyTakesAString(output);\n\n //Clear existing string to make ready for next iteration:\n formattedOutput.Remove(0, output.Length);\n }\n }\n stopWatch.Stop();\n\n Console.WriteLine(\"Option #1 ({1} iterations): {0}ms\", stopWatch.ElapsedMilliseconds, __iterations);\n Console.ReadLine();\n stopWatch.Reset();\n\n //Option #2\n stopWatch.Start();\n for (var i = 0; i < __iterations; i++)\n {\n foreach (var outputString in outputStrings)\n {\n StringBuilder formattedOutputInsideALoop = new StringBuilder();\n\n formattedOutputInsideALoop.Append(\"prefix \");\n formattedOutputInsideALoop.Append(outputString);\n formattedOutputInsideALoop.Append(\" postfix\");\n\n ExistingOutputMethodThatOnlyTakesAString(\n formattedOutputInsideALoop.ToString());\n }\n }\n stopWatch.Stop();\n\n Console.WriteLine(\"Option #2 ({1} iterations): {0}ms\", stopWatch.ElapsedMilliseconds, __iterations);\n }\n\n private static void ExistingOutputMethodThatOnlyTakesAString(string s)\n {\n // do nothing\n }\n} \n"
},
{
"answer_id": 267169,
"author": "Jason Hernandez",
"author_id": 34863,
"author_profile": "https://Stackoverflow.com/users/34863",
"pm_score": 2,
"selected": false,
"text": "foreach (string outputString in outputStrings)\n { \n string output = \"prefix \" + outputString + \" postfix\";\n ExistingOutputMethodThatOnlyTakesAString(output) \n }\n string output = formattedOutput.ToString();\n ExistingOutputMethodThatOnlyTakesAString(\n formattedOutputInsideALoop.ToString());\n StringBuilder formattedOutput = new StringBuilder(); \n // create new string builder\n formattedOutput.Remove(0, output.Length); \n // reuse existing string builder\n"
},
{
"answer_id": 267189,
"author": "Ty.",
"author_id": 16948,
"author_profile": "https://Stackoverflow.com/users/16948",
"pm_score": 2,
"selected": false,
"text": "formattedOutput.Length = 0;\n"
},
{
"answer_id": 273750,
"author": "Sixto Saez",
"author_id": 9711,
"author_profile": "https://Stackoverflow.com/users/9711",
"pm_score": 4,
"selected": true,
"text": "ClassName Instances TotalBytesAllocated Gen0_InstancesCollected Gen0BytesCollected Gen1InstancesCollected Gen1BytesCollected\n=======Option #1 \nSystem.Text.StringBuilder 100,001 2,000,020 100,016 2,000,320 2 40\nSystem.String 301,020 32,587,168 201,147 11,165,268 3 246\nSystem.Char[] 200,000 8,977,780 200,022 8,979,678 2 90\nSystem.String[] 1 400,016 26 1,512 0 0\nSystem.Int32 100,000 1,200,000 100,061 1,200,732 2 24\nSystem.Object[] 100,000 2,000,000 100,070 2,004,092 2 40\n======Option #2 \nSystem.Text.StringBuilder 200,000 4,000,000 200,011 4,000,220 4 80\nSystem.String 401,018 37,587,036 301,127 16,164,318 3 214\nSystem.Char[] 200,000 9,377,780 200,024 9,379,768 0 0\nSystem.String[] 1 400,016 20 1,208 0 0\nSystem.Int32 100,000 1,200,000 100,051 1,200,612 1 12\nSystem.Object[] 100,000 2,000,000 100,058 2,003,004 1 20\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9711/"
] |
266,924
|
<p>I am trying to convert a date with individual parts such as 12, 1, 2007 into a datetime in SQL Server 2005. I have tried the following:</p>
<pre><code>CAST(DATEPART(year, DATE)+'-'+ DATEPART(month, DATE) +'-'+ DATEPART(day, DATE) AS DATETIME)
</code></pre>
<p>but this results in the wrong date. What is the correct way to turn the three date values into a proper datetime format.</p>
|
[
{
"answer_id": 266940,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 8,
"selected": true,
"text": "y, m, d int CAST(CAST(y AS varchar) + '-' + CAST(m AS varchar) + '-' + CAST(d AS varchar) AS DATETIME)\n"
},
{
"answer_id": 266955,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 3,
"selected": false,
"text": "DECLARE @Day int, @Month int, @Year int\nSELECT @Day = 1, @Month = 2, @Year = 2008\n\nSELECT DateAdd(dd, @Day-1, DateAdd(mm, @Month -1, DateAdd(yy, @Year - 2000, '20000101')))\n"
},
{
"answer_id": 267016,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 8,
"selected": false,
"text": "Declare @DayOfMonth TinyInt Set @DayOfMonth = 13\nDeclare @Month TinyInt Set @Month = 6\nDeclare @Year Integer Set @Year = 2006\n-- ------------------------------------\nSelect DateAdd(day, @DayOfMonth - 1, \n DateAdd(month, @Month - 1, \n DateAdd(Year, @Year-1900, 0)))\n Select DateAdd(yy, @Year-1900, \n DateAdd(m, @Month - 1, @DayOfMonth - 1)) \n DATEFROMPARTS(year, month, day) select dateadd(month, @Month - 1, \n dateadd(year, @Year-1900, @DayOfMonth - 1)); \n"
},
{
"answer_id": 5189789,
"author": "Shrike",
"author_id": 644128,
"author_profile": "https://Stackoverflow.com/users/644128",
"pm_score": 7,
"selected": false,
"text": "DECLARE @day int, @month int, @year int\nSELECT @day = 4, @month = 3, @year = 2011\n\nSELECT dateadd(mm, (@year - 1900) * 12 + @month - 1 , @day - 1)\n"
},
{
"answer_id": 10142966,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 8,
"selected": false,
"text": "DATEFROMPARTS(ycolumn, mcolumn, dcolumn)\n DATEFROMPARTS(@y, @m, @d)\n"
},
{
"answer_id": 11187436,
"author": "Jack",
"author_id": 794594,
"author_profile": "https://Stackoverflow.com/users/794594",
"pm_score": 3,
"selected": false,
"text": "create function dbo.fnDateTime2FromParts(@Year int, @Month int, @Day int, @Hour int, @Minute int, @Second int, @Nanosecond int)\nreturns datetime2\nas\nbegin\n -- Note! SQL Server 2012 includes datetime2fromparts() function\n declare @output datetime2 = '19000101'\n set @output = dateadd(year , @Year - 1900 , @output)\n set @output = dateadd(month , @Month - 1 , @output)\n set @output = dateadd(day , @Day - 1 , @output)\n set @output = dateadd(hour , @Hour , @output)\n set @output = dateadd(minute , @Minute , @output)\n set @output = dateadd(second , @Second , @output)\n set @output = dateadd(ns , @Nanosecond , @output)\n return @output\nend\n"
},
{
"answer_id": 13051395,
"author": "Saul Guerra",
"author_id": 1771520,
"author_profile": "https://Stackoverflow.com/users/1771520",
"pm_score": 2,
"selected": false,
"text": "CAST(STR(DATEPART(year, DATE))+'-'+ STR(DATEPART(month, DATE)) +'-'+ STR(DATEPART(day, DATE)) AS DATETIME)\n"
},
{
"answer_id": 19192012,
"author": "Brian",
"author_id": 320,
"author_profile": "https://Stackoverflow.com/users/320",
"pm_score": 4,
"selected": false,
"text": "IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[func_DateFromParts]'))\n DROP FUNCTION [dbo].[func_DateFromParts]\nGO\n\nCREATE FUNCTION [dbo].[func_DateFromParts]\n(\n @Year INT,\n @Month INT,\n @DayOfMonth INT,\n @Hour INT = 0, -- based on 24 hour clock (add 12 for PM :)\n @Min INT = 0,\n @Sec INT = 0\n)\nRETURNS DATETIME\nAS\nBEGIN\n\n RETURN DATEADD(second, @Sec, \n DATEADD(minute, @Min, \n DATEADD(hour, @Hour,\n DATEADD(day, @DayOfMonth - 1, \n DATEADD(month, @Month - 1, \n DATEADD(Year, @Year-1900, 0))))))\n\nEND\n\nGO\n SELECT dbo.func_DateFromParts(2013, 10, 4, 15, 50, DEFAULT)\n 2013-10-04 15:50:00.000\n"
},
{
"answer_id": 21482283,
"author": "bluish",
"author_id": 505893,
"author_profile": "https://Stackoverflow.com/users/505893",
"pm_score": 2,
"selected": false,
"text": "select dateadd(month, (@Year -1900)*12 + @Month -1, @DayOfMonth -1) + dateadd(ss, @Hour*3600 + @Minute*60 + @Second, 0) + dateadd(ms, @Millisecond, 0)\n"
},
{
"answer_id": 27355251,
"author": "Konstantin",
"author_id": 1665649,
"author_profile": "https://Stackoverflow.com/users/1665649",
"pm_score": 2,
"selected": false,
"text": "CAST SET DATEFORMAT -- 26 February 2015\nSET DATEFORMAT dmy\nSELECT CAST('26-2-2015' AS DATE)\n\nSET DATEFORMAT ymd\nSELECT CAST('2015-2-26' AS DATE)\n"
},
{
"answer_id": 28923195,
"author": "user3141962",
"author_id": 3141962,
"author_profile": "https://Stackoverflow.com/users/3141962",
"pm_score": 1,
"selected": false,
"text": " SELECT SUBSTRING(CONVERT(VARCHAR,JOINGDATE,103),7,4)AS\n YEAR,SUBSTRING(CONVERT(VARCHAR,JOINGDATE,100),1,2)AS\nMONTH,SUBSTRING(CONVERT(VARCHAR,JOINGDATE,100),4,3)AS DATE FROM EMPLOYEE1\n 2014 Ja 1\n2015 Ja 1\n2014 Ja 1\n2015 Ja 1\n2012 Ja 1\n2010 Ja 1\n2015 Ja 1\n"
},
{
"answer_id": 36937904,
"author": "Gouri Shankar Aechoor",
"author_id": 3849742,
"author_profile": "https://Stackoverflow.com/users/3849742",
"pm_score": 0,
"selected": false,
"text": "--2012 and above\nSELECT CONCAT (\n RIGHT(REPLACE(@date, ' ', ''), 4)\n ,'-'\n ,RIGHT(CONCAT('00',SUBSTRING(REPLACE(@date, ' ', ''), CHARINDEX(',', REPLACE(@date, ' ', '')) + 1, LEN(REPLACE(@date, ' ', '')) - CHARINDEX(',', REPLACE(@date, ' ', '')) - 5)),2)\n ,'-'\n ,RIGHT(CONCAT('00',SUBSTRING(REPLACE(@date, ' ', ''), 1, CHARINDEX(',', REPLACE(@date, ' ', '')) - 1)),2)\n )\n\n--2008 and below\nSELECT RIGHT(REPLACE(@date, ' ', ''), 4)\n +'-'\n +RIGHT('00'+SUBSTRING(REPLACE(@date, ' ', ''), CHARINDEX(',', REPLACE(@date, ' ', '')) + 1, LEN(REPLACE(@date, ' ', '')) - CHARINDEX(',', REPLACE(@date, ' ', '')) - 5),2)\n +'-'\n +RIGHT('00'+SUBSTRING(REPLACE(@date, ' ', ''), 1, CHARINDEX(',', REPLACE(@date, ' ', '')) - 1),2)\n DECLARE @Table TABLE (ID INT IDENTITY(1000,1), DateString VARCHAR(50), DateColumn DATE)\n\nINSERT INTO @Table\nSELECT'12, 1, 2007',NULL\nUNION\nSELECT'15,3, 2007',NULL\nUNION\nSELECT'18, 11 , 2007',NULL\nUNION\nSELECT'22 , 11, 2007',NULL\nUNION\nSELECT'30, 12, 2007 ',NULL\n\nUPDATE @Table\nSET DateColumn = CONCAT (\n RIGHT(REPLACE(DateString, ' ', ''), 4)\n ,'-'\n ,RIGHT(CONCAT('00',SUBSTRING(REPLACE(DateString, ' ', ''), CHARINDEX(',', REPLACE(DateString, ' ', '')) + 1, LEN(REPLACE(DateString, ' ', '')) - CHARINDEX(',', REPLACE(DateString, ' ', '')) - 5)),2)\n ,'-'\n ,RIGHT(CONCAT('00',SUBSTRING(REPLACE(DateString, ' ', ''), 1, CHARINDEX(',', REPLACE(DateString, ' ', '')) - 1)),2)\n ) \n\nSELECT ID,DateString,DateColumn\nFROM @Table\n"
},
{
"answer_id": 37063697,
"author": "Marcelo Lujan",
"author_id": 1303723,
"author_profile": "https://Stackoverflow.com/users/1303723",
"pm_score": 4,
"selected": false,
"text": "select DATEFROMPARTS(year, month, day) as ColDate, Col2, Col3 \nFrom MyTable Where DATEFROMPARTS(year, month, day) Between @DateIni and @DateEnd\n"
},
{
"answer_id": 56779214,
"author": "Peter Bojanczyk",
"author_id": 11467549,
"author_profile": "https://Stackoverflow.com/users/11467549",
"pm_score": 2,
"selected": false,
"text": "SELECT DATEADD(DAY, 1, EOMONTH(@somedate, -1))\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23133/"
] |
266,927
|
<p>I receive an error message when exposing an ADO.NET Data Service using an Entity Framework data model that contains an entity (called "Case") with an internal setter on a property. If I modify the setter to be public (using the entity designer), the data services works fine.</p>
<p>I don’t need the entity "Case" exposed in the data service, so I tried to limit which entities are exposed using SetEntitySetAccessRule. This didn’t work, and service end point fails with the same error.</p>
<pre><code>public static void InitializeService(IDataServiceConfiguration config)
{
config.SetEntitySetAccessRule("User", EntitySetRights.AllRead);
}
</code></pre>
<p>The error message is reported in a browser when the .svc endpoint is called. It is very generic, and reads “Request Error. The server encountered an error processing the request. See server logs for more details.” Unfortunately, there are no entries in the System and Application event logs.</p>
<p>I found this <a href="https://stackoverflow.com/questions/54380/problem-rolling-out-adonet-data-service-application-to-iis">stackoverflow question</a> that shows how to configure tracing on the service. After doing so, the following NullReferenceExceptoin error was reported in the trace log.</p>
<p>Does anyone know how to avoid this exception when including an entity with an internal setter?</p>
<pre><code><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>131076</EventID>
<Type>3</Type>
<SubType Name="Error">0</SubType>
<Level>2</Level>
<TimeCreated SystemTime="2008-11-05T22:30:44.1523578Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{da77ee97-960f-4275-a5e7-a181c0b024b1}" />
<Execution ProcessName="WebDev.WebServer" ProcessID="6388" ThreadID="8" />
<Channel />
<Computer>MOTOJIM</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error">
<TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.TraceHandledException.aspx</TraceIdentifier>
<Description>Handling an exception.</Description>
<AppDomain>685a2910-19-128703978432492675</AppDomain>
<Exception>
<ExceptionType>System.NullReferenceException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>Object reference not set to an instance of an object.</Message>
<StackTrace>
at System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMemberMetadata(ResourceType resourceType, MetadataWorkspace workspace, IDictionary`2 entitySets, IDictionary`2 knownTypes)
at System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMetadata(IDictionary`2 knownTypes, IDictionary`2 entitySets)
at System.Data.Services.Providers.BaseServiceProvider.PopulateMetadata()
at System.Data.Services.DataService`1.CreateProvider(Type dataServiceType, Object dataSourceInstance, DataServiceConfiguration&amp; configuration)
at System.Data.Services.DataService`1.EnsureProviderAndConfigForRequest()
at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody)
at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
</StackTrace>
<ExceptionString>System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMemberMetadata(ResourceType resourceType, MetadataWorkspace workspace, IDictionary`2 entitySets, IDictionary`2 knownTypes)
at System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMetadata(IDictionary`2 knownTypes, IDictionary`2 entitySets)
at System.Data.Services.Providers.BaseServiceProvider.PopulateMetadata()
at System.Data.Services.DataService`1.CreateProvider(Type dataServiceType, Object dataSourceInstance, DataServiceConfiguration&amp; configuration)
at System.Data.Services.DataService`1.EnsureProviderAndConfigForRequest()
at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody)
at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</ExceptionString>
</Exception>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>
</code></pre>
|
[
{
"answer_id": 421500,
"author": "ggponti",
"author_id": 6840,
"author_profile": "https://Stackoverflow.com/users/6840",
"pm_score": 0,
"selected": false,
"text": "public class WebDataService : DataService< DataModel.DataEntities >\n"
},
{
"answer_id": 3090364,
"author": "Jakob Gade",
"author_id": 10932,
"author_profile": "https://Stackoverflow.com/users/10932",
"pm_score": 2,
"selected": false,
"text": "public static void InitializeService(DataServiceConfiguration config)\n{\n config.SetEntitySetAccessRule(\"*\", EntitySetRights.All);\n config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;\n}\n"
},
{
"answer_id": 6018883,
"author": "Peter",
"author_id": 563744,
"author_profile": "https://Stackoverflow.com/users/563744",
"pm_score": 0,
"selected": false,
"text": "config.SetEntitySetAccessRule(\"Orders\", EntitySetRights.All);\n"
},
{
"answer_id": 21870792,
"author": "Jakub Kuszneruk",
"author_id": 1565454,
"author_profile": "https://Stackoverflow.com/users/1565454",
"pm_score": 0,
"selected": false,
"text": "public class WebDataService : DataService< DataModel.DataEntities >\n public class WebDataService : EntityFrameworkDataService< DataModel.DataEntities >\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33496/"
] |
266,931
|
<p>It seems that nginx is used with php, ruby and python. </p>
<p>Anyone has an example of how to setup nginx to work with jetty/tomcat in backend? </p>
<p>Thanks.</p>
|
[
{
"answer_id": 267072,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 4,
"selected": true,
"text": "server {\n location /anything {\n proxy_pass http://localhost:8080/whatever;\n }\n}\n"
},
{
"answer_id": 267077,
"author": "Florin",
"author_id": 34565,
"author_profile": "https://Stackoverflow.com/users/34565",
"pm_score": 4,
"selected": false,
"text": "server {\n listen 80;\n server_name mydomain.com www.mydomain.com;\n access_log /var/log/nginx_67_log main;\n location / {\n proxy_pass http://127.0.0.1:8080;\n proxy_redirect off;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n }\n}\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34565/"
] |
266,988
|
<p>I'm working on a Facebook FBML controls library and would like to create my FBML controls somewhat patterned like the ASP.NET WebControls library. I have a base class that handles rendering by default; here's my render method:</p>
<pre><code>
protected override void Render(HtmlTextWriter writer)
{
AddAttributesToRender(writer);
if (UseXfbmlSemantics)
{
writer.RenderBeginTag(ElementName);
writer.EndRender();
writer.RenderEndTag();
}
else
{
writer.RenderBeginTag(ElementName);
writer.RenderEndTag();
}
}
</code></pre>
<p>What I would like is for the rendering to be modified based on UseXfbmlSemantics - if it's true, it should render, for instance:</p>
<pre><code><fb:name uid="10300399458"></fb:name></code></pre>
<p>When it's false, it should render with a self-closing tag:</p>
<pre><code><fb:name uid="10300399458" /></code></pre>
<p>I can get the "true" condition to work almost correctly, but the self-closing tag seems to be incompatible with the Render- set of methods. Unfortunately if that's the case it also means that the AddAttributesToRender pattern wouldn't work, either. What it's actually producing is this:</p>
<pre><code>
<fb:name uid="10300399458">
</fb:name>
</code></pre>
<p>How can I get HtmlTextWriter (or which HtmlTextWriter do I need to use) to make it render a self-closing tag? Or, at the very least, how can I make it not render that interim space (so that the opening and closing tags are immediately next to one another)?</p>
|
[
{
"answer_id": 270417,
"author": "Jason Hernandez",
"author_id": 34863,
"author_profile": "https://Stackoverflow.com/users/34863",
"pm_score": 4,
"selected": true,
"text": "<fb:name uid=\"00101010101\"/> public class FbName:System.Web.UI.WebControls.WebControl\n{\n\n protected override string TagName\n {\n get\n {\n return \"fb:name\";\n }\n }\n\n public override void RenderControl(HtmlTextWriter writer)\n { \n RenderBeginTag(writer);// render only the begin tag.\n //base.RenderContents(writer);\n //base.RenderEndTag(writer);\n }\n\n public override void RenderBeginTag(HtmlTextWriter writer)\n {\n writer.Write(\"<\" + this.TagName);\n writer.WriteAttribute(\"uid\", \"00101010101\");\n writer.Write(\"/>\");\n\n }\n}\n"
},
{
"answer_id": 7230207,
"author": "user917829",
"author_id": 917829,
"author_profile": "https://Stackoverflow.com/users/917829",
"pm_score": 2,
"selected": false,
"text": " protected override void Render(HtmlTextWriter writer)\n {\n AddAttributesToRender(writer);\n writer.Write(HtmlTextWriter.TagLeftChar); // '<'\n writer.Write(this.TagName);\n writer.Write(HtmlTextWriter.SpaceChar); // ' '\n writer.WriteAttribute(\"uid\", \"00101010101\");\n writer.Write(HtmlTextWriter.SpaceChar); // ' '\n writer.Write(HtmlTextWriter.SelfClosingTagEnd); // \"/>\"\n }\n"
},
{
"answer_id": 25813598,
"author": "Tony",
"author_id": 1985479,
"author_profile": "https://Stackoverflow.com/users/1985479",
"pm_score": 3,
"selected": false,
"text": "writer.WriteBeginTag(\"tag\");\nwriter.WriteAttribute(\"attribute\", \"attribute value\");\n// ... add other attributes here ...\nwriter.Write(HtmlTextWriter.SelfClosingTagEnd);\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34224/"
] |
266,989
|
<p>Subject says it all but he background:</p>
<p>I want to trigger some TortoiseSVN action from a batch file? I suspect that I can do this by calling the right exe with the right args but I'd rather find a way to solve the more general problem of doing an arbitrary action.</p>
<p><strong>Edit:</strong> The reason that I don't just use svn directly is that TortoiseSVN doesn't include a command line SVN client (e.i. there is no svn.exe on my computer at all). Also, it would dump it output the stdout and I want the GUI output.</p>
<p>Regarding the Right Click menu, besides a way to directly trigger a right click item, a way to take an arbitrary right click item and (more or less automatically) find out what command line to call would also be good enough. However a solution that amounts to "just find out what it does" is not as I already know how to go there.</p>
<p>I don't have any specific reason to believe this can be done, so if someone <em>knows</em> it can't be, that would be a valid answer as well.</p>
|
[
{
"answer_id": 267019,
"author": "Niniki",
"author_id": 4155,
"author_profile": "https://Stackoverflow.com/users/4155",
"pm_score": 1,
"selected": false,
"text": "svn update\n svn help\n svn help <command>\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] |
266,997
|
<p>I'm trying to extract all matches from a EBML definition, which is something like this:</p>
<pre><code>| + A track
| + Track number: 3
| + Track UID: 724222477
| + Track type: subtitles
...
| + Language: eng
...
| + A track
| + Track number: 4
| + Track UID: 745646561
| + Track type: subtitles
...
| + Language: jpn
...
</code></pre>
<p>I want all occurrences of "Language: ???" when preceded by "Track type: subtitles". I tried several variations of this:</p>
<pre><code>Track type: subtitles.*Language: (\w\w\w)
</code></pre>
<p>I'm using the multi-line modifier in Ruby so it matches newlines (like the 's' modifier in other languages).</p>
<p>This works to get the <strong>last</strong> occurrence, which in the example above, would be 'jpn', for example:</p>
<pre><code>string.scan(/Track type: subtitles.*Language: (\w\w\w)/m)
=> [["jpn"]]
</code></pre>
<p>The result I'd like:</p>
<pre><code>=> [["eng"], ["jpn"]]
</code></pre>
<p>What would be a correct regex to accomplish this?</p>
|
[
{
"answer_id": 267007,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 2,
"selected": false,
"text": ".* /Track type: subtitles.*?Language: (\\w\\w\\w)/m\n Language: ??? Track type: subtitles: subtitles Language /^\\| \\+ (?:(?!^\\| \\+).)*?\\+ Track type: subtitles$(?:(?!^\\| \\+).)*?^\\| \\+ Language: (\\w+)$/m\n /^\\| \\+ ([^\\r\\n]+)|^\\| \\+ Track type: (subtitles)|^\\| \\+ Language: (\\w+)/m\n subtitles subtitles"
},
{
"answer_id": 267012,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 4,
"selected": true,
"text": ".*\n .*?\n Track type: subtitles Language: (\\w\\w\\w)"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/266997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16957/"
] |
267,001
|
<p>I'm trying to save the output of an vector image drawin in Java2D to an SWF file. There are great libraries for saving java2D output as things like SVG (BATIK) and PDF(itext) but I can't find one for SWF. Any ideas?</p>
|
[
{
"answer_id": 267023,
"author": "rmeador",
"author_id": 10861,
"author_profile": "https://Stackoverflow.com/users/10861",
"pm_score": 1,
"selected": false,
"text": "<mx:Script><![CDATA[\n\n[Embed(source=\"../images/down.svg\")]\n[Bindable]\nprotected var drillDownImage:Class;\n\n]]></mx:Script>\n\n<mx:HBox width=\"50%\" horizontalAlign=\"right\">\n <mx:Image id=\"drillDownButton\" source=\"{drillDownImage}\" height=\"20\" width=\"20\" click=\"drillDown();\" />\n</mx:HBox>\n"
},
{
"answer_id": 268670,
"author": "jcoder",
"author_id": 417292,
"author_profile": "https://Stackoverflow.com/users/417292",
"pm_score": 1,
"selected": false,
"text": "package{\n import flash.display.Sprite;\n\n public class Test extends Sprite{\n public function Test (){\n\n // Start of lines generated by your java\n graphics.lineStyle(1, 0, 1);\n graphics.lineTo(100, 0);\n graphics.lineTo(100, 100);\n graphics.lineTo(0, 100);\n graphics.lineTo(0, 0);\n // End of lines generated by your java\n }\n }\n}\n"
},
{
"answer_id": 269714,
"author": "delux247",
"author_id": 5569,
"author_profile": "https://Stackoverflow.com/users/5569",
"pm_score": 4,
"selected": true,
"text": " // Create the SpriteGraphics2D object\n SpriteGraphics2D g = new SpriteGraphics2D(100, 100);\n\n // Draw on to the graphics object\n Font font = new Font(\"Serif\", Font.PLAIN, 16);\n g.setFont(font); \n g.drawString(\"Test swf\", 30, 30); \n g.draw(new Line2D.Double(5, 5, 50, 60));\n g.draw(new Line2D.Double(50, 60, 150, 40));\n g.draw(new Line2D.Double(150, 40, 160, 10));\n\n // Create a new empty movie\n Movie m = new Movie();\n m.version = 7;\n m.bgcolor = new SetBackgroundColor(SwfUtils.colorToInt(255, 255, 255));\n m.framerate = 12;\n m.frames = new ArrayList(1);\n m.frames.add(new Frame());\n m.size = new Rect(11000, 8000);\n\n // Get the DefineSprite from the graphics object\n DefineSprite tag = g.defineSprite(\"swf-test\");\n\n // Place the DefineSprite on the first frame\n Frame frame1 = (Frame) m.frames.get(0);\n Matrix mt = new Matrix(0, 0);\n frame1.controlTags.add(new PlaceObject(mt, tag, 1, null));\n\n TagEncoder tagEncoder = new TagEncoder();\n MovieEncoder movieEncoder = new MovieEncoder(tagEncoder);\n movieEncoder.export(m);\n\n //Write to file\n FileOutputStream fos = new FileOutputStream(new File(\"/test.swf\"));\n tagEncoder.writeTo(fos);\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34888/"
] |
267,006
|
<p>My new ASP.NET MVC Web Application works on my development workstation, but does not run on my web server...</p>
<hr>
<h1>Server Error in '/' Application.</h1>
<hr>
<h2>Configuration Error</h2>
<p><strong>Description:</strong> An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. </p>
<p><strong>Parser Error Message:</strong> Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. </p>
<p><strong>Source Error:</strong> </p>
<pre><code>Line 44: <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 45: <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 46: <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 47: <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Line 48: <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</code></pre>
<p><strong>Source File:</strong> C:\inetpub\www.example.org\web.config <strong>Line:</strong> 46 </p>
<p><strong>Assembly Load Trace:</strong> The following information can be helpful to determine why the assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded. </p>
<pre>
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
</pre>
<hr>
<p><strong>Version Information:</strong> Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053</p>
<hr>
<p>Do I need to install the <em>AspNetMVCBeta-setup.msi</em> on the server? Or is there a different installer for servers?</p>
<p><img src="https://i.stack.imgur.com/V21XS.gif" alt="enter image description here"></p>
|
[
{
"answer_id": 267021,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 9,
"selected": true,
"text": "* Microsoft.Web.Infrastructure\n* System.Web.Razor\n* System.Web.WebPages.Deployment\n* System.Web.WebPages.Razor\n"
},
{
"answer_id": 5481834,
"author": "Victor Juri",
"author_id": 653855,
"author_profile": "https://Stackoverflow.com/users/653855",
"pm_score": 5,
"selected": false,
"text": "* Microsoft.Web.Infrastructure\n* System.Web.Razor\n* System.Web.WebPages.Deployment\n* System.Web.WebPages.Razor\n"
},
{
"answer_id": 13426060,
"author": "Dave Shinkle",
"author_id": 1647603,
"author_profile": "https://Stackoverflow.com/users/1647603",
"pm_score": 3,
"selected": false,
"text": "C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET MVC 4\\Assemblies"
},
{
"answer_id": 28819836,
"author": "Brian Rice",
"author_id": 1027031,
"author_profile": "https://Stackoverflow.com/users/1027031",
"pm_score": 0,
"selected": false,
"text": "<Reference Include=\"System.Web.Http\">\n <HintPath>..\\packages\\Microsoft.AspNet.WebApi.Core.5.2.3\\lib\\net45\\System.Web.Http.dll</HintPath>\n\n<Reference Include=\"System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL\">\n <HintPath>..\\packages\\Microsoft.AspNet.Mvc.5.2.3\\lib\\net45\\System.Web.Mvc.dll</HintPath>\n"
},
{
"answer_id": 32367093,
"author": "actual_kangaroo",
"author_id": 2377920,
"author_profile": "https://Stackoverflow.com/users/2377920",
"pm_score": 0,
"selected": false,
"text": "Copy Local true System.Web.Webpages Microsoft.Web.Infrastructure\nSystem.Web.Razor\nSystem.Web.WebPages.Deployment\nSystem.Web.WebPages.Razor\nSystem.Web.Webpages\n"
},
{
"answer_id": 36714873,
"author": "Mikael Puusaari",
"author_id": 6094057,
"author_profile": "https://Stackoverflow.com/users/6094057",
"pm_score": 2,
"selected": false,
"text": "web.config <add assembly=\"System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>\n 3.0.0.0 web.config \"copy local = true\""
},
{
"answer_id": 41758515,
"author": "PBo",
"author_id": 5262306,
"author_profile": "https://Stackoverflow.com/users/5262306",
"pm_score": 2,
"selected": false,
"text": " <runtime>\n <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n <dependentAssembly>\n <assemblyIdentity name=\"System.Web.WebPages\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-3.0.0.0\" newVersion=\"3.0.0.0\"/>\n </dependentAssembly>\n <dependentAssembly>\n\n\n <assemblyIdentity name=\"System.Web.Mvc\" publicKeyToken=\"31bf3856ad364e35\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-5.2.3.0\" newVersion=\"5.2.3.0\"/>\n <assemblyIdentity name=\"Microsoft.Owin\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-3.0.1.0\" newVersion=\"3.0.1.0\"/>\n <assemblyIdentity name=\"Microsoft.Owin.Security.OAuth\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\"/>\n <assemblyIdentity name=\"Microsoft.Owin.Security\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\"/>\n <assemblyIdentity name=\"Microsoft.Owin.Security.Cookies\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\"/>\n <assemblyIdentity name=\"Newtonsoft.Json\" publicKeyToken=\"30ad4fe6b2a6aeed\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-9.0.0.0\" newVersion=\"9.0.0.0\"/>\n <assemblyIdentity name=\"WebGrease\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-1.6.5135.21930\" newVersion=\"1.6.5135.21930\"/>\n <assemblyIdentity name=\"Antlr3.Runtime\" publicKeyToken=\"eb42632606e9261f\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-3.5.0.2\" newVersion=\"3.5.0.2\"/>\n\n\n <assemblyIdentity name=\"System.Web.Helpers\" publicKeyToken=\"31bf3856ad364e35\"/>\n <bindingRedirect oldVersion=\"1.0.0.0-3.0.0.0\" newVersion=\"3.0.0.0\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"System.Web.Mvc\" publicKeyToken=\"31bf3856ad364e35\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-5.2.3.0\" newVersion=\"5.2.3.0\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"Microsoft.Owin.Security\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-3.0.1.0\" newVersion=\"3.0.1.0\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"Microsoft.Owin\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-3.0.1.0\" newVersion=\"3.0.1.0\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"Newtonsoft.Json\" publicKeyToken=\"30ad4fe6b2a6aeed\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-9.0.0.0\" newVersion=\"9.0.0.0\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"WebGrease\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-1.6.5135.21930\" newVersion=\"1.6.5135.21930\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"Microsoft.Owin.Security.Cookies\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-3.0.1.0\" newVersion=\"3.0.1.0\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"Microsoft.Owin.Security.OAuth\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-3.0.1.0\" newVersion=\"3.0.1.0\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"SimpleInjector\" publicKeyToken=\"984cb50dea722e99\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-3.3.2.0\" newVersion=\"3.3.2.0\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"Antlr3.Runtime\" publicKeyToken=\"eb42632606e9261f\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-3.5.0.2\" newVersion=\"3.5.0.2\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"HtmlAgilityPack\" publicKeyToken=\"bd319b19eaf3b43a\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-1.4.9.5\" newVersion=\"1.4.9.5\"/>\n </dependentAssembly>\n </assemblyBinding>\n </runtime>\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] |
267,011
|
<p>I'm trying to understand what this method means as I'm reading <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getpostbackeventreference.aspx" rel="noreferrer">this</a> and have wondered what uses this may have. I don't quite understand the example given.</p>
<p>Can anyone give another explanation of it. Examples would help.</p>
<p>Thanks</p>
|
[
{
"answer_id": 267246,
"author": "stevemegson",
"author_id": 25028,
"author_profile": "https://Stackoverflow.com/users/25028",
"pm_score": 4,
"selected": true,
"text": "href=\"javascript:__doPostBack('ctl00$LinkButton1','')\"\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5853/"
] |
267,025
|
<p>I need to read an Excel 2007 XLSX file in a Java application. Does anyone know of a good API to accomplish this task?</p>
|
[
{
"answer_id": 14396304,
"author": "Koss",
"author_id": 1691125,
"author_profile": "https://Stackoverflow.com/users/1691125",
"pm_score": 3,
"selected": false,
"text": " public Workbook getTemplateData(String xlsxFile) {\n Workbook workbook = new Workbook();\n parseSharedStrings(xlsxFile);\n parseWorkesheet(xlsxFile, workbook);\n parseComments(xlsxFile, workbook);\n for (Worksheet worksheet : workbook.sheets) {\n worksheet.dimension = manager.getDimension(worksheet);\n }\n\n return workbook;\n}\n\nprivate void parseComments(String tmpFile, Workbook workbook) {\n try {\n FileInputStream fin = new FileInputStream(tmpFile);\n final ZipInputStream zin = new ZipInputStream(fin);\n InputStream in = getInputStream(zin);\n while (true) {\n ZipEntry entry = zin.getNextEntry();\n if (entry == null)\n break;\n\n String name = entry.getName();\n if (name.endsWith(\".xml\")) { //$NON-NLS-1$\n if (name.contains(COMMENTS)) {\n parseComments(in, workbook);\n }\n }\n zin.closeEntry();\n }\n in.close();\n zin.close();\n fin.close();\n } catch (FileNotFoundException e) {\n System.out.println(e);\n } catch (IOException e) {\n e.printStackTrace();\n }\n}\n\nprivate void parseComments(InputStream in, Workbook workbook) {\n try {\n DefaultHandler handler = getCommentHandler(workbook);\n SAXParser saxParser = getSAXParser();\n saxParser.parse(in, handler);\n } catch (Exception e) {\n e.printStackTrace();\n }\n}\n\nprivate DefaultHandler getCommentHandler(Workbook workbook) {\n final Worksheet ws = workbook.sheets.get(0);\n return new DefaultHandler() {\n String lastTag = \"\";\n private Cell ccell;\n\n @Override\n public void startElement(String uri, String localName,\n String qName, Attributes attributes) throws SAXException {\n lastTag = qName;\n if (lastTag.equals(\"comment\")) {\n String cellName = attributes.getValue(\"ref\");\n int r = manager.getRowIndex(cellName);\n int c = manager.getColumnIndex(cellName);\n Row row = ws.rows.get(r);\n if (row == null) {\n row = new Row();\n row.index = r;\n ws.rows.put(r, row);\n }\n ccell = row.cells.get(c);\n if (ccell == null) {\n ccell = new Cell();\n ccell.cellName = cellName;\n row.cells.put(c, ccell);\n }\n }\n }\n\n @Override\n public void characters(char[] ch, int start, int length)\n throws SAXException {\n String val = \"\";\n if (ccell != null && lastTag.equals(\"t\")) {\n for (int i = start; i < start + length; i++) {\n val += ch[i];\n }\n if (ccell.comment == null)\n ccell.comment = val;\n else {\n ccell.comment += val;\n }\n }\n }\n };\n}\n\nprivate void parseSharedStrings(String tmpFile) {\n try {\n FileInputStream fin = new FileInputStream(tmpFile);\n final ZipInputStream zin = new ZipInputStream(fin);\n InputStream in = getInputStream(zin);\n while (true) {\n ZipEntry entry = zin.getNextEntry();\n if (entry == null)\n break;\n String name = entry.getName();\n if (name.endsWith(\".xml\")) { //$NON-NLS-1$\n if (name.startsWith(SHARED_STRINGS)) {\n parseStrings(in);\n }\n }\n zin.closeEntry();\n }\n in.close();\n zin.close();\n fin.close();\n } catch (FileNotFoundException e) {\n System.out.println(e);\n } catch (IOException e) {\n e.printStackTrace();\n }\n}\n\npublic void parseWorkesheet(String tmpFile, Workbook workbook) {\n try {\n FileInputStream fin = new FileInputStream(tmpFile);\n final ZipInputStream zin = new ZipInputStream(fin);\n InputStream in = getInputStream(zin);\n while (true) {\n ZipEntry entry = zin.getNextEntry();\n if (entry == null)\n break;\n\n String name = entry.getName();\n if (name.endsWith(\".xml\")) { //$NON-NLS-1$\n if (name.contains(\"worksheets\")) {\n Worksheet worksheet = new Worksheet();\n worksheet.name = name;\n parseWorksheet(in, worksheet);\n workbook.sheets.add(worksheet);\n }\n }\n zin.closeEntry();\n }\n in.close();\n zin.close();\n fin.close();\n } catch (FileNotFoundException e) {\n System.out.println(e);\n } catch (IOException e) {\n e.printStackTrace();\n }\n}\n\npublic void parseWorksheet(InputStream in, Worksheet worksheet)\n throws IOException {\n // read sheet1 sharedStrings\n // styles, strings, formulas ...\n try {\n DefaultHandler handler = getDefaultHandler(worksheet);\n SAXParser saxParser = getSAXParser();\n saxParser.parse(in, handler);\n } catch (SAXException e) {\n e.printStackTrace();\n } catch (ParserConfigurationException e) {\n e.printStackTrace();\n }\n}\n public class Workbook {\nInteger id = null;\npublic List<Worksheet> sheets = new ArrayList<Worksheet>();}\n public class Worksheet {\npublic Integer id = null;\npublic String name = null;\npublic String dimension = null;\npublic Map<Integer, Row> rows = new TreeMap<Integer, Row>();\npublic Map<Integer, Column> columns = new TreeMap<Integer, Column>();\npublic List<Span> spans = new ArrayList<Span>();}\n public class Row {\npublic Integer id = null;\npublic Integer index = null;\npublic Row tmpRow = null;\npublic Style style = null;\npublic Double height = null;\npublic Map<Integer,Cell> cells = new TreeMap<Integer, Cell>();\npublic String spans = null;\npublic Integer customHeight = null;}\n public class Cell {\npublic Integer id = null;\npublic Integer rowIndex = null;\npublic Integer colIndex = null;\npublic String cellName = null;\npublic String text = null;\npublic String formula = null;\npublic String comment = null;\npublic Style style = null;\npublic Object value = null;\npublic Cell tmpCell = null;}\n public class Column {\n public Integer index = null;\n public Style style = null;\n public String width = null;\n public Column tmpColumn = null;\n}\n public class Span {\n Integer id = null;\n String topLeft = null;\n String bottomRight = null;\n}\n"
},
{
"answer_id": 33569515,
"author": "Matthias Braun",
"author_id": 775954,
"author_profile": "https://Stackoverflow.com/users/775954",
"pm_score": 1,
"selected": false,
"text": "String parse(File xlsxFile) {\n return new Tika().parseToString(xlsxFile);\n}\n void parse(File xlsx) {\n try (XSSFWorkbook workbook = new XSSFWorkbook(xlsx)) {\n // Handle each cell in each sheet\n workbook.forEach(sheet -> sheet.forEach(row -> row.forEach(this::handle)));\n }\n catch (InvalidFormatException | IOException e) {\n System.out.println(\"Can't parse file \" + xlsx);\n }\n}\n\nvoid handle(Cell cell) {\n final String cellContent;\n switch (cell.getCellType()) {\n case Cell.CELL_TYPE_STRING:\n cellContent = cell.getStringCellValue();\n break;\n case Cell.CELL_TYPE_NUMERIC:\n cellContent = String.valueOf(cell.getNumericCellValue());\n break;\n case Cell.CELL_TYPE_BOOLEAN:\n cellContent = String.valueOf(cell.getBooleanCellValue());\n break;\n default:\n cellContent = \"Don't know how to handle cell \" + cell;\n }\n System.out.println(cellContent);\n}\n"
},
{
"answer_id": 52089564,
"author": "patidarsnju",
"author_id": 9539850,
"author_profile": "https://Stackoverflow.com/users/9539850",
"pm_score": 1,
"selected": false,
"text": "org.apache.poi.ss OPCPackage pkg = OPCPackage.open(new ByteArrayInputStream(data));\n Workbook wb = new XSSFWorkbook(pkg);\n Sheet sheet = wb.getSheetAt(0);\n Iterator<Row> rows = sheet.rowIterator();\n\n while (rows.hasNext()) {\n int j = 5;\n Person person= new Person ();\n Row row = rows.next();\n if (row.getRowNum() > 0) {\n person.setPersonId((int)(row.getCell(0).getNumericCellValue()));\n person.setFirstName(row.getCell(1).getStringCellValue());\n person.setLastName(row.getCell(2).getStringCellValue());\n person.setGroupId((int)(row.getCell(3).getNumericCellValue()));\n person.setUserName(row.getCell(4).getStringCellValue());\n person.setCreditId((int)(row.getCell(5).getNumericCellValue()));\n }\n\n }\n\nExcel 1998-2003 file (.xls) - you may use HSSF library.\n just use : Workbook wb = new HSSFWorkbook(pkg);\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32435/"
] |
267,026
|
<p>This very simple code gives me tons of errors:</p>
<pre><code>#include <iostream>
#include <string>
int main() {
std::string test = " ";
std::cout << test;
}
</code></pre>
<p>I tried to compile it on linux by typing <strong>gcc -o simpletest simpletest.cpp</strong> on the console. I can't see why it isn't working. What is happening?</p>
|
[
{
"answer_id": 267031,
"author": "rmeador",
"author_id": 10861,
"author_profile": "https://Stackoverflow.com/users/10861",
"pm_score": 0,
"selected": false,
"text": "main() int return 0;"
},
{
"answer_id": 267034,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 3,
"selected": false,
"text": "g++ -o simpletest simpletest.cpp\n"
},
{
"answer_id": 267039,
"author": "MP24",
"author_id": 6206,
"author_profile": "https://Stackoverflow.com/users/6206",
"pm_score": 3,
"selected": false,
"text": "g++ -o simpletest simpletest.cpp return 0; main()"
},
{
"answer_id": 267078,
"author": "RAGNO",
"author_id": 11540,
"author_profile": "https://Stackoverflow.com/users/11540",
"pm_score": 2,
"selected": false,
"text": "return 0;"
},
{
"answer_id": 267099,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 3,
"selected": false,
"text": "g++ gcc gcc g++ gcc gcc g++ gcc gcc gcc -o simpletest simpletest.cpp -lstdc++"
},
{
"answer_id": 10180787,
"author": "Bill IV",
"author_id": 280769,
"author_profile": "https://Stackoverflow.com/users/280769",
"pm_score": 0,
"selected": false,
"text": "// too simple!\n\n#include <iostream.h>\n#include <stdlib.h>\n\nmain() {\n cout << \"Hello World!\" << endl;\n}\n #include <iostream>\n#include <stdlib.h>\n\nint main(int argc, char* argv[] ) {\n std::cout << \"Hello World!\" << std::endl;\n// TODO - this ought to return success, 0\n}\n <string>... \n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27090/"
] |
267,030
|
<p>I'm needing to script my build. I'm using MSBUILD because of it's integration with VS.net. I am trying to copy some files from the build environment to the deployment folder. I'm using the copy task of MSBuild. But instead of copying the directory tree as I would expect. it copies all the contents into a single folder. I repeat all the files from the directory tree end up in one folder. I need it to copy the tree of folders and directories into the destination folder. Is there something I'm missing?</p>
<p>Here is the relavant parts of my build script:</p>
<pre><code><PropertyGroup>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<Source>outputfolder</Source>
<DestEnv>x</DestEnv>
<DeployPath>\\networkpath\$(DestEnv)</DeployPath>
</PropertyGroup>
<ItemGroup>
<TargetDir Include="$(DeployPath)\**\*" Exclude="**\web.config"></TargetDir>
<SourceDir Include="$(Source)\**\*" />
</ItemGroup>
<Target Name="Clean" >
<!-- clean detail ... -->
</Target>
<Target Name="migrate" DependsOnTargets="Clean">
<Copy DestinationFolder="$(DeployPath)" SourceFiles="@(SourceDir)" />
</Target>
</code></pre>
|
[
{
"answer_id": 267088,
"author": "minty",
"author_id": 4491,
"author_profile": "https://Stackoverflow.com/users/4491",
"pm_score": 2,
"selected": false,
"text": "<Target Name=\"migrate\" DependsOnTargets=\"Clean\">\n <Copy DestinationFiles=\"@(SourceDir->'$(DeployPath)\\%(RecursiveDir)%(Filename)%(Extension)')\" SourceFiles=\"@(SourceDir)\" />\n</Target>\n"
},
{
"answer_id": 267110,
"author": "Franci Penov",
"author_id": 17028,
"author_profile": "https://Stackoverflow.com/users/17028",
"pm_score": 4,
"selected": false,
"text": "<ItemGroup>\n <SourceDir Include=\"$(Source)\\**\\*\" />\n <SourceDir Include=\"E:\\ExternalDependencies\\**\\*\" />\n <SourceDir Include=\"\\\\sharedlibraries\\gdiplus\\*.h\" />\n</ItemGroup>\n <Copy SourceFiles=\"@(Compile)\" DestinationFiles=\"@(Compile->'$(DropPath)%(Identity)')\" />\n <Copy SourceFiles=\"@(Compile)\" DestinationFiles=\"@(Compile->'$(DestinationFolder)%(Identity)')\" />\n"
},
{
"answer_id": 274974,
"author": "Adam",
"author_id": 1341,
"author_profile": "https://Stackoverflow.com/users/1341",
"pm_score": 3,
"selected": false,
"text": "<Copy SourceFiles=\"@(Compile)\" DestinationFolder=\"c:\\foocopy\\%(Compile.RecursiveDir)\"></Copy>\n <ItemGroup>\n <Compile Include=\".\\**\\*.dll\" /> \n </ItemGroup>\n"
},
{
"answer_id": 434742,
"author": "Jarrod Dixon",
"author_id": 3,
"author_profile": "https://Stackoverflow.com/users/3",
"pm_score": 4,
"selected": false,
"text": "<Target Name=\"Copy\" >\n <CreateItem Include=\"..\\Source\\**\\bin\\**\\*.exe\"\n Exclude=\"..\\Source\\**\\bin\\**\\*.vshost.exe\">\n <Output TaskParameter=\"Include\" ItemName=\"CompileOutput\" />\n </CreateItem>\n <Copy SourceFiles=\"@(CompileOutput)\" \n DestinationFolder=\"$(OutputDirectory)\"></Copy>\n</Target>\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] |
267,033
|
<p>Say I have a list of all <code>Projects</code>, and that I group them by <code>Category</code> like this:</p>
<pre><code>var projectsByCat = from p in Projects
group p by p.Category into g
orderby g.Count() descending
select new { Category = g.Key, Projects = g };
</code></pre>
<p>Now I want to display this as a list in a web page, where first I create the left side div, secondly the right side div. I am ordering by number of <code>Projects</code> in each <code>Category</code> to show the <code>Categories</code> with the most <code>Projects</code> on top - thus I would like to split <code>projectsByCat</code> in two - if I put all the "odd numbered" <code>Categories</code> on the left and the "even numbered" categories on the right, I think I will get a reasonably sane view.</p>
<p>So I thought I could do this to get the odd and even members of <code>projectsByCat</code>:</p>
<pre><code>var oddCategories = projectsByCat.Where((cat, index) => index % 2 != 0);
var evenCategories = projectsByCat.Where((cat, index) => index % 2 == 0);
</code></pre>
<p>And it compiles - however, when I run it, I get an exception such as this:</p>
<blockquote>
<p>Unsupported overload used for query operator 'Where'.</p>
</blockquote>
<p>And I thought I was safe since it compiled in the first place.. ;)</p>
<p>Is there an elegant way to do this? And also, is there an elegant explanation for why my creative use of <code>Where()</code> won't work?</p>
|
[
{
"answer_id": 267053,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 7,
"selected": true,
"text": "var oddCategories = projectsByCat.ToList().Where((c,i) => i % 2 != 0);\nvar evenCategories = projectsByCat.ToList().Where((c,i) => i % 2 == 0);\n"
},
{
"answer_id": 267235,
"author": "Jacob Carpenter",
"author_id": 26627,
"author_profile": "https://Stackoverflow.com/users/26627",
"pm_score": 5,
"selected": false,
"text": ".ToList() var projectsByCat =\n (from p in Projects\n group p by p.Category into g\n orderby g.Count() descending\n select new { Category = g.Key, Projects = g }).ToList();\n\nvar oddCategories = projectsByCat.Where((cat, index) => index % 2 != 0);\nvar evenCategories = projectsByCat.Where((cat, index) => index % 2 == 0);\n"
},
{
"answer_id": 6343500,
"author": "bjhamltn",
"author_id": 427534,
"author_profile": "https://Stackoverflow.com/users/427534",
"pm_score": 3,
"selected": false,
"text": "var oddCategories = projectsByCat.Where((cat, index) => index % 2 == 0);\n\nvar evenCategories = projectsByCat.Where((cat, index) => index % 2 != 0);\n"
},
{
"answer_id": 37384168,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "Select ToLookup var oddsAndEvens = input\n .ToList() // if necessary to get from IQueryable to IEnumerable\n .Select((item, index) => new { isEven = index % 2 == 0, item })\n .ToLookup(\n i => i.isEven,\n i => i.item);\n Lookup<TKey, TElement> var evens = oddsAndEvens[true];\nvar odds = oddsAndEvens[false];\n"
},
{
"answer_id": 42022394,
"author": "Athul Nalupurakkal",
"author_id": 4136430,
"author_profile": "https://Stackoverflow.com/users/4136430",
"pm_score": 1,
"selected": false,
"text": "//even \n@foreach (var item in Model.Where((item, index) => index % 2 == 0))\n{\n //do the code\n}\n\n//odd\n@foreach (var item in Model.Where((item, index) => index % 2 != 0))\n{\n //do the code\n}\n"
},
{
"answer_id": 45640412,
"author": "Sam Saarian",
"author_id": 1617686,
"author_profile": "https://Stackoverflow.com/users/1617686",
"pm_score": 0,
"selected": false,
"text": "var text = \"this is a test <string> to extract odd <index> values after split\";\nvar parts = text.Split(new char[] { '<', '>' });\nIEnumerable words = parts.Where(x => parts.ToList().IndexOf(x) % 2 == 1)\n"
},
{
"answer_id": 49890217,
"author": "Hrishikesh Kulkarni",
"author_id": 9620863,
"author_profile": "https://Stackoverflow.com/users/9620863",
"pm_score": 0,
"selected": false,
"text": "static void Main(string[] args)\n{\n List<int> lstnum = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\n\n List<int> lstresult = lstnum.FindAll(x => (x % 2) == 0);\n\n lstresult.ForEach(x => Console.WriteLine(x));\n}\n"
},
{
"answer_id": 74255511,
"author": "jptrujillol",
"author_id": 20373528,
"author_profile": "https://Stackoverflow.com/users/20373528",
"pm_score": 0,
"selected": false,
"text": " List<string> lista = new List<string> { \"uno\", \"dos\", \"tres\", \"cuatro\" };\n\n var grupoXindices = lista.GroupBy(i => (lista.IndexOf(i) % 2) == 0);\n foreach (var grupo in grupoXindices) \n {\n Console.WriteLine(grupo.Key); \n foreach (var i in grupo) Console.WriteLine(i);\n }\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2122/"
] |
267,045
|
<p>I started out with a generic interface called ILogin. The interfaces requires that you implement two properties: UserID and Password. I have many login-type classes that implement this interface. As my project grew and grew, I found that many classes repeated the UserID and Password code. Now I decide that I need a base Login class. </p>
<p>Is it proper to create an abstract base Login class that implements the ILogin interface and have all of my concrete classes just inherit from the abstract class and override when necessary? Originally I was thinking there would be no problem with this. Then I started think that ILogin was probably unneeded because it'll likely only ever be implemented by my abstract class.</p>
<p>Is there a benefit to keeping both the abstract class and the interface around?</p>
<p>Thanks!</p>
|
[
{
"answer_id": 267118,
"author": "coobird",
"author_id": 17172,
"author_profile": "https://Stackoverflow.com/users/17172",
"pm_score": 5,
"selected": true,
"text": "Animal Cat Dog Mosquito Eagle Eat() Breathe() Sleep() Animal Fly() Mosquito Eagle IFly IFly Fly() Mosquito Eagle Animal IFly Eat() Breathe() Sleep() Fly()"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132931/"
] |
267,057
|
<p>I hope someone can help me with this, I'm mostly a C# developer so my
C and C++ skills are bad. I have a native C dll that is a plugin of a
larger application. I cross compile this dll for windows on linux
using gcc.</p>
<p>In the native dll when I create a D3DSurface I want to call a function
in a Mixed Mode C++ dll and pass in the pointer to the surface along
with a Hwnd/handle. That Mixed Mode C++ should then call my C#
managed code.</p>
<p>As an example, in C I want to do the following;</p>
<pre><code>Hwnd handle;
LPDIRECT3DSURFACE d3dtarg;
SurfaceCreated(handle, d3dtarg);
</code></pre>
<p>In C# I want this called from the mixed mode assembly</p>
<pre><code>public static class D3DInterop
{
public static void SurfaceCreated(IntPtr handle, IntPtr surface)
{
//do work
}
}
</code></pre>
<p>Since I suck at C++, I just want to know if someone can give me an
example of what I need to code for the mixed mode dll. I'd also like
to not have to compile the mixed mode dll with directx headers, so is
there a way I can cast the 'C' LPDIRECT3DSURFACE into a generic
pointer? In C# I just use the IntPtr anyway. </p>
|
[
{
"answer_id": 268822,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 0,
"selected": false,
"text": "void * IDirect3DSurface void * IntPtr"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,064
|
<p>Why is the dropdown not showing my blank item first? Here is what I have</p>
<pre><code>drpList.Items.Add(New ListItem("", ""))
With drpList
.DataSource = myController.GetList(userid)
.DataTextField = "Name"
.DataValueField = "ID"
.DataBind()
End With
</code></pre>
<p>Edit ~ I am binding to a Generig List, could this be the culprit?</p>
|
[
{
"answer_id": 267080,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 3,
"selected": false,
"text": "Dim liFirst As New ListItem(\"\", \"\")\ndrpList.Items.Insert(0, liFirst)\n"
},
{
"answer_id": 267082,
"author": "JasonS",
"author_id": 1865,
"author_profile": "https://Stackoverflow.com/users/1865",
"pm_score": 9,
"selected": true,
"text": "drpList.Items.Insert(0, new ListItem(String.Empty, String.Empty));\ndrpList.SelectedIndex = 0;\n"
},
{
"answer_id": 659354,
"author": "Andy McCluggage",
"author_id": 3362,
"author_profile": "https://Stackoverflow.com/users/3362",
"pm_score": 4,
"selected": false,
"text": "AppendDataBoundItems public static void BindList(ListControl list, IEnumerable datasource, string valueName, string textName)\n{\n list.Items.Clear();\n list.Items.Add(\"\", \"\");\n list.AppendDataBoundItems = true;\n list.DataValueField = valueName;\n list.DataTextField = textName;\n list.DataSource = datasource;\n list.DataBind();\n}\n"
},
{
"answer_id": 4060487,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "protected void Page_Load(object sender, EventArgs e)\n{\n if (!IsPostBack)\n {\n DropDownList1.AppendDataBoundItems = true;\n DropDownList1.Items.Insert(0, new ListItem(String.Empty, String.Empty));\n DropDownList1.SelectedIndex = 0;\n }\n}\n"
},
{
"answer_id": 10498971,
"author": "Umesh",
"author_id": 1382097,
"author_profile": "https://Stackoverflow.com/users/1382097",
"pm_score": 2,
"selected": false,
"text": "ddlProducer.Items.Insert(0, \"\");\n"
},
{
"answer_id": 13597034,
"author": "ayhtut",
"author_id": 1858461,
"author_profile": "https://Stackoverflow.com/users/1858461",
"pm_score": 5,
"selected": false,
"text": "AppendDataBoundItems=true <asp:DropDownList ID=\"drpList\" AppendDataBoundItems=\"true\" runat=\"server\">\n <asp:ListItem Text=\"\" Value=\"\" />\n</asp:DropDownList>\n"
},
{
"answer_id": 16186763,
"author": "Chưa biết",
"author_id": 2246088,
"author_profile": "https://Stackoverflow.com/users/2246088",
"pm_score": 1,
"selected": false,
"text": "ddlCategory.DataSource = ds; ddlCategory.DataTextField = \"CatName\"; ddlCategory.DataValueField = \"CatID\"; ddlCategory.Items.Add(new ListItem(\"--please select--\", \"-1\")); ddlCategory.AppendDataBoundItems = true; ddlCategory.SelectedIndex = -1; ddlCategory.DataBind(); ddlCategory.Items.Insert(0, new ListItem(\"-- please select --\", \"0\"));"
},
{
"answer_id": 28820158,
"author": "BitsAndBytes",
"author_id": 407635,
"author_profile": "https://Stackoverflow.com/users/407635",
"pm_score": 0,
"selected": false,
"text": "select '' value, '' name\nunion\nselect value, name from mytable\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23667/"
] |
267,071
|
<p>I'm using the JSP <a href="http://displaytag.sourceforge.net/11/" rel="nofollow noreferrer">displaytag</a> tag lib to create HTML tables. I'd like the user to able to click on a column header in order to sort the data. My JSP code is shown below:</p>
<pre><code><display:table name="tableData" id="stat" sort="page">
<display:column property="name" title="Name" sortable="true"/>
<display:column property="age" title="Age" sortable="true"/>
</display:table>
</code></pre>
<p>I thought this would cause the data to be sorted on the client-side (in JavaScript), but what it actually does is create a broken hyperlink on the column header back to the server.</p>
<p>Is it possible to use displaytag to sort data on the client-side? If so, how?</p>
<p>Cheers,
Don</p>
|
[
{
"answer_id": 267365,
"author": "MetroidFan2002",
"author_id": 8026,
"author_profile": "https://Stackoverflow.com/users/8026",
"pm_score": 3,
"selected": false,
"text": "<display:table requestURI=\"yourUrlMappedController.yourExtension\" ...>\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] |
267,076
|
<p>Could someone please tell me which objects types can be tested using Regular Expressions in C#?</p>
|
[
{
"answer_id": 267084,
"author": "Manu",
"author_id": 2133,
"author_profile": "https://Stackoverflow.com/users/2133",
"pm_score": 4,
"selected": true,
"text": "if(obj is string){...}\n"
},
{
"answer_id": 267105,
"author": "ripper234",
"author_id": 11236,
"author_profile": "https://Stackoverflow.com/users/11236",
"pm_score": 0,
"selected": false,
"text": "Regex.IsMatch()\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] |
267,085
|
<p>I'm trying to convert the below SQL query to HQL and am having a few issues. A straight line by line conversion doesn't work, I am wondering if I should be using an Inner Join in the HQL?</p>
<pre><code> SELECT (UNIX_TIMESTAMP(cosc1.change_date) - UNIX_TIMESTAMP(cosc2.change_date))
FROM customer_order_state_change cosc1
LEFT JOIN customer_order_state cos1_new on cosc1.new_state_id = cos1_new.customer_order_state_id
LEFT JOIN customer_order_state cos1_old on cosc1.old_state_id = cos1_old.customer_order_state_id
LEFT JOIN customer_order_state_change cosc2 on cosc2.customer_order_id = cosc1.customer_order_id
LEFT JOIN customer_order_state cos2_new on cosc2.new_state_id = cos2_new.customer_order_state_id
LEFT JOIN customer_order_state cos2_old on cosc2.old_state_id = cos2_old.customer_order_state_id
WHERE cos1_new.name = "state1" AND cos2_new.name = "state2" and cosc2.change_date < "2008-11-06 09:00"
AND cosc2.change_date > "2008-11-06 06:00" GROUP BY cosc1.change_date, cosc2.change_date ;
</code></pre>
<p>Query returns time in seconds between state changes for a customer order.</p>
<p>The state names and dates are dynamically inserted into the query.</p>
<p>Edit:
Just tried this</p>
<pre><code>"SELECT (UNIX_TIMESTAMP(cosc1.changeDate) - UNIX_TIMESTAMP(cosc2.changeDate))" +
" FROM" +
" " + CustomerOrderStateChange.class.getName() + " as cosc1" +
" INNER JOIN " + CustomerOrderStateChange.class.getName() + " as cosc2" +
" WHERE cosc1.newState.name = ?" +
" AND cosc1.order.id = cosc2.order.id" +
" AND cosc2.newState.name = ?" +
" AND cosc2.changeDate < ?" +
" AND cosc2.changeDate > ?" +
" GROUP BY cosc1.changeDate, cosc2.changeDate";
</code></pre>
<p>and received exception"<em>outer or full join must be followed by path expression</em>"</p>
|
[
{
"answer_id": 267166,
"author": "Nick",
"author_id": 34558,
"author_profile": "https://Stackoverflow.com/users/34558",
"pm_score": 4,
"selected": true,
"text": "from Foo f inner join f.bar as b session.createSQLQuery(...)"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18340/"
] |
267,091
|
<p>At the risk of being downmodded, I want to ask what the best mechanism (best is obviously subjective for the practice violation inherent here) for viewing data from a table, using C#, with a <em>lot</em> of columns. By a lot, I mean something like 1000.</p>
<p>Now before you get all click happy, or throw out responses like "why the hell would you ever have a table with that many columns" let me say that it's actually part of a design requirement. We are collecting data as fast as we can from 1000 data points. We need to store these as fast as possible, hence the flat table. The data needs to be directly accessible from SQL Server, hence the database (we're using SQL Compact with table-direct).</p>
<p>So let's forget, for now, all that we've learned about proper database design, the rules of normalization, etc. and just focus on the fact that I have a table with 1000 columns and I want to be able to display the data on screen to verify that the data is actually going in there.</p>
<p>I've tried a data grid. It pukes because (not surprisingly) it's not designed to handle that many columns.</p>
<p>I've tried using the viewer in Studio. It pukes after 256, plus the end user won't have Studio installed anyway.</p>
<p>For now the result need not be pretty, it need not be updateable, nor does it need to be sensitive to data changes - just a static snapshot of data in the table at a given point in time.</p>
<p>Relevant (or semi-relevant) info:</p>
<ul>
<li>Table has 1000 columns (read above before getting click happy)</li>
<li>Using SQL Compact version 3.5</li>
<li>Running on the desktop</li>
<li>Looking for a managed-code answer</li>
</ul>
|
[
{
"answer_id": 267107,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 2,
"selected": false,
"text": "td { font-size: 0.2em; text-align: right; }\n"
},
{
"answer_id": 267112,
"author": "Whisk",
"author_id": 908,
"author_profile": "https://Stackoverflow.com/users/908",
"pm_score": 0,
"selected": false,
"text": "SELECT Field1 + ' - ' + Field2 + ... AS EvilMegaColumn FROM Table\n"
},
{
"answer_id": 267132,
"author": "Matthew Watson",
"author_id": 3839,
"author_profile": "https://Stackoverflow.com/users/3839",
"pm_score": 2,
"selected": false,
"text": "Id = 1\n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\n----|--------------------------------------------------------\n 0 | \n 20 | \n 40 |\n 60 |\n 80 |\n100 |\n120 |\netc |\n"
},
{
"answer_id": 267471,
"author": "configurator",
"author_id": 9536,
"author_profile": "https://Stackoverflow.com/users/9536",
"pm_score": 4,
"selected": false,
"text": "1 2 3 4 6 36 436 6346\n2 3 4 6 36 436 6346 0\n3 4 6 36 436 6346 3 4\n4 6 36 436 6346 333 222 334\n"
},
{
"answer_id": 270576,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 5,
"selected": true,
"text": "public static Stream BuildRDLCStream(\n DataSet data, string name, string reportXslPath)\n{\n using (MemoryStream schemaStream = new MemoryStream())\n {\n // save the schema to a stream\n data.WriteXmlSchema(schemaStream);\n schemaStream.Seek(0, SeekOrigin.Begin);\n\n // load it into a Document and set the Name variable\n XmlDocument xmlDomSchema = new XmlDocument();\n xmlDomSchema.Load(schemaStream); \n xmlDomSchema.DocumentElement.SetAttribute(\"Name\", data.DataSetName);\n\n // load the report's XSL file (that's the magic)\n XslCompiledTransform xform = new XslCompiledTransform();\n xform.Load(reportXslPath);\n\n // do the transform\n MemoryStream rdlcStream = new MemoryStream();\n XmlWriter writer = XmlWriter.Create(rdlcStream);\n xform.Transform(xmlDomSchema, writer);\n writer.Close();\n rdlcStream.Seek(0, SeekOrigin.Begin);\n\n // send back the RDLC\n return rdlcStream;\n }\n}\n ds.DataSetName = name;\n\nStream rdlc = RdlcEngine.BuildRDLCStream(\n ds, name, \"c:\\\\temp\\\\rdlc\\\\report.xsl\");\n\nreportView.LocalReport.LoadReportDefinition(rdlc);\nreportView.LocalReport.DataSources.Clear();\nreportView.LocalReport.DataSources.Add(\n new ReportDataSource(ds.DataSetName, ds.Tables[0]));\nreportView.RefreshReport();\n <?xml version=\"1.0\"?>\n <!-- Stylesheet for creating ReportViewer RDLC documents -->\n <xsl:stylesheet version=\"1.0\"\n xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\n xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\"\n xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\"\n xmlns:rd=\"http://schemas.microsoft.com/SQLServer/reporting/reportdesigner\" xmlns=\"http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition\"\n >\n\n <xsl:variable name=\"mvarName\" select=\"/xs:schema/@Name\"/>\n <xsl:variable name=\"mvarFontSize\">8pt</xsl:variable>\n <xsl:variable name=\"mvarFontWeight\">500</xsl:variable>\n <xsl:variable name=\"mvarFontWeightBold\">700</xsl:variable>\n\n\n <xsl:template match=\"/\">\n <xsl:apply-templates select=\"/xs:schema/xs:element/xs:complexType/xs:choice/xs:element/xs:complexType/xs:sequence\">\n </xsl:apply-templates>\n </xsl:template>\n\n <xsl:template match=\"xs:sequence\">\n <Report xmlns:rd=\"http://schemas.microsoft.com/SQLServer/reporting/reportdesigner\" xmlns=\"http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition\">\n <BottomMargin>1in</BottomMargin>\n <RightMargin>1in</RightMargin>\n <LeftMargin>1in</LeftMargin>\n <TopMargin>1in</TopMargin>\n <InteractiveHeight>11in</InteractiveHeight>\n <InteractiveWidth>8.5in</InteractiveWidth>\n <Width>6.5in</Width>\n <Language>en-US</Language>\n <rd:DrawGrid>true</rd:DrawGrid>\n <rd:SnapToGrid>true</rd:SnapToGrid>\n <rd:ReportID>7358b654-3ca3-44a0-8677-efe0a55c7c45</rd:ReportID>\n\n <xsl:call-template name=\"BuildDataSource\">\n </xsl:call-template>\n\n <xsl:call-template name=\"BuildDataSet\">\n </xsl:call-template>\n\n <Body>\n <Height>0.50in</Height>\n <ReportItems>\n <Table Name=\"table1\">\n <DataSetName><xsl:value-of select=\"$mvarName\" /></DataSetName>\n <Top>0.5in</Top>\n <Height>0.50in</Height>\n <Header>\n <TableRows>\n <TableRow>\n <Height>0.25in</Height>\n <TableCells>\n\n <xsl:apply-templates select=\"xs:element\" mode=\"HeaderTableCell\">\n </xsl:apply-templates>\n\n </TableCells>\n </TableRow>\n </TableRows>\n </Header>\n <Details>\n <TableRows>\n <TableRow>\n <Height>0.25in</Height>\n <TableCells>\n\n <xsl:apply-templates select=\"xs:element\" mode=\"DetailTableCell\">\n </xsl:apply-templates>\n\n </TableCells>\n </TableRow>\n </TableRows>\n </Details>\n <TableColumns>\n\n <xsl:apply-templates select=\"xs:element\" mode=\"TableColumn\">\n </xsl:apply-templates>\n\n </TableColumns>\n </Table>\n </ReportItems>\n </Body>\n </Report>\n </xsl:template>\n\n <xsl:template name=\"BuildDataSource\">\n <DataSources>\n <DataSource Name=\"DummyDataSource\">\n <ConnectionProperties>\n <ConnectString/>\n <DataProvider>SQL</DataProvider>\n </ConnectionProperties>\n <rd:DataSourceID>84635ff8-d177-4a25-9aa5-5a921652c79c</rd:DataSourceID>\n </DataSource>\n </DataSources>\n </xsl:template>\n\n <xsl:template name=\"BuildDataSet\">\n <DataSets>\n <DataSet Name=\"{$mvarName}\">\n <Query>\n <rd:UseGenericDesigner>true</rd:UseGenericDesigner>\n <CommandText/>\n <DataSourceName>DummyDataSource</DataSourceName>\n </Query>\n <Fields>\n\n <xsl:apply-templates select=\"xs:element\" mode=\"Field\">\n </xsl:apply-templates>\n\n </Fields>\n </DataSet>\n </DataSets>\n </xsl:template>\n\n <xsl:template match=\"xs:element\" mode=\"Field\">\n <xsl:variable name=\"varFieldName\"> \n <xsl:value-of select=\"@name\" />\n </xsl:variable>\n\n <xsl:variable name=\"varDataType\">\n <xsl:choose>\n <xsl:when test=\"@type='xs:int'\">System.Int32</xsl:when>\n <xsl:when test=\"@type='xs:string'\">System.String</xsl:when>\n <xsl:when test=\"@type='xs:dateTime'\">System.DateTime</xsl:when>\n <xsl:when test=\"@type='xs:boolean'\">System.Boolean</xsl:when>\n </xsl:choose>\n </xsl:variable>\n\n <Field Name=\"{$varFieldName}\">\n <rd:TypeName><xsl:value-of select=\"$varDataType\"/></rd:TypeName>\n <DataField><xsl:value-of select=\"$varFieldName\"/></DataField>\n </Field>\n </xsl:template>\n\n <xsl:template match=\"xs:element\" mode=\"HeaderTableCell\">\n <xsl:variable name=\"varFieldName\"> \n <xsl:value-of select=\"@name\" />\n </xsl:variable>\n\n <TableCell>\n <ReportItems>\n <Textbox Name=\"textbox{position()}\">\n <rd:DefaultName>textbox<xsl:value-of select=\"position()\"/>\n </rd:DefaultName>\n <Value><xsl:value-of select=\"$varFieldName\"/></Value>\n <CanGrow>true</CanGrow>\n <ZIndex>7</ZIndex>\n <Style>\n <TextAlign>Center</TextAlign>\n <PaddingLeft>2pt</PaddingLeft>\n <PaddingBottom>2pt</PaddingBottom>\n <PaddingRight>2pt</PaddingRight>\n <PaddingTop>2pt</PaddingTop>\n <FontSize><xsl:value-of select=\"$mvarFontSize\"/></FontSize> \n <FontWeight><xsl:value-of select=\"$mvarFontWeightBold\"/></FontWeight> \n <BackgroundColor>#000000</BackgroundColor> \n <Color>#ffffff</Color>\n <BorderColor>\n <Default>#ffffff</Default>\n </BorderColor>\n <BorderStyle>\n <Default>Solid</Default>\n </BorderStyle>\n </Style>\n </Textbox>\n </ReportItems>\n </TableCell>\n </xsl:template>\n\n <xsl:template match=\"xs:element\" mode=\"DetailTableCell\">\n <xsl:variable name=\"varFieldName\"> \n <xsl:value-of select=\"@name\" />\n </xsl:variable>\n\n <TableCell>\n <ReportItems>\n <Textbox Name=\"{$varFieldName}\">\n <rd:DefaultName><xsl:value-of select=\"$varFieldName\"/></rd:DefaultName>\n <Value>=Fields!<xsl:value-of select=\"$varFieldName\"/>.Value</Value>\n <CanGrow>true</CanGrow>\n <ZIndex>7</ZIndex>\n <Style>\n <TextAlign>Left</TextAlign>\n <PaddingLeft>2pt</PaddingLeft>\n <PaddingBottom>2pt</PaddingBottom>\n <PaddingRight>2pt</PaddingRight>\n <PaddingTop>2pt</PaddingTop>\n <FontSize><xsl:value-of select=\"$mvarFontSize\"/></FontSize> \n <FontWeight><xsl:value-of select=\"$mvarFontWeight\"/></FontWeight> \n <BackgroundColor>#e0e0e0</BackgroundColor> \n <Color>#000000</Color> \n <BorderColor>\n <Default>#ffffff</Default> \n </BorderColor>\n <BorderStyle>\n <Default>Solid</Default>\n </BorderStyle>\n </Style>\n </Textbox>\n </ReportItems>\n </TableCell>\n </xsl:template>\n\n <xsl:template match=\"xs:element\" mode=\"TableColumn\">\n <TableColumn>\n <Width>0.75in</Width>\n </TableColumn>\n </xsl:template>\n\n <xsl:template name=\"replace-string\">\n <xsl:param name=\"text\"/>\n <xsl:param name=\"from\"/>\n <xsl:param name=\"to\"/>\n <xsl:choose>\n <xsl:when test=\"contains($text, $from)\">\n <xsl:variable name=\"before\" select=\"substring-before($text, $from)\"/>\n <xsl:variable name=\"after\" select=\"substring-after($text, $from)\"/>\n <xsl:variable name=\"prefix\" select=\"concat($before, $to)\"/>\n <xsl:value-of select=\"$before\"/>\n <xsl:value-of select=\"$to\"/>\n <xsl:call-template name=\"replace-string\">\n <xsl:with-param name=\"text\" select=\"$after\"/>\n <xsl:with-param name=\"from\" select=\"$from\"/>\n <xsl:with-param name=\"to\" select=\"$to\"/>\n </xsl:call-template>\n </xsl:when>\n <xsl:otherwise>\n <xsl:value-of select=\"$text\"/>\n </xsl:otherwise>\n </xsl:choose>\n </xsl:template>\n </xsl:stylesheet>\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13154/"
] |
267,101
|
<p>once you have a commit that contains a submodule object, you pretty much cannot get git-svn to commit past it.</p>
<p>Any ideas, workarounds, anything that is not "don't use submodules with git-svn"?</p>
<p>So far the answer seems to be a big NO.</p>
<p>Is there any way to at least allow existing git commits containing submodule data to be committed to svn without the submodule data? Even if it means rewriting the tree.</p>
|
[
{
"answer_id": 286185,
"author": "Aupajo",
"author_id": 10407,
"author_profile": "https://Stackoverflow.com/users/10407",
"pm_score": 1,
"selected": false,
"text": "svn:externals svn propset svn:externals [...]\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13989/"
] |
267,113
|
<p>I’m trying to implement a dictionary for use with WCF. My requirements are:</p>
<ul>
<li>actual (private variable or base
class) type equivalent to
Dictionary </li>
<li>Comparer
= <code>System.StringComparer.InvariantCultureIgnoreCase</code></li>
<li>Custom (override/new) Add(key,
value) method (to include
validations). </li>
<li>Override ToString()</li>
<li>Use of the same type on both the client and host</li>
</ul>
<p>I’ve attempted using this class in a common project shared by the WCF host and client projects:</p>
<pre><code>[Serializable]
public class MyDictionary : Dictionary<string, object>
{
public MyDictionary()
: base(System.StringComparer.InvariantCultureIgnoreCase)
{ }
public new void Add(string key, object value)
{ /* blah */ }
public override string ToString()
{ /* blah */ }
}
[DataContract]
[KnownType(typeof(MyDictionary))]
[KnownType(typeof(object[]))]
[KnownType(typeof(double[]))]
[KnownType(typeof(string[]))]
[KnownType(typeof(DateTime[]))]
public class ResultClass
{
public object Value{ get; set; }
/* More properties */
}
public class ParmData
{
public object Value{ get; set; }
/* More properties */
}
[DataContract]
[KnownType(typeof(MyDictionary))]
[KnownType(typeof(object[]))]
[KnownType(typeof(double[]))]
[KnownType(typeof(string[]))]
[KnownType(typeof(DateTime[]))]
public class ParameterClass
{
public List<ParmData> Data{ get; set; }
/* More properties */
}
[OperationContract]
ResultClass DoSomething(ParameterClass args);
</code></pre>
<p>Results:</p>
<ul>
<li>When I pass MyDictionary as one of the ParameterClass.Data.Value elements, I get a missing KnownType exception.</li>
<li>I can safely return MyDictionary in the ResultClass, but it is no longer my type. It is just a Dictionary, and is not castable to <code>MyDictionary</code>. Also comparer = <code>System.Collections.Generic.GenericEqualityComparer<string></code>, not the case insensitive comparer I’m looking for.</li>
</ul>
<p>The help I’m asking for is to either fix my failed attempt, or a completely different way to achieve my stated requirements. Any solution should not involve copying one dictionary to another.</p>
<p>Thanks</p>
|
[
{
"answer_id": 267691,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "Add Add object [DataContract] [DataMember] DataContractSerializer DataContractSerializer Add 1\nMyDictionary\nabc=123\ndef=ghi\n // or long-hand in C# 2.0\n ParameterClass pc = new ParameterClass {\n Data = new List<ParmData> { new ParmData {\n Value = new MyDictionary {\n {\"abc\",123},\n {\"def\",\"ghi\"}\n }}}};\n DataContractSerializer dcs = new DataContractSerializer(pc.GetType());\n string xml;\n using(StringWriter sw = new StringWriter())\n using(XmlWriter xw = XmlWriter.Create(sw)) {\n dcs.WriteObject(xw, pc);\n xw.Close();\n xml = sw.ToString();\n }\n using(StringReader sr = new StringReader(xml)) {\n ParameterClass clone = (ParameterClass)dcs.ReadObject(XmlReader.Create(sr));\n Console.WriteLine(clone.Data.Count);\n Console.WriteLine(clone.Data[0].Value.GetType().Name);\n MyDictionary d = (MyDictionary)clone.Data[0].Value;\n foreach (KeyValuePair<string, object> pair in d)\n {\n Console.WriteLine(\"{0}={1}\", pair.Key, pair.Value);\n }\n }\n DataContractSerializer <?xml version=\"1.0\" encoding=\"utf-16\"?><ParameterClass xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.datacontract.org/2004/07/\"><Data><ParmData><Value xmlns:d4p1=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" i:type=\"d4p1:ArrayOfKeyValueOfstringanyType\"><d4p1:KeyValueOfstringanyType><d4p1:Key>abc</d4p1:Key><d4p1:Value xmlns:d6p1=\"http://www.w3.org/2001/XMLSchema\" i:type=\"d6p1:int\">123</d4p1:Value></d4p1:KeyValueOfstringanyType><d4p1:KeyValueOfstringanyType><d4p1:Key>def</d4p1:Key><d4p1:Value xmlns:d6p1=\"http://www.w3.org/2001/XMLSchema\" i:type=\"d6p1:string\">ghi</d4p1:Value></d4p1:KeyValueOfstringanyType></Value></ParmData></Data></ParameterClass>\n"
},
{
"answer_id": 270580,
"author": "chilltemp",
"author_id": 28736,
"author_profile": "https://Stackoverflow.com/users/28736",
"pm_score": 2,
"selected": true,
"text": "CollectionDataContract"
},
{
"answer_id": 562591,
"author": "Shaun Bowe",
"author_id": 1514,
"author_profile": "https://Stackoverflow.com/users/1514",
"pm_score": 1,
"selected": false,
"text": "[CollectionDataContract]"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28736/"
] |
267,114
|
<p>I always try to avoid to return string literals, because I fear they aren't defined outside of the function. But I'm not sure if this is the case. Let's take, for example, this function:</p>
<pre><code>
const char *
return_a_string(void)
{
return "blah";
}
</code></pre>
<p>Is this correct code? It does work for me, but maybe it only works for my compiler (gcc). So the question is, do (string) literals have a scope or are they present/defined all the time.</p>
|
[
{
"answer_id": 267134,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 7,
"selected": true,
"text": "char * sz = \"this is a test\";\nsz[0] = 'T'; //<--- undefined results\n"
},
{
"answer_id": 267136,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 2,
"selected": false,
"text": "const"
},
{
"answer_id": 7331474,
"author": "Sumit Trehan",
"author_id": 931458,
"author_profile": "https://Stackoverflow.com/users/931458",
"pm_score": 4,
"selected": false,
"text": "char *f()\n{\nchar a[]=\"SUMIT\";\nreturn a;\n}\n char *f()\n{\nchar *a=\"SUMIT\";\nreturn a;\n}\n \"SUMIT\" {'S','U','M','I',\"T''\\0'}"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18687/"
] |
267,124
|
<p>I'm working on an ASP.Net application and working to add some Ajax to it to speed up certain areas. The first area that I am concentrating is the attendance area for the teachers to report attendance (and some other data) about the kids. This needs to be fast.</p>
<p>I've created a dual-control set up where the user clicks on the icon and via Javascript and Jquery I pop up the second control. Then I use a __doPostBack() to refresh the pop up control to load all of the relevant data.</p>
<p>Here's a little video snippet to show how it works: <a href="http://www.screencast.com/users/cyberjared/folders/Jing/media/32ef7c22-fe82-4b60-a74a-9a37ab625f1f" rel="nofollow noreferrer">http://www.screencast.com/users/cyberjared/folders/Jing/media/32ef7c22-fe82-4b60-a74a-9a37ab625f1f</a> (:21 and ignore the audio background).</p>
<p>It's slower than I would like at 2-3 seconds in Firefox and Chrome for each "popping up", but it's entirely unworkable in IE, taking easily 7-8 seconds for each time it pops up and loads. And that disregards any time that is needed to save the data after it's been changed.</p>
<p>Here's the javascript that handles the pop-up:</p>
<pre><code>function showAttendMenu(callingControl, guid) {
var myPnl = $get('" + this.MyPnl.ClientID + @"')
if(myPnl) {
var displayIDFld = $get('" + this.AttendanceFld.ClientID + @"');
var myStyle = myPnl.style;
if(myStyle.display == 'block' && (guid== '' || guid == displayIDFld.value)) {
myStyle.display = 'none';
} else {
// Get a reference to the PageRequestManager.
var prm = Sys.WebForms.PageRequestManager.getInstance();
// Unblock the form when a partial postback ends.
prm.add_endRequest(function() {
$('#" + this.MyPnl.ClientID + @"').unblock({ fadeOut: 0});
});
var domEl = Sys.UI.DomElement;
//Move it into position
var loc = domEl.getLocation(callingControl);
var width = domEl.getBounds(callingControl).width;
domEl.setLocation(myPnl, loc.x + width, loc.y - 200);
//Show it and block it until we finish loading the data
myStyle.display = 'block';
$('#" + this.MyPnl.ClientID + @"').block({ message: null, overlayCSS: { backgroundColor:'#fff', opacity: '0.7'} });
//Load the data
if(guid != '') { displayIDFld.value = guid; }
__doPostBack('" + UpdatePanel1.ClientID + @"','');
}
}}
</code></pre>
<p>First, I don't understand why the __doPostBack() introduces such a delay in IE. If I take that and the prm.add_endRequest out, it's VERY speedy as no postback is happening.</p>
<p>Second, I need a way to pop up this control and refresh the data so that it is still interactive. I'm not married to an UpdatePanel, but I haven't been able to figure out how to do it with a Web Service/static page method. As you can see this control is loaded many times on the same page so page size and download speed is an issue.</p>
<p>I'd appreciate any ideas?</p>
<p>Edit: It's the same in IE 6 or 7. I'm thinking it has to do with IE's handling of the UpdatePanel, because the same code is much faster in FF and Chrome.</p>
|
[
{
"answer_id": 267181,
"author": "Jared",
"author_id": 3442,
"author_profile": "https://Stackoverflow.com/users/3442",
"pm_score": 0,
"selected": false,
"text": "<script type=\"text/javascript\" src=\"<%=Response.ApplyAppPathModifier(\"~/js/jquery-1.2.6.js\") %>\"></script>\n<script type=\"text/javascript\" src=\"<%=Response.ApplyAppPathModifier(\"~/js/jquery.blockUI.js\") %>\"></script>\n<asp:Panel CssClass=\"PopOutBox noPrint\" ID=\"MyPnl\" style=\"display: none; z-index:1000; width:230px; position: absolute;\" runat=\"server\">\n <cmp:Image MyImageType=\"SmallCancel\" CssClass=\"fright\" runat=\"server\" ID=\"CloseImg\" AlternateText=\"Close\" />\n <asp:UpdatePanel ID=\"UpdatePanel1\" runat=\"server\" UpdateMode=\"Conditional\">\n\n <ContentTemplate>\n <asp:HiddenField ID=\"AttendanceFld\" runat=\"server\" />\n <asp:HiddenField ID=\"DatePickerFld\" runat=\"server\" />\n <table width=\"100%\">\n <tr>\n <td valign=\"top\">\n <asp:RadioButtonList EnableViewState=\"false\" ID=\"AttendRBL\" runat=\"server\" RepeatDirection=\"Vertical\">\n <asp:ListItem Selected=\"True\" Text=\"On Time\" Value=\"\" />\n <asp:ListItem Text=\"Late\" Value=\"Late\" />\n <asp:ListItem Text=\"Absent\" Value=\"Absent\" />\n <asp:ListItem Text=\"Cleaning Flunk\" Value=\"Other\" title=\"This is used for things like cubby flunks\" />\n <asp:ListItem Text=\"Major Cleaning Flunk\" Value=\"Major\" title=\"This is used for things like White Glove flunks\" />\n </asp:RadioButtonList>\n </td>\n <td valign=\"top\" style=\"text-align: center; vertical-align: middle;\">\n <asp:CheckBox EnableViewState=\"false\" ID=\"ExcusedCB\" runat=\"server\" />\n <br />\n <asp:Label ID=\"Label1\" EnableViewState=\"false\" AssociatedControlID=\"ExcusedCB\" Text=\"Excused\"\n runat=\"server\" />\n </td>\n </tr>\n\n <tr>\n <td colspan=\"2\">\n <asp:Label EnableViewState=\"false\" ID=\"Label2\" Text=\"Notes\" runat=\"server\" AssociatedControlID=\"DataTB\" />\n <cmp:HelpPopUp EnableViewState=\"false\" runat=\"server\" Text='Must include \"Out Sick\" to be counted as ill on reports and progress reports' />\n <br />\n <asp:TextBox ID=\"DataTB\" EnableViewState=\"false\" runat=\"server\" Columns=\"30\" /><br />\n <div style=\"font-size: 10px; text-align:center;\">\n <a href=\"#\" onclick=\"setAttendVal('<%=this.DataTB.ClientID%>','Out Sick');return false;\">\n (Ill)</a> <a href=\"#\" onclick=\"setAttendVal('<%=this.DataTB.ClientID%>','In Ethics');return false;\">\n (Ethics)</a> <a href=\"#\" onclick=\"setAttendVal('<%=this.DataTB.ClientID %>','Warned');return false;\">\n (Warned)</a>\n </div>\n </td>\n </tr>\n <tr>\n <td colspan=\"2\">\n <cmp:ImageButton ID=\"DeleteBtn\" OnClientClick=\"showAttendMenu(this,'');\" OnClick=\"DeleteAttendance\" ButtonType=\"SmallDelete\"\n CssClass=\"fright\" runat=\"server\" />\n <cmp:ImageButton ID=\"SaveBtn\" OnClientClick=\"showAttendMenu(this,'');\" OnClick=\"SaveAttendance\" ButtonType=\"SmallSave\" runat=\"server\" />\n </td>\n </tr>\n </table>\n </ContentTemplate>\n </asp:UpdatePanel>\n</asp:Panel>\n"
},
{
"answer_id": 281631,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": 4,
"selected": true,
"text": "// In your aspx.cs define the server-side method marked with the \n// WebMethod attribute and it must be public static.\n[WebMethod]\npublic static string HelloWorld(string name)\n{\n return \"Hello World - by \" + name;\n}\n\n// Call the method via javascript\nPageMethods.HelloWorld(\"Jimmy\", callbackMethod, failMethod);\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3442/"
] |
267,138
|
<p>I have a site where I use CustomErrors in the web.config to specify a custom error page, and that's working just fine. The custom 404 page is also specified in the IIS configuration (because if it's not, I don't get my custom 404 page).</p>
<p>But I have some logic that kicks in if a user gets a 404 that looks at their requested URL and make a navigation suggestion, if appropriate. This logic relies on the aspxerrorpath value. On my development PC, the aspxerrorpath is correctly appended to the URL, like so:
<em><a href="http://localhost:3092/FileNotFound.aspx?aspxerrorpath=/badpage.aspx" rel="noreferrer">http://localhost:3092/FileNotFound.aspx?aspxerrorpath=/badpage.aspx</a></em>, but on my test site, there's no aspxerrorpath appended to the URL, so all of my custom logic is bypassed and my suggestions don't work. I'm not sure if this is an IIS config issue or something else. The web server is Windows Server 2008 with IIS 7.</p>
<p>Any thoughts?</p>
<p>Many Thanks.</p>
|
[
{
"answer_id": 267183,
"author": "stevemegson",
"author_id": 25028,
"author_profile": "https://Stackoverflow.com/users/25028",
"pm_score": 4,
"selected": false,
"text": "http://example.com/FileNotFound.aspx?404;http://example.com/badpage.aspx"
},
{
"answer_id": 267252,
"author": "Ramesh",
"author_id": 30594,
"author_profile": "https://Stackoverflow.com/users/30594",
"pm_score": 3,
"selected": false,
"text": "<customErrors mode=\"On\">\n <error statusCode=\"404\" redirect=\"~/error404.aspx\" />\n</customErrors>\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/856/"
] |
267,151
|
<p>I have seen 3d surface plots of data before but i do not know what software i could use to make it.</p>
<p>I have 3 series of data (X, Y, Z) basically i want each of the rows on the table to be a point in 3d space, all joined as a mesh. The data is currently csv, but i can change the format, as it is data i generated myself.</p>
<p>Can anyone help</p>
|
[
{
"answer_id": 267175,
"author": "nlucaroni",
"author_id": 157,
"author_profile": "https://Stackoverflow.com/users/157",
"pm_score": 0,
"selected": false,
"text": "function plot_from_file(datafile)\n//\n// Make a simple x-y-z plot based on values read from a datafile.\n// We assume that the datafile has three columns of floating-point\n// values seperated by tabs.\n\n // set verbose = 1 to see lots of diagnostics\n verbose = 1;\n\n // open the datafile (quit if we can't)\n fid = mopen(datafile, 'r');\n if (fid == -1) \n error('cannot open datafile');\n end\n\n // loop over all lines in the file, reading them one at a time\n num_lines = 0;\n while (true)\n\n // try to read the line ...\n [num_read, val(1), val(2), val(3)] = mfscanf(fid, \"%f\\t%f\\t%f\");\n if (num_read <= 0)\n break\n end\n if (verbose > 0)\n fprintf(1, 'num_lines %3d num_read %4d \\n', num_lines, num_read);\n end\n if (num_read ~= 3) \n error('didn''t read three points');\n end\n\n // okay, that line contained valid data. Store in arrays\n num_lines = num_lines + 1;\n x_array(num_lines) = val(1);\n y_array(num_lines) = val(2);\n z_array(num_lines) = val(3);\n end\n\n // now, make the plot\n plot3d2(x_array, y_array, z_array);\n // close the datafile\n mclose(fid);\n\nendfunction\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29924/"
] |
267,160
|
<p>I recently added JQuery's date-picker control to a project. In Internet Exploder, I get the following error message:</p>
<blockquote>
<p>Internet Explorer cannot open the
Internet site</p>
<p><a href="http://localhost/" rel="nofollow noreferrer">http://localhost/</a></p>
<p>Operation aborted</p>
</blockquote>
<p>What is causing this problem?</p>
|
[
{
"answer_id": 267331,
"author": "Andrew Hedges",
"author_id": 11577,
"author_profile": "https://Stackoverflow.com/users/11577",
"pm_score": 0,
"selected": false,
"text": "defer"
},
{
"answer_id": 865331,
"author": "Travis",
"author_id": 307338,
"author_profile": "https://Stackoverflow.com/users/307338",
"pm_score": 1,
"selected": false,
"text": "</body> ...\n<script>highlightSearchTerms();</script>\n</body>\n</html>\n ...\n</body>\n<script>highlightSearchTerms();</script>\n</html>\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10420/"
] |
267,163
|
<p>I've had significant success with NSURL, NSURL[Mutable]Request, NSURLConnection with my iPhone applications. When trying to compile a stand alone Cocoa application, 10 line program to make a simple HTTP request, there are zero compiler errors or warnings. The program compiles fine, yet the HTTP Request is never made to my web server (I'm running a tcpdump and watching Apache logs in parallel). When I run very similar code in an iPhone app, essentially copy/pasted as evil as that is, all works golden. </p>
<p>I kept the code for the 'obj' declaration in the delegate to NSURLConnection out of this code snippet for the sake of simplicity. I'm also passing the following to gcc:</p>
<p>gcc -o foo foo.m -lobjc -framework cocoa</p>
<p>Thanks for any insight.</p>
<pre><code>#import <Cocoa/Cocoa.h>
int main (int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString * urlstr = @"http://tmp/test.php";
[NSApplication sharedApplication];
NSObject *obj = [[NSObject alloc] init];
NSURL *url = [NSURL URLWithString: urlstr];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
if([request isKindOfClass:[NSMutableURLRequest class]])
NSLog(@"request is of type NSMutableURLRequest");
[request setHTTPMethod:@"GET"];
[request setCachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData];
NSURLConnection *connection = [[NSURLConnection alloc]
initWithRequest:request
delegate:obj
startImmediately:YES];
if(connection)
NSLog(@"We do have a connection.");
[pool release];
return 0;
</code></pre>
<p>} </p>
|
[
{
"answer_id": 267265,
"author": "Mike Abdullah",
"author_id": 28768,
"author_profile": "https://Stackoverflow.com/users/28768",
"pm_score": 2,
"selected": false,
"text": "NSURLConnection NSRunLoop NSURLConnection [NSURLConnection sendSynchronousRequest:returningResponse:error:]"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,168
|
<p>In Visual Studio, I can select the "Treat warnings as errors" option to prevent my code from compiling if there are any warnings. Our team uses this option, but there are two warnings we would like to keep as warnings. </p>
<p>There is an option to suppress warnings, but we DO want them to show up as warnings, so that won't work.</p>
<p>It appears that the only way to get the behavior we want is to enter a list of every C# warning number into the "Specific warnings" text box, except for the two we want treated as warnings.</p>
<p>Besides the maintenance headache, the biggest disadvantage to this approach is that a few warnings do not have numbers, so they can't be referenced explicitly. For example, "Could not resolve this reference. Could not locate assembly 'Data....'"</p>
<p>Does anyone know of a better way to do this?</p>
<hr>
<p>Clarifying for those who don't see immediately why this is useful. Think about how most warnings work. They tell you something is a little off in the code you just wrote. It takes about 10 seconds to fix them, and that keeps the code base cleaner.</p>
<p>The "Obsolete" warning is very different from this. Sometimes fixing it means just consuming a new method signature. But if an entire class is obsolete, and you have usage of it scattered through hundreds of thousands of lines of code, it could take weeks or more to fix. You don't want the build to be broken for that long, but you definitely DO want to see a warning about it. This isn't just a hypothetical case--this has happened to us.</p>
<p>Literal "#warning" warnings are also unique. I often <em>want</em> to check it in, but I don't want to break the build.</p>
|
[
{
"answer_id": 468166,
"author": "SvenL",
"author_id": 57790,
"author_profile": "https://Stackoverflow.com/users/57790",
"pm_score": 7,
"selected": false,
"text": "WarningsNotAsErrors <PropertyGroup>\n ...\n ...\n <WarningsNotAsErrors>618,1030,1701,1702</WarningsNotAsErrors>\n</PropertyGroup>\n 612 618"
},
{
"answer_id": 67542429,
"author": "Drew Noakes",
"author_id": 24874,
"author_profile": "https://Stackoverflow.com/users/24874",
"pm_score": 4,
"selected": true,
"text": "<WarningsNotAsErrors>618,1030,1701,1702</WarningsNotAsErrors>\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24315/"
] |
267,179
|
<p>I'm trying to create a template class to insulate the users from a data type. I would have preferred to use an adapter class, but the function signatures needed to change requiring a template.</p>
<p>In the code sample below(not the actual project just a simplified version to illustrate the problem), while in the main routine I'm able to use the ob_traits interface. But when I attempt to create the templated StructWrapper which uses the ob_traits as a base class, I get errors and gcc doesn't recognize the IntAdapter class created. This compiles on MSVC 8.0 but fails on gcc 4.1.2 20070626 ( Red hat 4.1.2-14)</p>
<p>So two questions first, do you understand why the compile fails with the errors specified below?</p>
<p>Second, any suggestions on how to implement this concept in a more simple manner?</p>
<pre><code> #include <iostream>
template <typename T >
struct ob_traits
{
ob_traits( T& param ) { value = param; };
T value;
};
struct GeneralStructure
{
int a;
GeneralStructure(int param):a(param){}
};
struct DifferentStructure
{
GeneralStructure hidden;
DifferentStructure( int param ):hidden(param){};
}
;
/*template< typename T > struct ob_traits
{
};
*/
template<> struct ob_traits< GeneralStructure >
{
struct IntAdapter
{
IntAdapter( GeneralStructure& valueParam ):value(valueParam){}
GeneralStructure value;
int& getValue() { return value.a; };
};
};
template<> struct ob_traits< DifferentStructure >
{
struct IntAdapter
{
IntAdapter( DifferentStructure& valueParam):value( valueParam ){}
DifferentStructure value;
int& getValue( ){ return value.hidden.a; };
};
void dump()
{
DifferentStructure testLocal(44);
IntAdapter local( testLocal );
std::cout << local.getValue()<<std::endl;
}
};
template <typename T > struct StructWrapper:public ob_traits< T >
{
StructWrapper(){};
/*main.cpp:60: error: 'IntAdapter' was not declared in this scope
main.cpp:60: error: expected `;' before 'inner'
main.cpp:60: error: 'inner' was not declared in this scope
*/
void dumpOuter(const T& tempParam) { IntAdapter inner(tempParam); inner.dump(); };
/*
main.cpp: In member function 'void StructWrapper<T>::dumpOuterFailsAsWell(const T&)':
main.cpp:66: error: expected `;' before 'inner'
main.cpp:66: error: 'inner' was not declared in this scope
*/
void dumpOuterFailsAsWell(const T& tempParam) { ob_traits<T>::IntAdapter inner(tempParam); inner.dump(); };
};
int main(int argc, char* argv[])
{
GeneralStructure dummyGeneral(22);
ob_traits<struct GeneralStructure >::IntAdapter test(dummyGeneral);
DifferentStructure dummyDifferent(33);
ob_traits<struct DifferentStructure >::IntAdapter test2(dummyDifferent);
std::cout << "GeneralStructure: "<<test.getValue()<<std::endl;
std::cout << "DifferentStructure: "<<test2.getValue()<<std::endl;
ob_traits<struct DifferentStructure > test3;
test3.dump();
std::cout << "Test Templated\n";
return 0;
}
</code></pre>
|
[
{
"answer_id": 267254,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 0,
"selected": false,
"text": "StructWrapper StructWrapper"
},
{
"answer_id": 269258,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 2,
"selected": false,
"text": "dumpOuter IntAdapter dumpOuterFailsAsWell void dumpOuterWorks(const T& tempParam) \n{ \n typename ob_traits<T>::IntAdapter inner(tempParam); \n inner.dump(); \n}\n typename"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,186
|
<p>In C++ when can a virtual function use static binding? If it is being accessed through a pointer, accessed directly, or never?</p>
|
[
{
"answer_id": 267238,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 3,
"selected": false,
"text": "class Base\n{\npublic:\n virtual ~Base() {}\n virtual void DoIt() { printf(\"In Base::DoIt()\\n\"); }\n};\n\nclass Derived : public Base\n{\npublic:\n virtual void DoIt() { printf(\"In Derived::DoIt()\\n\"); }\n};\n\nBase *basePtr = new Derived;\nbasePtr->DoIt(); // Calls Derived::DoIt() through virtual function call\nbasePtr->Base::DoIt(); // Explicitly calls Base::DoIt() using normal function call\ndelete basePtr;"
},
{
"answer_id": 267260,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "class C;\n\nvoid Foo(C* a, C& b, C c) {\n a->foo(); // dynamic\n b.foo(); // dynamic\n c.foo(); // static (compile-time)\n}\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,191
|
<p>Bascially I want to know the best way to hide/show an ASP.NET control from a Javascript function. I figured I would just access the control in Javascript using:</p>
<pre><code>var theControl = document.getElementById("txtEditBox");
</code></pre>
<p>Then just set the control's Visible property to true/false. It doesn't seem to be working, I can't seem to figure out how to set "Visible" to true/false. How can I do that? Also, is that the best way to hide/show a ASP.NET control from a Javascript function?</p>
<p>Thanks,
Jeff </p>
|
[
{
"answer_id": 267197,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 6,
"selected": true,
"text": "var theControl = document.getElementById(\"txtEditBox\");\ntheControl.style.display = \"none\";\n\n// to show it again:\ntheControl.style.display = \"\";\n id .invisible { display: none; }\n display block"
},
{
"answer_id": 267207,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 3,
"selected": false,
"text": "//css:\n.invisible { display:none; }\n\n//C#\ntxtEditBox.CssClass = 'invisible';\ntxtEditBox.CssClass = ''; // visible again\n\n//javascript\ndocument.getElementById('txtEditBox').className = 'invisible'\ndocument.getElementById('txtEditBox').className = ''\n"
},
{
"answer_id": 267209,
"author": "gfrizzle",
"author_id": 23935,
"author_profile": "https://Stackoverflow.com/users/23935",
"pm_score": 2,
"selected": false,
"text": "theControl.style.display = 'none';\n"
},
{
"answer_id": 267211,
"author": "Michael Kniskern",
"author_id": 26327,
"author_profile": "https://Stackoverflow.com/users/26327",
"pm_score": 3,
"selected": false,
"text": "var theControl = document.getElementById(\"<%= txtEditBox.ClientID %>\");\ntheControl.style.display = \"none\";\n"
},
{
"answer_id": 267212,
"author": "C. Dragon 76",
"author_id": 5682,
"author_profile": "https://Stackoverflow.com/users/5682",
"pm_score": 2,
"selected": false,
"text": "theControl.style.display = \"none\";\n"
},
{
"answer_id": 267216,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "null var theControl = document.getElementById(\"txtEditBox\");\n\n theControl.style.display = 'none';\n\n theControl.style.display = null;\n $('#txtEditBox').hide();\n\n $('#txtEditBox').show();\n"
},
{
"answer_id": 267245,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 2,
"selected": false,
"text": "ASP.NET <asp:UpdatePanel ID=\"panel\" runat=\"server\">\n <ContentTemplate>\n <asp:TextBox ID=\"myTextBox\" runat=\"server\" />\n </ContentTemplate>\n <Triggers>\n <asp:AsynchronousPostbackTrigger ControlID=\"button\" EventName=\"Click\" />\n </Triggers>\n</asp:UpdatePanel>\n<asp:Button ID=\"button\" runat=\"server\" OnClick=\"toggle\" Text=\"Click!\" />\n protected void toggle(object sender, EventArgs e){\n myTextBox.Visibility = !myTextBox.Visibility;\n}\n"
},
{
"answer_id": 6307429,
"author": "live-love",
"author_id": 436341,
"author_profile": "https://Stackoverflow.com/users/436341",
"pm_score": 1,
"selected": false,
"text": "<asp:TextBox ID=\"txtBox\" runat=\"server\" style=\"display:none;\">\n"
},
{
"answer_id": 54350083,
"author": "GreatNews",
"author_id": 9290530,
"author_profile": "https://Stackoverflow.com/users/9290530",
"pm_score": 0,
"selected": false,
"text": "<div id=\"divTest\"> \n <asp:TextBox ID=\"txtTest\" runat=\"server\"></asp:TextBox>\n</div>\n\n<script type=\"text/javascript\">\n SIN JQuery\n document.getElementById('divTest').style.display = \"none\";\n\n CON JQuery\n $('#divTest').hide();\n</script>\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12172/"
] |
267,193
|
<p>I have a computer at home which I can't access from work. I'd like to be able to view results from work that my home computer produces. The best idea I've come up with is an automated script running on my home computer that emails myself the results (from a text file or stderr/out) when complete. </p>
<p>I'm decent with bash (I have a <em>linux</em> machine) and java, so an answer using either or both of those would be ideal, but if there's something easier that's fine too.</p>
<p>I typically use gmail, but also have yahoo mail. </p>
<p>My question is this: what would be the basic steps in solving this problem? I can do the nitty gritty stuff, but can't really get the big picture of how something like this would work.</p>
<p>Please help.</p>
<p>jbu</p>
|
[
{
"answer_id": 267289,
"author": "paavo256",
"author_id": 34911,
"author_profile": "https://Stackoverflow.com/users/34911",
"pm_score": 2,
"selected": false,
"text": "mail -s \"My subject here\" recipient@wherever.com <message_body.txt\n"
},
{
"answer_id": 267301,
"author": "Claudiu",
"author_id": 15055,
"author_profile": "https://Stackoverflow.com/users/15055",
"pm_score": 1,
"selected": false,
"text": "HELO relay.example.org\nMAIL FROM:<bob@example.org>\nRCPT TO:<alice@example.com>\nRCPT TO:<theboss@example.com>\nDATA\nFrom: \"Bob Example\" <bob@example.org>\nTo: Alice Example <alice@example.com>\nCc: theboss@example.com\nDate: Tue, 15 Jan 2008 16:02:43 -0500\nSubject: Test message\n\nHello Alice.\nThis is a test message with 5 headers and 4 lines in the body.\nYour friend,\nBob\n.\nQUIT\n nc mail.somewhere.com 25 < file.txt\n"
},
{
"answer_id": 341912,
"author": "jpsecher",
"author_id": 13372,
"author_profile": "https://Stackoverflow.com/users/13372",
"pm_score": 2,
"selected": false,
"text": "user@gmail.com user.noreply@gmail.com aptitude install ssmtp /etc/ssmtp/ssmtp.conf /etc/ssmtp/revaliases localuser mailx aptitude install bsd-mailx johnsmith.noreply From"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,198
|
<p>We need to handle this event in the base form, regardless of which controls currently have focus. We have a couple of global key commands that need to work regardless of control focus.</p>
<p>This works by handling the PreviewKeyDown event in the form normally. When we add a user control to the form, the event no longer fires.</p>
<p>Am I missing something trivial here? Or do we need to handle the event in the user control first?</p>
<p>Thanks for your help!</p>
<p><p>Thanks Factor. When I get more time :) I'll get it working 'properley'!</p>
|
[
{
"answer_id": 267385,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 1,
"selected": false,
"text": " foreach (Control control in this.Controls)\n {\n control.PreviewKeyDown += new PreviewKeyDownEventHandler(HandlePreviewKeyDown);\n }\n"
},
{
"answer_id": 277907,
"author": "Eric W",
"author_id": 14972,
"author_profile": "https://Stackoverflow.com/users/14972",
"pm_score": 2,
"selected": false,
"text": "Form.KeyPreview"
},
{
"answer_id": 2761380,
"author": "Byron Ross",
"author_id": 1811110,
"author_profile": "https://Stackoverflow.com/users/1811110",
"pm_score": 2,
"selected": true,
"text": "ToolStripMenuItem.Visible = false\n"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1811110/"
] |
267,200
|
<p>I have a Visual Studio Solution. Currently, it is an empty solution (=no projects) and I have added a few solution folders.</p>
<p>Solution Folders only seem to be "virtual folders", because they are not really created in the Filesystem and files inside solution folders are just sitting in the same folder as the .sln file.</p>
<p>Is there a setting that i've overlooked that tells Visual Studio to treat Solution Folders as "real" folders, that is to create them in the file system and move files into it when I move them inside the solution into one of those folders?</p>
<p><strong>Edit:</strong> Thanks. Going to make a suggestion for VS2010 then :)</p>
|
[
{
"answer_id": 55675993,
"author": "rsenna",
"author_id": 158074,
"author_profile": "https://Stackoverflow.com/users/158074",
"pm_score": 4,
"selected": false,
"text": "MSBUILD <None Include=\"**/*\" /> <?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- DockerDev/DockerDev.shproj -->\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n <ItemGroup>\n <None Include=\"**/*\" />\n </ItemGroup>\n</Project>\n DockerDev"
},
{
"answer_id": 65368228,
"author": "keyone2693",
"author_id": 3726322,
"author_profile": "https://Stackoverflow.com/users/3726322",
"pm_score": 2,
"selected": false,
"text": "Project(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"src\", \"src\", \"{9D8C3BB1-AEDB-4757-8559-995D12A4E6D0}\"\n"
},
{
"answer_id": 66004927,
"author": "Rub",
"author_id": 9050921,
"author_profile": "https://Stackoverflow.com/users/9050921",
"pm_score": 0,
"selected": false,
"text": "Show All Files Add New Folder New Filter New Folder Project include src data libs CrazyDemo Solution 'CreazyDemo' (1 of 1 project) Project Properties Configuration Properties VC++ Directories Include Directories $(ProjectDir)/Project/include;$(IncludePath) Library Directories $(ProjectDir)/Project/libs;$(LibraryPath) Source Directories $(ProjectDir)/Project/src;$(SourcePath) Scope to This Project Scope to This Project Properties main.cpp Project CrazyDemo Properties"
},
{
"answer_id": 67033529,
"author": "marsh-wiggle",
"author_id": 1574221,
"author_profile": "https://Stackoverflow.com/users/1574221",
"pm_score": 2,
"selected": false,
"text": "switch views folder view switch views"
}
] |
2008/11/05
|
[
"https://Stackoverflow.com/questions/267200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] |
267,219
|
<p>I want to display the current host and database names in a view.</p>
<p>Where can I get these names?</p>
<p>Are there some predefined environment or global variables? </p>
|
[
{
"answer_id": 267251,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 5,
"selected": true,
"text": "config = Rails::Configuration.new\nhost = config.database_configuration[RAILS_ENV][\"host\"]\ndatabase = config.database_configuration[RAILS_ENV][\"database\"]\n"
},
{
"answer_id": 5385176,
"author": "craic.com",
"author_id": 561807,
"author_profile": "https://Stackoverflow.com/users/561807",
"pm_score": 5,
"selected": false,
"text": "config = Rails::Configuration.new\nNoMethodError: undefined method `new' for Rails::Configuration:Module\n[...]\n ActiveRecord::Base.connection.current_database\n"
},
{
"answer_id": 6953222,
"author": "Ryan Long",
"author_id": 542791,
"author_profile": "https://Stackoverflow.com/users/542791",
"pm_score": 4,
"selected": false,
"text": "Rails::Application.config YourApplicationClassName::Application.config.database_configuration[::Rails.env]\n Rails YourApplicationClassName Rails.application.class.name"
},
{
"answer_id": 8333129,
"author": "joshmckin",
"author_id": 297561,
"author_profile": "https://Stackoverflow.com/users/297561",
"pm_score": 3,
"selected": false,
"text": "MyModel.connection.instance_variable_get(:@config)[:database]\n"
},
{
"answer_id": 17607657,
"author": "Fernando Almeida",
"author_id": 756704,
"author_profile": "https://Stackoverflow.com/users/756704",
"pm_score": 6,
"selected": false,
"text": "Rails.configuration.database_configuration[Rails.env]\n Rails.application.config.database_configuration[Rails.env]\n ActiveRecord::Base.connection_config\n"
},
{
"answer_id": 19932078,
"author": "mikowiec",
"author_id": 2945404,
"author_profile": "https://Stackoverflow.com/users/2945404",
"pm_score": 3,
"selected": false,
"text": "ActiveRecord::Base.connection.instance_variable_get(:@config)\n"
},
{
"answer_id": 52583216,
"author": "toomaj",
"author_id": 5638830,
"author_profile": "https://Stackoverflow.com/users/5638830",
"pm_score": 1,
"selected": false,
"text": "ActiveRecord::Base.connection.database_name"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14755/"
] |
267,221
|
<p>I've got a Perforce server set up, and installed the P4V client. I've created a new depot and a new workspace. Per the documentation, I've mapped the workspace to the depot. So far so good.</p>
<p>I now have a .SQL script that was created by an external application that I wish to check in for the first time. I copied the file into my workspace and can see the file in the client's workspace tree window. Yet when I attempt to mark the file for add, I get a "file(s) not opened on this client" error. I've tried editing a changelist to include the file, but the changelist editor does not "see" the file.</p>
<p>I've read through the documentation (PDF files), but I just do not see what I'm missing. I've worked with other RCS software in a commercial setting, but this is my first stab at trying to set up and administer and RCS system up for personal use.</p>
|
[
{
"answer_id": 268163,
"author": "Toby Allen",
"author_id": 6244,
"author_profile": "https://Stackoverflow.com/users/6244",
"pm_score": 1,
"selected": false,
"text": "Workspace root: C:\\Documents and Settings\\wtansill\\Perforce\\wtansill_localhost_1666\n\nFile dir under root: C:\\Documents and Settings\\wtansill\\Perforce\\wtansill_localhost_1666\\tunnel_files\n\nView mappings:\n\n//tunnel/... //wtansill_localhost_1666/tunnel/...\n\n//tunnel/* //wtansill_localhost_1666/tunnel/*\n //tunnel/... //wtansill_localhost_1666/tunnel/...\n C:\\Documents and Settings\\wtansill\\Perforce\\wtansill_localhost_1666\\tunnel_files\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34903/"
] |
267,222
|
<p>I would like to write an application that will copy MP3 files to a SanDisk Sansa M240. The SanDisk doesn't have a drive letter and uses MTP for file transfer.
I stumbled through the sample of connecting to the device at : <a href="http://blogs.msdn.com/dimeby8/archive/2006/09/27/774259.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/dimeby8/archive/2006/09/27/774259.aspx</a></p>
<p>but once connected, I can't figure out how to actually copy files / create folders on the device.</p>
<p>I am very surprised that there aren't any .Net wrappers for this COM library.</p>
|
[
{
"answer_id": 39818354,
"author": "Xavier Peña",
"author_id": 831138,
"author_profile": "https://Stackoverflow.com/users/831138",
"pm_score": 2,
"selected": false,
"text": "obj\\Debug bin\\Debug FriendlyName private IDictionary<string, string> GetDeviceIds()\n {\n var deviceIds = new Dictionary<string, string>();\n var devices = new PortableDeviceCollection();\n devices.Refresh();\n foreach (var device in devices)\n {\n device.Connect();\n deviceIds.Add(device.FriendlyName, device.DeviceId);\n Console.WriteLine(@\"DeviceId: {0}, FriendlyName: {1}\", device.DeviceId, device.FriendlyName);\n device.Disconnect();\n }\n return deviceIds;\n }\n var contents = device.GetContents();\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12747/"
] |
267,236
|
<p>It seems if I do something like</p>
<pre><code>$file = fopen($filepath, "w");
$CR = curl_init();
curl_setopt($CR, CURLOPT_URL, $source_path);
curl_setopt($CR, CURLOPT_POST, 1);
curl_setopt($CR, CURLOPT_FAILONERROR, true);
curl_setopt($CR, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($CR, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($CR, CURLOPT_FILE, $file);
$result = curl_exec( $CR );
$error = curl_error( $CR );
print filesize($filepath);
</code></pre>
<p>I get a different result than if I just run</p>
<pre><code>print filesize($filepath);
</code></pre>
<p>a second time. My guess is that curl is still downloading when do a filesize().</p>
|
[
{
"answer_id": 279844,
"author": "too much php",
"author_id": 28835,
"author_profile": "https://Stackoverflow.com/users/28835",
"pm_score": 3,
"selected": true,
"text": "$file = '/tmp/test12345';\nfile_put_contents($file, 'hello');\necho filesize($file), \"\\n\";\nfile_put_contents($file, 'hello world, this is a test');\necho filesize($file), \"\\n\";\nclearstatcache();\necho filesize($file), \"\\n\";\n"
},
{
"answer_id": 10802130,
"author": "Daniel",
"author_id": 1424080,
"author_profile": "https://Stackoverflow.com/users/1424080",
"pm_score": 0,
"selected": false,
"text": "print_r(curls_getinfo($CR));\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10393/"
] |
267,237
|
<p>What's the best way to unit test protected and private methods in Ruby, using the standard Ruby <code>Test::Unit</code> framework?</p>
<p>I'm sure somebody will pipe up and dogmatically assert that "you should only unit test public methods; if it needs unit testing, it shouldn't be a protected or private method", but I'm not really interested in debating that. I've got several methods that <strong>are</strong> protected or private for good and valid reasons, these private/protected methods are moderately complex, and the public methods in the class depend upon these protected/private methods functioning correctly, therefore I need a way to test the protected/private methods.</p>
<p>One more thing... I generally put all the methods for a given class in one file, and the unit tests for that class in another file. Ideally, I'd like all the magic to implement this "unit test of protected and private methods" functionality into the unit test file, not the main source file, in order to keep the main source file as simple and straightforward as possible.</p>
|
[
{
"answer_id": 267401,
"author": "James Baker",
"author_id": 9365,
"author_profile": "https://Stackoverflow.com/users/9365",
"pm_score": 7,
"selected": false,
"text": "myobject.send(:method_name, args)\n send send! send!"
},
{
"answer_id": 267408,
"author": "rampion",
"author_id": 9859,
"author_profile": "https://Stackoverflow.com/users/9859",
"pm_score": 3,
"selected": false,
"text": "instance_eval() --------------------------------------------------- Object#instance_eval\n obj.instance_eval(string [, filename [, lineno]] ) => obj\n obj.instance_eval {| | block } => obj\n------------------------------------------------------------------------\n Evaluates a string containing Ruby source code, or the given \n block, within the context of the receiver (obj). In order to set \n the context, the variable self is set to obj while the code is \n executing, giving the code access to obj's instance variables. In \n the version of instance_eval that takes a String, the optional \n second and third parameters supply a filename and starting line \n number that are used when reporting compilation errors.\n\n class Klass\n def initialize\n @secret = 99\n end\n end\n k = Klass.new\n k.instance_eval { @secret } #=> 99\n send() test_obj.a_private_method(...) #=> raises NoMethodError\n test_obj.a_protected_method(...) #=> raises NoMethodError\n class << test_obj\n public :a_private_method, :a_protected_method\n end\n test_obj.a_private_method(...) # executes\n test_obj.a_protected_method(...) # executes\n\n other_test_obj = test.obj.class.new\n other_test_obj.a_private_method(...) #=> raises NoMethodError\n other_test_obj.a_protected_method(...) #=> raises NoMethodError\n"
},
{
"answer_id": 268953,
"author": "Scott",
"author_id": 7399,
"author_profile": "https://Stackoverflow.com/users/7399",
"pm_score": 3,
"selected": false,
"text": "class foo\n def public_method\n private_method\n end\n\nprivate unless 'test' == Rails.env\n\n def private_method\n 'private'\n end\nend\n"
},
{
"answer_id": 268971,
"author": "Mike",
"author_id": 19215,
"author_profile": "https://Stackoverflow.com/users/19215",
"pm_score": 2,
"selected": false,
"text": "# A derived class useful for testing.\nclass MockISIQuery < PublicationSearch::ISIQuery\n attr_accessor :result\n public :build_year_range\nend\n"
},
{
"answer_id": 269047,
"author": "tragomaskhalos",
"author_id": 31140,
"author_profile": "https://Stackoverflow.com/users/31140",
"pm_score": 2,
"selected": false,
"text": "class Foo\n private\n def bar; puts \"Oi! how did you reach me??\"; end\nend\n# and then\nclass Foo\n def ah_hah; bar; end\nend\n# then\nFoo.new.ah_hah\n"
},
{
"answer_id": 269452,
"author": "Will Sargent",
"author_id": 5266,
"author_profile": "https://Stackoverflow.com/users/5266",
"pm_score": 6,
"selected": false,
"text": "before(:each) do\n MyClass.send(:public, *MyClass.protected_instance_methods) \nend\n"
},
{
"answer_id": 269771,
"author": "Aaron Hinni",
"author_id": 12086,
"author_profile": "https://Stackoverflow.com/users/12086",
"pm_score": 5,
"selected": false,
"text": "public class MyClass\n\n private\n\n def foo\n true\n end\nend\n class MyClass\n public :foo\n\nend\n public public :foo, :bar\n"
},
{
"answer_id": 316760,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "class Class\n def publicize_methods\n saved_private_instance_methods = self.private_instance_methods\n self.class_eval { public *saved_private_instance_methods }\n begin\n yield\n ensure\n self.class_eval { private *saved_private_instance_methods }\n end\n end\nend\n\nMyClass.publicize_methods do\n assert_equal 10, MyClass.new.secret_private_method\nend\n"
},
{
"answer_id": 2011241,
"author": "Franz Hinkel",
"author_id": 244496,
"author_profile": "https://Stackoverflow.com/users/244496",
"pm_score": 1,
"selected": false,
"text": "def obj.my_private_method_publicly (*args)\n my_private_method(*args)\nend\n my_private_method_publicly my_private_method obj.send send! send! obj.send"
},
{
"answer_id": 13551935,
"author": "Sean Tan",
"author_id": 191040,
"author_profile": "https://Stackoverflow.com/users/191040",
"pm_score": 3,
"selected": false,
"text": "RSpec.configure do |config|\n config.before(:each) do\n described_class.send(:public, *described_class.protected_instance_methods)\n described_class.send(:public, *described_class.private_instance_methods)\n end\nend\n"
},
{
"answer_id": 29390223,
"author": "Knut Stenmark",
"author_id": 4269216,
"author_profile": "https://Stackoverflow.com/users/4269216",
"pm_score": 1,
"selected": false,
"text": "disrespect_privacy @object do |p|\n assert p.private_method\nend\n class ActiveSupport::TestCase\n def disrespect_privacy(object_or_class, &block) # access private methods in a block\n raise ArgumentError, 'Block must be specified' unless block_given?\n yield Disrespect.new(object_or_class)\n end\n\n class Disrespect\n def initialize(object_or_class)\n @object = object_or_class\n end\n def method_missing(method, *args)\n @object.send(method, *args)\n end\n end\nend\n"
},
{
"answer_id": 30244377,
"author": "rahul patil",
"author_id": 1298176,
"author_profile": "https://Stackoverflow.com/users/1298176",
"pm_score": 2,
"selected": false,
"text": "MyClass.send(:public, :method_name)\n assert_equal expected, MyClass.instance.method_name(params)\n"
},
{
"answer_id": 35783607,
"author": "qix",
"author_id": 954643,
"author_profile": "https://Stackoverflow.com/users/954643",
"pm_score": 3,
"selected": false,
"text": "describe private_instance_methods describe \"protected custom `validates` methods\" do\n # Test these methods directly to avoid needing FactoryGirl.create\n # to trigger before_create, etc.\n before(:all) do\n @protected_methods = MyClass.protected_instance_methods\n MyClass.send(:public, *@protected_methods)\n end\n after(:all) do\n MyClass.send(:protected, *@protected_methods)\n @protected_methods = nil\n end\n\n # ...do some tests...\n end\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13157/"
] |
267,239
|
<p>In C# how do you make the columns in a DataGrid AutoFit Column Width like you can in Excel? Currently my five columns are fixed width but the column headers can change so I would like the columns to autofit to the width of the column.</p>
<p>Thanks</p>
|
[
{
"answer_id": 19436840,
"author": "JVD2C",
"author_id": 1678769,
"author_profile": "https://Stackoverflow.com/users/1678769",
"pm_score": 1,
"selected": false,
"text": " public static DataGrid AddDataGrid(DataGrid DG, object Me, System.Data.DataTable DS)\n {\n\n\n try {\n DG.DataSource = DS;\n Me.Controls.Add(DG);\n DataGridTableStyle TblS = new DataGridTableStyle { MappingName = DS.TableName };\n DG.TableStyles.Clear();\n DG.TableStyles.Add(TblS);\n\n\n for (ColIndex = 0; ColIndex <= DS.Columns.Count - 1; ColIndex++) {\n int maxlength = 0;\n Graphics g = DG.CreateGraphics();\n\n // Take width of one blank space and add to the new width of the Column.\n int offset = Convert.ToInt32(Math.Ceiling(g.MeasureString(\" \", DG.Font).Width));\n\n int i = 0;\n int intaux = 0;\n string straux = null;\n int tot = DS.Rows.Count;\n\n for (i = 0; i <= (tot - 1); i++) {\n straux = DS.Rows[i][ColIndex].ToString();\n // Get the width of Current Field String according to the Font.\n intaux = Convert.ToInt32(Math.Ceiling(g.MeasureString(straux, DG.Font).Width));\n if ((intaux > maxlength)) {\n maxlength = intaux;\n }\n }\n\n // Assign New Width to DataGrid column.\n DG.TableStyles(DS.TableName).GridColumnStyles(ColIndex).Width = maxlength + offset;\n\n }\n\n\n } catch (Exception ex) {\n Debug.WriteLine(ex.Message);\n } finally {\n DG.Show();\n }\n\n return DG;\n }\n private void AddDataGrid(DataSet Ds)\n {\n AddDataGrid(new DataGrid { Dock = DockStyle.Fill }, this, Ds.Tables[0]);\n\n }\n"
},
{
"answer_id": 19437231,
"author": "JVD2C",
"author_id": 1678769,
"author_profile": "https://Stackoverflow.com/users/1678769",
"pm_score": 0,
"selected": false,
"text": "Shared Function AddDataGrid(ByVal DG As DataGrid, ByVal This As Object, ByVal DS As System.Data.DataTable) As DataGrid\n\n Try\n\n DG.DataSource = DS\n This.Controls.Add(DG)\n Dim TblS As New DataGridTableStyle() With {.MappingName = DS.TableName}\n DG.TableStyles.Clear()\n DG.TableStyles.Add(TblS)\n\n For ColIndex = 0 To DS.Columns.Count - 1\n\n Dim maxlength As Integer = 0\n Dim g As Graphics = DG.CreateGraphics()\n\n ' Take width of one blank space and add to the new width of the Column.\n Dim offset As Integer = Convert.ToInt32(Math.Ceiling(g.MeasureString(\" \", DG.Font).Width))\n\n Dim i As Integer = 0\n Dim intaux As Integer\n Dim straux As String\n Dim tot As Integer = DS.Rows.Count\n\n For i = 0 To (tot - 1)\n straux = DS.Rows(i)(ColIndex).ToString()\n ' Get the width of Current Field String according to the Font.\n intaux = Convert.ToInt32(Math.Ceiling(g.MeasureString(straux, DG.Font).Width))\n If (intaux > maxlength) Then\n maxlength = intaux\n End If\n Next\n\n ' Assign New Width to DataGrid column.\n DG.TableStyles(DS.TableName).GridColumnStyles(ColIndex).Width = maxlength + offset\n\n Next\n\n\n Catch ex As Exception\n Debug.WriteLine(ex.Message)\n Finally\n DG.Show()\n End Try\n\n Return DG\n End Function\n Private Sub AddDataGrid(ByVal Ds As DataSet)\n\n AddDataGrid(New DataGrid With {.Dock = DockStyle.Fill}, Me, Ds.Tables(0))\n\nEnd Sub\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,248
|
<p>I have some code that looks like:</p>
<pre><code>template<unsigned int A, unsigned int B>
int foo() {
int v = 1;
const int x = A - B;
if (x > 0) {
v = v << x;
}
bar(v);
}
</code></pre>
<p>gcc will complain about x being negative for certain instantiations of A, B; however, I do perform a check to make sure it is non-negative. What's the best way around this? I know I can cast <code>x</code> to be <code>unsigned int</code> but that will cause warnings about <code>x</code> being larger than the width of <code>v</code> (since it is casting a negative number to be positive). I know there is a work-around that involves creating a new templatized <code>shift</code> function, but I'd like to avoid that if possible.</p>
|
[
{
"answer_id": 267255,
"author": "Claudiu",
"author_id": 15055,
"author_profile": "https://Stackoverflow.com/users/15055",
"pm_score": 0,
"selected": false,
"text": "const short unsigned int x = A - B;\n"
},
{
"answer_id": 267257,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 1,
"selected": false,
"text": "const unsigned char x = static_cast<unsigned char>(A - B);\n const unsigned int x = static_cast<unsigned int>(A - B) & 0x1f; // limit A-B to have a range of (0 - 31)\n template<unsigned int A, unsigned int B>\nint foo() {\n int v = 1;\n const int x = A - B;\n if (x > 0) {\n v = v << (static_cast<unsigned int>(x) & 0x1f);\n }\n bar(v);\n}\n #include <iostream>\n\ntemplate<unsigned int A, unsigned int B>\nint foo() {\n int v = 1;\n const int x = A - B;\n if (x > 0) {\n v = v << (static_cast<unsigned int>(x) & 0x1f);\n }\n return v;\n}\n\nint main() {\n std::cout << foo<1, 3>() << std::endl;\n std::cout << foo<3, 1>() << std::endl;\n std::cout << foo<300, 1>() << std::endl;\n std::cout << foo<25, 31>() << std::endl;\n}\n"
},
{
"answer_id": 267415,
"author": "jwfearn",
"author_id": 10559,
"author_profile": "https://Stackoverflow.com/users/10559",
"pm_score": 3,
"selected": true,
"text": "if #include <iostream>\nusing namespace std;\n\ntemplate< unsigned int A, unsigned int B >\nstruct my\n{\n template< bool P >\n static void shift_if( int & );\n\n template<>\n static void shift_if< false >( int & ) {}\n\n template<>\n static void shift_if< true >( int & v ) { v <<= A - B; }\n\n static void op( int & v ) { shift_if< (A > B) >( v ); }\n};\n\ntemplate< unsigned int A, unsigned int B >\nint foo()\n{\n int v = 1;\n my< A, B >::op( v );\n return v;\n}\n\nint main() {\n cout << foo< 1, 3 >() << endl;\n cout << foo< 3, 1 >() << endl;\n cout << foo< 300, 1 >() << endl;\n cout << foo< 25, 31 >() << endl;\n return 0;\n}\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,250
|
<p>I am using <code>getch()</code> and my app crashes instantly. Including when doing:</p>
<pre><code>int main()
{
getch();
}
</code></pre>
<p>I can't find the link but supposedly the problem is that it needs to turn off buffering or something strange along those lines, and I still want <code>cout</code> to work along with cross platform code.</p>
<p>I was told to use <code>std::cin.get()</code>, but I'd like the app to quit when a key is pressed, not when the user typed in a letter or number then press enter to quit.</p>
<p>Is there any function for this? The code must work under Mac (my os) and Windows.</p>
<hr>
<p>Linking/compiling is not an <a href="https://stackoverflow.com/questions/267250/equivalent-to-getch-mac-linux-crash#comment14636199_267281">issue</a>; I include <code><curses.h></code> and link with <code>-lcurses</code> in XCode, while Windows uses <code><conio.h></code>.</p>
|
[
{
"answer_id": 267281,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 2,
"selected": false,
"text": "#include <stdio.h>\n #include <curses.h>\n getch()"
},
{
"answer_id": 267371,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 5,
"selected": true,
"text": "<curses.h> getch() <curses.h> #define getch() wgetch(stdscr)\n getch() stdscr initscr() atexit() read(0, &c, 1) <curses.h>"
},
{
"answer_id": 17354184,
"author": "Jose Munoz",
"author_id": 2529905,
"author_profile": "https://Stackoverflow.com/users/2529905",
"pm_score": -1,
"selected": false,
"text": "getch system system(\"pause\"); system(\"read -n1 -p ' ' key\"); system <stdlib.h>"
},
{
"answer_id": 44687705,
"author": "Benjamin",
"author_id": 8196881,
"author_profile": "https://Stackoverflow.com/users/8196881",
"pm_score": 1,
"selected": false,
"text": "#include <iostream>\n\nusing namespace std;\n\nint main()\n{\n char input = cin.get();\n\n cout << \"You Pressed: \" << input;\n}\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,256
|
<p>After considering the answers to my previous question (<a href="https://stackoverflow.com/questions/252459/one-svn-repository-or-many">One SVN Repository or many?</a>), I've decided to take the 4 or so repositories I have and consolidate them into one. This of course leads to the question, <strong>what's the best way to do this?</strong></p>
<p>Is there a way to combine two or more repositories maintaining the version history for both?</p>
<p>Edit: <em>I should also point out that I'm using Assembla.com, which does not provide access to the svnadmin command, AFAIK</em></p>
<p>Another edit: <em>Does this even matter? If svnadmin works on URLs, then it's no problem then.</em></p>
|
[
{
"answer_id": 267307,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 7,
"selected": true,
"text": "svnadmin dump > project<n>.dmp\n svn mkdir \"<repo url>/project<n>\"\nsvnadmin load --parent-dir \"project<n>\" <filesystem path to repos>\n svnadmin dump svndumpfilter svnadmin load svnadmin dump"
},
{
"answer_id": 8529409,
"author": "Scott Coldwell",
"author_id": 483403,
"author_profile": "https://Stackoverflow.com/users/483403",
"pm_score": 4,
"selected": false,
"text": "svnadmin dump svnrdump"
},
{
"answer_id": 11254635,
"author": "sthysel",
"author_id": 203449,
"author_profile": "https://Stackoverflow.com/users/203449",
"pm_score": 1,
"selected": false,
"text": "#!/bin/bash\n\nNEWREPO=$(pwd)/newrepo\nNEWREPOCO=\"${NEWREPO}_co\"\nDUMPS=repodumps\nREV=\"0:HEAD\"\nREPOROOT=/data/svn/2.2.1/repositories/\nTOOLDIR=/opt/svn/2.2.1/bin/\nPATH=${PATH}:${TOOLDIR}\n\n# Old Repository mapping \ndeclare -A REPOS=( \n [BlaEntityBeans]='(\n [newname]=\"EntityBeans\"\n )'\n [OldServletRepoServlet]='(\n [newname]=\"SpreadsheetImportServlet\"\n )'\n [ExperimentalMappingXML]='(\n [newname]=\"SpreadsheetMappingXML\"\n )'\n [NewImportProcess]='(\n [newname]=\"SpreadsheetImportProcess\"\n )' \n)\n\ndump() {\n rm -fr ${DUMPS}\n mkdir ${DUMPS}\n for repo in \"${!REPOS[@]}\"\n do\n local dumpfile=${DUMPS}/${repo}.dmp\n echo \"Dumpimg Repo ${repo} to ${dumpfile}\"\n svnadmin dump -r ${REV} ${REPOROOT}/${repo} > ${dumpfile}\n done\n}\n\nloadRepos() {\n # new big repo\n rm -fr ${NEWREPO}\n svnadmin create ${NEWREPO}\n svn mkdir file:///${NEWREPO}/trunk -m \"\"\n svn mkdir file:///${NEWREPO}/branches -m \"\"\n svn mkdir file:///${NEWREPO}/tags -m \"\"\n\n # add the old projects as modules\n for currentname in \"${!REPOS[@]}\"\n do \n declare -A repo=${REPOS[$currentname]}\n local newname=${repo[newname]}\n echo \"Loading repo ${currentname} soon to be ${newname}\"\n dumpfile=${DUMPS}/${currentname}.dmp\n\n # import the current repo into a trmporary root position\n svn mkdir file:///${NEWREPO}/${currentname} -m \"Made module ${currentname}\"\n svnadmin load --parent-dir ${currentname} ${NEWREPO} < ${dumpfile}\n\n # now move stuff arround\n # first rename to new repo\n svn move file:///${NEWREPO}/${currentname} file:///${NEWREPO}/${newname} -m \"Moved ${currentname} to ${newname}\"\n # now move trunk, branches and tags\n for vc in {trunk,branches,tags}\n do\n echo \"Moving the current content of $vc into ${NEWREPO}/${vc}/${newname}\"\n svn move file:///${NEWREPO}/${newname}/${vc} file:///${NEWREPO}/${vc}/${newname} -m \"Done by $0\"\n done\n svn rm file:///${NEWREPO}/${newname} -m \"Removed old ${newname}\"\n done\n}\n\ndump\nloadRepos\n"
},
{
"answer_id": 14263244,
"author": "Hatim",
"author_id": 1860511,
"author_profile": "https://Stackoverflow.com/users/1860511",
"pm_score": 3,
"selected": false,
"text": " projectA\n branches \n tags\n trunk\n projectB\n branches\n tags\n trunk\n $ svn mkdir -m \"Initial project root\" \\\nfile:///var/svn/repository_root/Project_A\\\nfile:///var/svn/repository_root/Project_B\\\nfile:///var/svn/repository_root/Project_C\\\n\nRevision 1 committed.\n --parent-dir DIRECTORY $ svnadmin load /var/svn/repository_root --parent-dir Project_A < file-dump-PRJA.dump\n…\n$ svnadmin load /var/svn/repository_root --parent-dir Project_B < file-dump-PRJB.dump\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
267,259
|
<p>So, I've been doing Java for a number of years now, but now I'm starting a C++ project. I'm trying to determine best practices for setting up said project.</p>
<p>Within the project, how do you generally structure their code? Do you do it Java style with namespace folders and break up your source that way? Do you keep your public headers in an include directory for easy referencing?</p>
<p>I've seen both and other ways mentioned, but what's a good method for a large project?</p>
<p>Also, how do you deal with resources/folders in your application structure? It's all well and good for the final project to install with a <code>log</code> folder for storing logs, maybe a <code>lib</code> folder for library files, maybe a <code>data</code> folder for data, but how do you manage those bits within the project? Is there a way to define that so when you build the solution it constructs the structure for you? Or, do you simply have to go into your built configuration folders (Debug, Release, etc.), and construct the file structure manually, thus ensuring paths your EXE file is expecting to find are properly positioned?</p>
|
[
{
"answer_id": 267307,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 7,
"selected": true,
"text": "svnadmin dump > project<n>.dmp\n svn mkdir \"<repo url>/project<n>\"\nsvnadmin load --parent-dir \"project<n>\" <filesystem path to repos>\n svnadmin dump svndumpfilter svnadmin load svnadmin dump"
},
{
"answer_id": 8529409,
"author": "Scott Coldwell",
"author_id": 483403,
"author_profile": "https://Stackoverflow.com/users/483403",
"pm_score": 4,
"selected": false,
"text": "svnadmin dump svnrdump"
},
{
"answer_id": 11254635,
"author": "sthysel",
"author_id": 203449,
"author_profile": "https://Stackoverflow.com/users/203449",
"pm_score": 1,
"selected": false,
"text": "#!/bin/bash\n\nNEWREPO=$(pwd)/newrepo\nNEWREPOCO=\"${NEWREPO}_co\"\nDUMPS=repodumps\nREV=\"0:HEAD\"\nREPOROOT=/data/svn/2.2.1/repositories/\nTOOLDIR=/opt/svn/2.2.1/bin/\nPATH=${PATH}:${TOOLDIR}\n\n# Old Repository mapping \ndeclare -A REPOS=( \n [BlaEntityBeans]='(\n [newname]=\"EntityBeans\"\n )'\n [OldServletRepoServlet]='(\n [newname]=\"SpreadsheetImportServlet\"\n )'\n [ExperimentalMappingXML]='(\n [newname]=\"SpreadsheetMappingXML\"\n )'\n [NewImportProcess]='(\n [newname]=\"SpreadsheetImportProcess\"\n )' \n)\n\ndump() {\n rm -fr ${DUMPS}\n mkdir ${DUMPS}\n for repo in \"${!REPOS[@]}\"\n do\n local dumpfile=${DUMPS}/${repo}.dmp\n echo \"Dumpimg Repo ${repo} to ${dumpfile}\"\n svnadmin dump -r ${REV} ${REPOROOT}/${repo} > ${dumpfile}\n done\n}\n\nloadRepos() {\n # new big repo\n rm -fr ${NEWREPO}\n svnadmin create ${NEWREPO}\n svn mkdir file:///${NEWREPO}/trunk -m \"\"\n svn mkdir file:///${NEWREPO}/branches -m \"\"\n svn mkdir file:///${NEWREPO}/tags -m \"\"\n\n # add the old projects as modules\n for currentname in \"${!REPOS[@]}\"\n do \n declare -A repo=${REPOS[$currentname]}\n local newname=${repo[newname]}\n echo \"Loading repo ${currentname} soon to be ${newname}\"\n dumpfile=${DUMPS}/${currentname}.dmp\n\n # import the current repo into a trmporary root position\n svn mkdir file:///${NEWREPO}/${currentname} -m \"Made module ${currentname}\"\n svnadmin load --parent-dir ${currentname} ${NEWREPO} < ${dumpfile}\n\n # now move stuff arround\n # first rename to new repo\n svn move file:///${NEWREPO}/${currentname} file:///${NEWREPO}/${newname} -m \"Moved ${currentname} to ${newname}\"\n # now move trunk, branches and tags\n for vc in {trunk,branches,tags}\n do\n echo \"Moving the current content of $vc into ${NEWREPO}/${vc}/${newname}\"\n svn move file:///${NEWREPO}/${newname}/${vc} file:///${NEWREPO}/${vc}/${newname} -m \"Done by $0\"\n done\n svn rm file:///${NEWREPO}/${newname} -m \"Removed old ${newname}\"\n done\n}\n\ndump\nloadRepos\n"
},
{
"answer_id": 14263244,
"author": "Hatim",
"author_id": 1860511,
"author_profile": "https://Stackoverflow.com/users/1860511",
"pm_score": 3,
"selected": false,
"text": " projectA\n branches \n tags\n trunk\n projectB\n branches\n tags\n trunk\n $ svn mkdir -m \"Initial project root\" \\\nfile:///var/svn/repository_root/Project_A\\\nfile:///var/svn/repository_root/Project_B\\\nfile:///var/svn/repository_root/Project_C\\\n\nRevision 1 committed.\n --parent-dir DIRECTORY $ svnadmin load /var/svn/repository_root --parent-dir Project_A < file-dump-PRJA.dump\n…\n$ svnadmin load /var/svn/repository_root --parent-dir Project_B < file-dump-PRJB.dump\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9450/"
] |
267,275
|
<p>Despite an earlier question (<a href="https://stackoverflow.com/questions/223894/opengl-rotation-using-gldrawpixels">asked here</a>), our project is constrained to using glDrawPixels, so we have to do some hackery.</p>
<p>One of the feature requirements is to be able to have a magnified view show up on a clicked region of an image; so, looking at an image, I want to click the mouse, and have a 200% image window show up where the mouse is. As I drag my cursor, the window should follow the cursor.</p>
<p>The context is set up like:</p>
<p>The Big Red Book has code that looks like this:</p>
<pre><code> Gl.glShadeModel(Gl.GL_FLAT);
Gl.glClearColor(0.1f, 0.1f, 0.1f, 0.0f);
Gl.glPixelStorei(Gl.GL_UNPACK_ALIGNMENT, 2);
Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE);
Gl.glDisable(Gl.GL_SCISSOR_TEST);
Gl.glDisable(Gl.GL_ALPHA_TEST);
Gl.glDisable(Gl.GL_STENCIL_TEST);
Gl.glDisable(Gl.GL_DEPTH_TEST);
Gl.glDisable(Gl.GL_BLEND);
Gl.glDisable(Gl.GL_DITHER);
Gl.glDisable(Gl.GL_LOGIC_OP);
Gl.glDisable(Gl.GL_LIGHTING);
Gl.glDisable(Gl.GL_FOG);
Gl.glDisable(Gl.GL_TEXTURE_1D);
Gl.glDisable(Gl.GL_TEXTURE_2D);
Gl.glPixelTransferi(Gl.GL_MAP_COLOR, Gl.GL_TRUE);
Gl.glPixelTransferf(Gl.GL_RED_SCALE, 1.0f);
Gl.glPixelTransferi(Gl.GL_RED_BIAS, 0);
Gl.glPixelTransferf(Gl.GL_GREEN_SCALE, 1.0f);
Gl.glPixelTransferi(Gl.GL_GREEN_BIAS, 0);
Gl.glPixelTransferf(Gl.GL_BLUE_SCALE, 1.0f);
Gl.glPixelTransferi(Gl.GL_BLUE_BIAS, 0);
Gl.glPixelTransferi(Gl.GL_ALPHA_SCALE, 1);
Gl.glPixelTransferi(Gl.GL_ALPHA_BIAS, 0);
</code></pre>
<p>And then the call to make the smaller-but-zoomed image looks like</p>
<pre><code> int width = (int)((this.Width * 0.2)/2.0);
Gl.glReadBuffer(Gl.GL_FRONT_AND_BACK);
Gl.glRasterPos2i(0, 0);
Gl.glBitmap(0, 0, 0, 0, mStartX - (width*2), mStartY, null);
Gl.glPixelZoom(2.0f, 2.0f);
Gl.glCopyPixels(mStartX - width, mStartY, width, width, Gl.GL_COLOR);
</code></pre>
<p>where mStartY and mStartX are the points where the click happened.</p>
<p>Problem is, the window that shows up is really mangling the lookup tables, and really clamping the image down to essentially a black-and-white binary image (ie, no shades of grey). </p>
<p>The data is a black-and-white unsigned short array, and is set with this code:</p>
<pre><code> float step = (65535.0f / (float)(max - min));
mColorTable = new ushort[65536];
int i;
for (i = 0; i < 65536; i++)
{
if (i < min)
mColorTable[i] = 0;
else if (i > max)
mColorTable[i] = 65535;
else
mColorTable[i] = (ushort)((float)(i - min) * step);
}
.... //some irrelevant code
Gl.glPixelMapusv(Gl.GL_PIXEL_MAP_R_TO_R, 65536, mColorTable);
Gl.glPixelMapusv(Gl.GL_PIXEL_MAP_G_TO_G, 65536, mColorTable);
Gl.glPixelMapusv(Gl.GL_PIXEL_MAP_B_TO_B, 65536, mColorTable);
</code></pre>
<p>Now, according to <a href="http://www.ugrad.cs.ubc.ca/~cs414/opengl/glCopyPixels.html" rel="nofollow noreferrer">this documentation</a>, I should use GL_PIXEL_MAP_I_TO_I and set INDEX_SCALE and INDEX_BIAS to zero, but doing that does not change the result, that the image is severely clamped. And by 'severely clamped' I mean it's either black or white, with very few shades of grey, but the original non-magnified image looks like what's expected.</p>
<p>So, how do I avoid the clamping of the magnified view? Should I make a second control that follows the cursor and gets filled in with data from the first control? That approach seems like it would take the array copies outside of the graphics card and into C#, which would almost by definition be slower, and so make the control nonresponsive. </p>
<p>Oh, I'm using C# and the Tao framework, if that matters.</p>
|
[
{
"answer_id": 273878,
"author": "thing2k",
"author_id": 3180,
"author_profile": "https://Stackoverflow.com/users/3180",
"pm_score": 0,
"selected": false,
"text": "// main.cpp\n// glut Text\n\n#ifdef __WIN32__\n #define WIN32_LEAN_AND_MEAN\n #include <windows.h>\n#endif\n#include <GL/glut.h>\n#include <cstdio>\n\nint WIDTH = 800;\nint HEIGHT = 600;\nint MouseButton, MouseY = 0, MouseX = 0;\nconst int size = 80;\nchar *image, rect[size*size*3];\nint imagewidth, imageheight;\n\nbool Init()\n{\n int offset;\n FILE* file = fopen(\"image.bmp\", \"rb\");\n if (file == NULL)\n return false;\n fseek(file, 10, SEEK_SET);\n fread(&offset, sizeof(int), 1, file);\n fseek(file, 18, SEEK_SET);\n fread(&imagewidth, sizeof(int), 1, file);\n fread(&imageheight, sizeof(int), 1, file);\n fseek(file, offset, SEEK_SET);\n image = new char[imagewidth*imageheight*3];\n if (image == NULL)\n return false;\n fread(image, 1, imagewidth*imageheight*3, file);\n fclose(file);\n return true;\n}\n\nvoid Reshape(int width, int height)\n{\n WIDTH = width;\n HEIGHT = height;\n glViewport(0 , 0, width, height);\n glMatrixMode(GL_PROJECTION);\n glLoadIdentity();\n gluOrtho2D(0, width, 0, height);\n}\n\nvoid Display()\n{\n int size2 = size/2;\n\n glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n glMatrixMode(GL_MODELVIEW);\n glLoadIdentity();\n glRasterPos2i(0,0);\n glPixelZoom(1.f, 1.f);\n glDrawPixels(imagewidth, imageheight, 0x80E0/*GL_RGB*/, GL_UNSIGNED_BYTE, image);\n glReadPixels(MouseX-size2, MouseY-size2, size, size, GL_RGB, GL_UNSIGNED_BYTE, rect);\n glPixelZoom(2.f, 2.f);\n glRasterPos2i(MouseX-size, MouseY-size);\n glDrawPixels(size, size, GL_RGB, GL_UNSIGNED_BYTE, rect);\n glFlush();\n glutSwapBuffers();\n}\n\nvoid Mouse(int button, int state, int x, int y)\n{\n if (state == GLUT_DOWN)\n MouseButton &= (1<<button);\n else\n MouseButton &= ~(1<<button);\n}\n\nvoid MouseMove(int x, int y)\n{\n MouseX = x;\n MouseY = HEIGHT - y;\n}\n\nint main(int argc, char* argv[])\n{\n glutInit(&argc, argv);\n if (Init() == false)\n return 1;\n glutInitWindowSize(WIDTH, HEIGHT);\n glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);\n glutCreateWindow(\"glut_Text\");\n glClearColor(0.25, 0.25, 0.25, 1.0);\n glutReshapeFunc(Reshape);\n glutDisplayFunc(Display);\n glutIdleFunc(Display);\n glutMouseFunc(Mouse);\n glutMotionFunc(MouseMove);\n glutPassiveMotionFunc(MouseMove);\n\n glutMainLoop();\n return 0;\n}\n"
},
{
"answer_id": 290468,
"author": "mmr",
"author_id": 21981,
"author_profile": "https://Stackoverflow.com/users/21981",
"pm_score": 3,
"selected": true,
"text": "Gl.glPixelTransferi(Gl.GL_MAP_COLOR, Gl.GL_FALSE);\n Gl.glPixelTransferi(Gl.GL_MAP_COLOR, Gl.GL_TRUE);\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21981/"
] |
267,287
|
<p>Attempting to print out a list of values from 2 different variables that are aligned correctly.</p>
<pre><code>foreach finalList ($correctList $wrongList)
printf "%20s%s\n" $finalList
end
</code></pre>
<p>This prints them out an they are aligned, but it's one after another. How would I have it go through each item in each list and THEN go to a new line? </p>
<p>I want them to eventually appear like this:</p>
<pre><code>Correct Incorrect
Good1 Bad1
Good2 Bad2
Good3 Bad3
</code></pre>
<p>Good comes from correctList
Bad comes from wrongList</p>
<p>Getting rid of \n makes it Like this:</p>
<pre><code>Good1 Bad1 Good2 Bad2
</code></pre>
<p>I just want 2 columns.</p>
|
[
{
"answer_id": 267340,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 4,
"selected": true,
"text": "# Get the max index of the smallest list\nset maxIndex = $#correctList\nif ( $#wrongList < $#correctList ) then\n set maxIndex = $#wrongList\nendif\n\nset index = 1\nwhile ($index <= $maxIndex)\n printf \"%-20s %s\\n\" \"$correctList[$index]\" \"$wrongList[$index]\"\n @ index++\nend\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28392/"
] |
267,303
|
<p>I'm am building my asp.net web application using MVC (Preview 5),
and am also using the Master pages concept. </p>
<p>My PageA and PageB are both content pages. I'm doing a form submit
in a method via JavaScript from PageA to PageB.
PageB has its PreviousPageType attribute set to PageA, but when I access the
PreviousPage property in PageB, it returns null.</p>
<p>Am I missing out on something here?</p>
|
[
{
"answer_id": 267340,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 4,
"selected": true,
"text": "# Get the max index of the smallest list\nset maxIndex = $#correctList\nif ( $#wrongList < $#correctList ) then\n set maxIndex = $#wrongList\nendif\n\nset index = 1\nwhile ($index <= $maxIndex)\n printf \"%-20s %s\\n\" \"$correctList[$index]\" \"$wrongList[$index]\"\n @ index++\nend\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31622/"
] |
267,312
|
<p>What is the difference between a Hash Map and dictionary ADT. And when to prefer one over another. For my programming assignment my instructor has asked to use one of them but I don't see any difference in between both. The program is supposed to work with a huge no. of strings. Any suggestions?</p>
|
[
{
"answer_id": 297123,
"author": "Phil",
"author_id": 38343,
"author_profile": "https://Stackoverflow.com/users/38343",
"pm_score": 7,
"selected": true,
"text": "HashMap Dictionary Dictionary Dictionary"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33203/"
] |
267,351
|
<p>The Dragon Book includes an exercise on converting integers to roman numerals using a syntax-directed translation scheme.</p>
<p>How can this be completed?</p>
|
[
{
"answer_id": 267587,
"author": "Oddthinking",
"author_id": 8014,
"author_profile": "https://Stackoverflow.com/users/8014",
"pm_score": 3,
"selected": true,
"text": "0 -> ''\n1 -> 'I'\n2 -> 'II'\n3 -> 'III'\n4 -> 'IV'\n...\n9 -> 'IX'\n 0 -> ''\n1 -> 'X'\n2 -> 'XX'\n...\n9 -> 'XC'\n"
},
{
"answer_id": 275699,
"author": "Lukman",
"author_id": 34586,
"author_profile": "https://Stackoverflow.com/users/34586",
"pm_score": 2,
"selected": false,
"text": "$roman = array(\n [0] = array( 1=>\"I\", 5=>\"V\", 10=>\"X\" ),\n [1] = array( 1=>\"X\", 5=>\"L\", 10=>\"C\" ),\n [2] = array( 1=>\"C\", 5=>\"D\", 10=>\"M\" ),\n [3] = array( 1=>\"M\", 5=>\"^V\", 10=>\"^X\" ),\n);\n 1 => $roman[$level][1]\n2 => $roman[$level][1].$roman[$level][1]\n3 => $roman[$level][1].$roman[$level][1].$roman[$level][1]\n4 => $roman[$level][1].$roman[$level][5]\n5 => $roman[$level][5]\n6 => $roman[$level][5].$roman[$level][1]\n7 => $roman[$level][5].$roman[$level][1].$roman[$level][1]\n8 => $roman[$level][5].$roman[$level][1].$roman[$level][1].$roman[$level][1]\n9 => $roman[$level][1].$roman[$level][10]\n 5 => $roman[0][5] = \"V\"\n4 => $roman[1][1].$roman[1][5] = \"XL\"\n9 => $roman[2][1].$roman[2][10] = \"CM\"\n1 => $roman[3][1] = \"M\"\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] |
267,367
|
<p>For example:</p>
<p>Base class header file has:</p>
<pre><code>enum FOO
{
FOO_A,
FOO_B,
FOO_C,
FOO_USERSTART
};
</code></pre>
<p>Then the derived class has:</p>
<pre><code>enum FOO
{
FOO_USERA=FOO_USERSTART
FOO_USERB,
FOO_USERC
};
</code></pre>
<p>Just to be clear on my usage it is for having an event handler where the base class has events and then derived classes can add events. The derived classes event handler would check for it's events and if the event was not for it, then it would pass the event down to the base class.</p>
<pre><code>class Base
{
public:
virtual void HandleFoo(FOO event);
};
class Derived: public Base
{
public:
void HandleFoo(FOO event);
};
void Base::HandleFoo(FOO event)
{
switch(event)
{
case FOO_A:
/* do stuff */
break;
case FOO_B:
/* do stuff */
break;
case FOO_B:
/* do stuff */
break;
}
}
void Derived::HandleFoo(FOO event)
{
switch(event)
{
case FOO_USERA:
/* do stuff */
break;
case FOO_USERB:
/* do stuff */
break;
case FOO_USERB:
/* do stuff */
break;
default:
/* not my event, must be for someone else */
Base::HandleFoo(event);
break;
}
}
</code></pre>
|
[
{
"answer_id": 268262,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 3,
"selected": true,
"text": "enum Foo {\n A,\n B,\n MAX = 1<<15\n};\n"
},
{
"answer_id": 269967,
"author": "Marcin",
"author_id": 22724,
"author_profile": "https://Stackoverflow.com/users/22724",
"pm_score": 0,
"selected": false,
"text": "enum FOO // Base class's FOO\n{\nFOO_A,\nFOO_B,\nFOO_C,\nFOO_BASE_MAX // Always keep this as the last value in the base class\n};\n\nenum FOO // Derived class's FOO\n{\nFOO_USERA=FOO_BASE_MAX+1, // Always keep this as the first value in the derived class\nFOO_USERB,\nFOO_USERC\n};"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13676/"
] |
267,369
|
<p>When beginning a new web project, i'm always a bit worried about removing pieces of the web.config. It seems there are more entries than ever with Net 3.5 SP1.</p>
<p>Which bits of the .config do you delete for the following scenarios:</p>
<ul>
<li>WCF Web Service, no Javascript support</li>
<li>Simple MVC Website</li>
</ul>
<p>EDIT
Can someone document a basic list of things left in and taken out of the web.config for a simple website?</p>
|
[
{
"answer_id": 506074,
"author": "Andrew Harry",
"author_id": 30576,
"author_profile": "https://Stackoverflow.com/users/30576",
"pm_score": 1,
"selected": true,
"text": "<?xml version=\"1.0\"?>\n<configuration>\n <system.web>\n <compilation debug=\"true\">\n <assemblies>\n <add assembly=\"System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\"/>\n </assemblies>\n </compilation>\n <authentication mode=\"Windows\" />\n <customErrors mode=\"RemoteOnly\" defaultRedirect=\"error.htm\">\n <error statusCode=\"403\" redirect=\"NoAccess.htm\" />\n <error statusCode=\"404\" redirect=\"FileNotFound.htm\" />\n </customErrors>\n </system.web>\n <system.codedom>\n <compilers>\n <compiler language=\"c#;cs;csharp\" extension=\".cs\" warningLevel=\"4\"\n type=\"Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n <providerOption name=\"CompilerVersion\" value=\"v3.5\"/>\n <providerOption name=\"WarnAsError\" value=\"false\"/>\n </compiler>\n </compilers>\n </system.codedom>\n <system.serviceModel>\n <services>\n <service behaviorConfiguration=\"Service.ServiceBehavior\" name=\"Service.Service\">\n <endpoint address=\"\" binding=\"basicHttpBinding\" contract=\"Service.IService\">\n <identity>\n <dns value=\"localhost\" />\n </identity>\n </endpoint>\n <endpoint address=\"mex\" binding=\"mexHttpBinding\" contract=\"IMetadataExchange\" />\n </service>\n </services>\n <behaviors>\n <serviceBehaviors>\n <behavior name=\"Service.ServiceBehavior\">\n <serviceMetadata httpGetEnabled=\"true\"/>\n <serviceDebug includeExceptionDetailInFaults=\"false\"/>\n </behavior>\n </serviceBehaviors>\n </behaviors>\n </system.serviceModel>\n</configuration>\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30576/"
] |
267,374
|
<p>People in java/.net world has framework which provides methods for sorting a list.</p>
<p>In CS, we all might have gone through Bubble/Insertion/Merge/Shell sorting algorithms.
Do you write any of it these days?</p>
<p>With frameworks in place, do you write code for sorting?<br></p>
<p>Do you think it makes sense to ask people to write code to sort in an interview? (other than for intern/junior developer requirement)</p>
|
[
{
"answer_id": 267406,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 3,
"selected": false,
"text": "list.Sort();\nenumerable.OrderBy(x => x); // Occasionally a different lambda is used\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23574/"
] |
267,399
|
<p>Thinking about <a href="https://stackoverflow.com/questions/267351/how-can-i-convert-from-integers-to-roman-numerals-using-a-syntax-directed-trans">my other problem</a>, i decided I can't even create a regular expression that will match roman numerals (let alone a context-free grammar that will generate them)</p>
<p>The problem is matching only valid roman numerals.
Eg, 990 is NOT "XM", it's "CMXC"</p>
<p>My problem in making the regex for this is that in order to allow or not allow certain characters, I need to look back.
Let's take thousands and hundreds, for example.</p>
<p>I can allow M{0,2}C?M (to allow for 900, 1000, 1900, 2000, 2900 and 3000). However, If the match is on CM, I can't allow following characters to be C or D (because I'm already at 900).</p>
<p>How can I express this in a regex?<br>
If it's simply not expressible in a regex, is it expressible in a context-free grammar?</p>
|
[
{
"answer_id": 267405,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 10,
"selected": true,
"text": "^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$\n M{0,4} 0 4000 0: <empty> matched by M{0}\n1000: M matched by M{1}\n2000: MM matched by M{2}\n3000: MMM matched by M{3}\n4000: MMMM matched by M{4}\n M* (CM|CD|D?C{0,3}) 0: <empty> matched by D?C{0} (with D not there)\n100: C matched by D?C{1} (with D not there)\n200: CC matched by D?C{2} (with D not there)\n300: CCC matched by D?C{3} (with D not there)\n400: CD matched by CD\n500: D matched by D?C{0} (with D there)\n600: DC matched by D?C{1} (with D there)\n700: DCC matched by D?C{2} (with D there)\n800: DCCC matched by D?C{3} (with D there)\n900: CM matched by CM\n (XC|XL|L?X{0,3}) 0: <empty> matched by L?X{0} (with L not there)\n10: X matched by L?X{1} (with L not there)\n20: XX matched by L?X{2} (with L not there)\n30: XXX matched by L?X{3} (with L not there)\n40: XL matched by XL\n50: L matched by L?X{0} (with L there)\n60: LX matched by L?X{1} (with L there)\n70: LXX matched by L?X{2} (with L there)\n80: LXXX matched by L?X{3} (with L there)\n90: XC matched by XC\n (IX|IV|V?I{0,3}) 0 9 0: <empty> matched by V?I{0} (with V not there)\n1: I matched by V?I{1} (with V not there)\n2: II matched by V?I{2} (with V not there)\n3: III matched by V?I{3} (with V not there)\n4: IV matched by IV\n5: V matched by V?I{0} (with V there)\n6: VI matched by V?I{1} (with V there)\n7: VII matched by V?I{2} (with V there)\n8: VIII matched by V?I{3} (with V there)\n9: IX matched by IX\n (?<=^)M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})(?=$)\n"
},
{
"answer_id": 267409,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 3,
"selected": false,
"text": "<opt-thousands-part><opt-hundreds-part><opt-tens-part><opt-units-part>\n <opt-hundreds-part> = m/(CM|DC{0,3}|CD|C{1,3})?/;\n <opt-hundreds-part> <opt-hundreds-part> = m/(C[MD]|D?C{0,3})/;\n <opt-hundreds-part> = m/(?:C[MD]|D?C{0,3})/;\n <opt-hundreds-part> = m/(?:[IXC][MD]|D?C{0,4})/;\n"
},
{
"answer_id": 5326535,
"author": "Marvin Frommhold",
"author_id": 662635,
"author_profile": "https://Stackoverflow.com/users/662635",
"pm_score": -1,
"selected": false,
"text": "^(M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})|[IDCXMLV])$\n"
},
{
"answer_id": 10441405,
"author": "Corin",
"author_id": 302306,
"author_profile": "https://Stackoverflow.com/users/302306",
"pm_score": 4,
"selected": false,
"text": "0 1 V L D (M{1,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})|M{0,4}(CM|C?D|D?C{1,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})|M{0,4}(CM|CD|D?C{0,3})(XC|X?L|L?X{1,3})(IX|IV|V?I{0,3})|M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|I?V|V?I{1,3}))\n ^ $ the Red Seacl and the Great Barrier Reefcli Tahiti fantastic Tahit fantasti"
},
{
"answer_id": 24354880,
"author": "Mottie",
"author_id": 145346,
"author_profile": "https://Stackoverflow.com/users/145346",
"pm_score": 0,
"selected": false,
"text": "/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/\n"
},
{
"answer_id": 26669245,
"author": "Salvador Dali",
"author_id": 1090562,
"author_profile": "https://Stackoverflow.com/users/1090562",
"pm_score": 3,
"selected": false,
"text": "import re\npattern = '^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$'\nif re.search(pattern, 'XCCMCI'):\n print 'Valid Roman'\nelse:\n print 'Not valid Roman'\n M{0,4}"
},
{
"answer_id": 27730606,
"author": "Vince Ypma",
"author_id": 3879027,
"author_profile": "https://Stackoverflow.com/users/3879027",
"pm_score": -1,
"selected": false,
"text": "function ConvertFrom-RomanNumeral\n{\n <#\n .SYNOPSIS\n Converts a Roman numeral to a number.\n .DESCRIPTION\n Converts a Roman numeral - in the range of I..MMMCMXCIX - to a number.\n .EXAMPLE\n ConvertFrom-RomanNumeral -Numeral MMXIV\n .EXAMPLE\n \"MMXIV\" | ConvertFrom-RomanNumeral\n #>\n [CmdletBinding()]\n [OutputType([int])]\n Param\n (\n [Parameter(Mandatory=$true,\n HelpMessage=\"Enter a roman numeral in the range I..MMMCMXCIX\",\n ValueFromPipeline=$true,\n Position=0)]\n [ValidatePattern(\"^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$\")]\n [string]\n $Numeral\n )\n\n Begin\n {\n $RomanToDecimal = [ordered]@{\n M = 1000\n CM = 900\n D = 500\n CD = 400\n C = 100\n XC = 90\n L = 50\n X = 10\n IX = 9\n V = 5\n IV = 4\n I = 1\n }\n }\n Process\n {\n $roman = $Numeral + \" \"\n $value = 0\n\n do\n {\n foreach ($key in $RomanToDecimal.Keys)\n {\n if ($key.Length -eq 1)\n {\n if ($key -match $roman.Substring(0,1))\n {\n $value += $RomanToDecimal.$key\n $roman = $roman.Substring(1)\n break\n }\n }\n else\n {\n if ($key -match $roman.Substring(0,2))\n {\n $value += $RomanToDecimal.$key\n $roman = $roman.Substring(2)\n break\n }\n }\n }\n }\n until ($roman -eq \" \")\n\n $value\n }\n End\n {\n }\n}\n\nfunction ConvertTo-RomanNumeral\n{\n <#\n .SYNOPSIS\n Converts a number to a Roman numeral.\n .DESCRIPTION\n Converts a number - in the range of 1 to 3,999 - to a Roman numeral.\n .EXAMPLE\n ConvertTo-RomanNumeral -Number (Get-Date).Year\n .EXAMPLE\n (Get-Date).Year | ConvertTo-RomanNumeral\n #>\n [CmdletBinding()]\n [OutputType([string])]\n Param\n (\n [Parameter(Mandatory=$true,\n HelpMessage=\"Enter an integer in the range 1 to 3,999\",\n ValueFromPipeline=$true,\n Position=0)]\n [ValidateRange(1,3999)]\n [int]\n $Number\n )\n\n Begin\n {\n $DecimalToRoman = @{\n Ones = \"\",\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\";\n Tens = \"\",\"X\",\"XX\",\"XXX\",\"XL\",\"L\",\"LX\",\"LXX\",\"LXXX\",\"XC\";\n Hundreds = \"\",\"C\",\"CC\",\"CCC\",\"CD\",\"D\",\"DC\",\"DCC\",\"DCCC\",\"CM\";\n Thousands = \"\",\"M\",\"MM\",\"MMM\"\n }\n\n $column = @{Thousands = 0; Hundreds = 1; Tens = 2; Ones = 3}\n }\n Process\n {\n [int[]]$digits = $Number.ToString().PadLeft(4,\"0\").ToCharArray() |\n ForEach-Object { [Char]::GetNumericValue($_) }\n\n $RomanNumeral = \"\"\n $RomanNumeral += $DecimalToRoman.Thousands[$digits[$column.Thousands]]\n $RomanNumeral += $DecimalToRoman.Hundreds[$digits[$column.Hundreds]]\n $RomanNumeral += $DecimalToRoman.Tens[$digits[$column.Tens]]\n $RomanNumeral += $DecimalToRoman.Ones[$digits[$column.Ones]]\n\n $RomanNumeral\n }\n End\n {\n }\n}\n"
},
{
"answer_id": 36576402,
"author": "smileart",
"author_id": 209557,
"author_profile": "https://Stackoverflow.com/users/209557",
"pm_score": 4,
"selected": false,
"text": "(^(?=[MDCLXVI])M*(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$)\n"
},
{
"answer_id": 53895776,
"author": "user2936263",
"author_id": 2936263,
"author_profile": "https://Stackoverflow.com/users/2936263",
"pm_score": 2,
"selected": false,
"text": "(?=\\b[MCDXLVI]{1,6}\\b)M{0,4}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3})\n import re\ntext = \"RULES OF LIFE: I. STAY CURIOUS; II. NEVER STOP LEARNING\"\ntext = re.sub(r'(?=\\b[MCDXLVI]{1,6}\\b)M{0,4}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3})', 'ROMAN', text)\nprint(text)\n RULES OF LIFE: ROMAN. STAY CURIOUS; ROMAN. NEVER STOP LEARNING\n"
},
{
"answer_id": 59311062,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": ">>> import re\n>>> target = (\n... r\"this should pass v\" + \"\\n\"\n... r\"this is a test iii\" + \"\\n\"\n... )\n>>>\n>>> re.findall( r\"(?m)\\s(i{1,3}v*|v)$\", target )\n['v', 'iii']\n (?m)\n \\s \n ( # (1 start)\n i{1,3} \n v* \n | v\n ) # (1 end)\n $\n"
},
{
"answer_id": 60461765,
"author": "ketenks",
"author_id": 7071412,
"author_profile": "https://Stackoverflow.com/users/7071412",
"pm_score": 0,
"selected": false,
"text": "(?<![A-Z])(M*(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3}))(?![A-Z]) (?<!) ([MATCH]) ([MATCH]) (?!) ([MATCH]) ([MATCH])"
},
{
"answer_id": 60469651,
"author": "Bernardo Duarte",
"author_id": 7395911,
"author_profile": "https://Stackoverflow.com/users/7395911",
"pm_score": 2,
"selected": false,
"text": "^(I[VX]|VI{0,3}|I{1,3})|((X[LC]|LX{0,3}|X{1,3})(I[VX]|V?I{0,3}))|((C[DM]|DC{0,3}|C{1,3})(X[LC]|L?X{0,3})(I[VX]|V?I{0,3}))|(M+(C[DM]|D?C{0,3})(X[LC]|L?X{0,3})(I[VX]|V?I{0,3}))$ M M+ M{1,4}"
},
{
"answer_id": 63774849,
"author": "Rafayet Ullah",
"author_id": 5409601,
"author_profile": "https://Stackoverflow.com/users/5409601",
"pm_score": 1,
"selected": false,
"text": "^M{0,4}(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$\n M{0,4} C[MD]|D?C{0,3} X[CL]|L?X{0,3} I[XV]|V?I{0,3} import re\nregex = re.compile(\"^M{0,4}(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$\")\nmatchArray = regex.match(\"MMMCMXCIX\")\n"
},
{
"answer_id": 64034764,
"author": "Pigeo",
"author_id": 10001863,
"author_profile": "https://Stackoverflow.com/users/10001863",
"pm_score": 1,
"selected": false,
"text": "(?!$)M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})\n (?!$) (?!f) f"
},
{
"answer_id": 68450933,
"author": "mekwall",
"author_id": 358556,
"author_profile": "https://Stackoverflow.com/users/358556",
"pm_score": 2,
"selected": false,
"text": "^(?=[MDCLXVI])M*(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$\n (?<![MDCLXVI])(?=[MDCLXVI])M{0,3}(?:C[MD]|D?C{0,3})(?:X[CL]|L?X{0,3})(?:I[XV]|V?I{0,3})[^ ]\\b\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] |
267,410
|
<p>I have a datasource that I want to bind to a listview that has multiple columns. How do I bind my datasource to that listview</p>
<p>Here is some pseudo code that doesn't work to help illustrate what I am trying to do:</p>
<pre><code>MyDataTable dt = GetDataSource();
ListView1.DataBindings.Add("Column1.Text", dt, "MyDBCol1");
ListView1.DataBindings.Add("Column2.Text", dt, "MyDBCol2");
</code></pre>
<p>-- edit --</p>
<p>Sorry, I forgot to mention it was winforms. </p>
|
[
{
"answer_id": 267720,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "ListView DataBindings.Add DataGridView"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632/"
] |
267,418
|
<p>Is there an elegant way to specialize a template based on one of its template parameters?</p>
<p>Ie.</p>
<pre><code>template<int N> struct Junk {
static int foo() {
// stuff
return Junk<N - 1>::foo();
}
};
// compile error: template argument '(size * 5)' involves template parameter(s)
template<int N> struct Junk<N*5> {
static int foo() {
// stuff
return N;
}
};
template<> struct Junk<0> {
static int foo() {
// stuff
return 0;
}
};
</code></pre>
<p>Ie. I am trying to specialize a template based on the parameter being divisible by 5. The only way I can seem to do it is like below:</p>
<pre><code>template<int N> struct JunkDivisibleBy5 {
static int foo() {
// stuff
return N;
}
};
template<int N> struct Junk {
static int foo() {
// stuff
if ((N - 1) % 5 == 0 && N != 1)
return JunkDivisibleBy5<N - 1>::foo();
else
return Junk<N - 1>::foo();
}
};
template<> struct Junk<0> {
static int foo() {
// stuff
return 0;
}
};
</code></pre>
<p>But this is significantly less elegant, and also necessitates instantiation of all templates even if the template argument shouldn't require it.</p>
|
[
{
"answer_id": 267514,
"author": "jwfearn",
"author_id": 10559,
"author_profile": "https://Stackoverflow.com/users/10559",
"pm_score": 5,
"selected": true,
"text": "#include <iostream>\nusing namespace std;\n\ntemplate < typename T, T N, T D >\nstruct fraction {\n typedef T value_type;\n static const value_type num = N;\n static const value_type denom = D;\n static const bool is_div = (num % denom == 0);\n};\n\ntemplate< typename T, T N, T D, bool P >\nstruct do_if {\n static void op() { cout << N << \" NOT divisible by \" << D << endl; }\n};\n\ntemplate< typename T, T N, T D >\nstruct do_if< T, N, D, true > {\n static void op() { cout << N << \" divisible by \" << D << endl; }\n};\n\ntemplate < int N >\nvoid foo() {\n typedef fraction< int, N, 5 > f;\n do_if< typename f::value_type, f::num, f::denom, f::is_div >::op();\n}\n\nint main() {\n foo< -5 >();\n foo< -1 >();\n foo< 0 >();\n foo< 1 >();\n foo< 5 >();\n foo< 10000005 >();\n return 0;\n}\n"
},
{
"answer_id": 267535,
"author": "hark",
"author_id": 34826,
"author_profile": "https://Stackoverflow.com/users/34826",
"pm_score": 0,
"selected": false,
"text": "#include <iostream>\n\ntemplate < int N > struct JunkDivBy5 {\n static int foo() {\n return N;\n }\n};\n\ntemplate < int N > struct Junk {\n template < int N1 > struct _JunkCond {\n enum { val = ( N1 != 1 && ( N1 - 1 ) % 5 == 0 ) ? 1 : 0 };\n };\n\n template < int M, int N1 > struct _JunkBranch { /* Error */ };\n\n template < int N1 > struct _JunkBranch< 1, N1 > {\n typedef JunkDivBy5< N1 - 1 > Type;\n };\n\n template < int N1 > struct _JunkBranch< 0, N1 > {\n typedef Junk< N1 - 1 > Type;\n };\n\n static int foo() {\n return _JunkBranch< _JunkCond< N >::val, N >::Type::foo();\n }\n};\n\ntemplate <> struct Junk< 0 > {\n static int foo() {\n return 0;\n }\n};\n\nint main( int argc, char *argv[] ) {\n std::cout << Junk< 0 >::foo() << std::endl;\n std::cout << Junk< 5 >::foo() << std::endl;\n std::cout << Junk< 7 >::foo() << std::endl;\n std::cout << Junk< 25 >::foo() << std::endl;\n}\n"
},
{
"answer_id": 267899,
"author": "Igor Semenov",
"author_id": 11401,
"author_profile": "https://Stackoverflow.com/users/11401",
"pm_score": 3,
"selected": false,
"text": "#include <iostream>\n\ntemplate<int N> struct Junk {\n enum { IsDivisibleBy5 = (N % 5 == 0) };\n template<bool D> struct JunkInternal {\n enum { Result = Junk<N-1>::Result };\n };\n template<> struct JunkInternal<true> {\n enum { Result = N };\n };\n enum { Result = JunkInternal<IsDivisibleBy5>::Result };\n};\n\nint main(int, char**)\n{\n std::cout << Junk< 0 >::Result << std::endl;\n std::cout << Junk< 7 >::Result << std::endl;\n std::cout << Junk< 10 >::Result << std::endl;\n\n return 0;\n}\n"
},
{
"answer_id": 268255,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 2,
"selected": false,
"text": "template<int N> struct Junk : private JunkBase < N % 5 > { };\n\ntemplate<int N> struct JunkBase {\n static int foo() {\n // stuff\n return Junk<N - 1>::foo();\n }\n};\ntemplate< > struct JunkBase<0> {\n static int foo() {\n return 0;\n }\n};\n"
},
{
"answer_id": 275254,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 2,
"selected": false,
"text": "template<int A, bool = !(A % 5)>\nstruct select : select<A-1> { };\n\ntemplate<int A>\nstruct select<A, true> { static int const value = A; };\n\ntemplate<>\nstruct select<0, true> { static int const value = 0; };\n\nint main() {\n std::cout << select<1>::value; // 0\n std::cout << select<7>::value; // 5\n std::cout << select<10>::value; // 10\n}\n template<int A, int D, bool = !(A % D)>\nstruct select : select<A-1, D> { };\n\ntemplate<int A, int D>\nstruct select<A, D, true> { static int const value = A; };\n\ntemplate<int D>\nstruct select<0, D, true> { static int const value = 0; };\n\nint main() {\n std::cout << select<1, 3>::value; // 0\n std::cout << select<7, 3>::value; // 6\n std::cout << select<10, 3>::value; // 9\n}\n"
},
{
"answer_id": 280697,
"author": "Walter Bright",
"author_id": 33949,
"author_profile": "https://Stackoverflow.com/users/33949",
"pm_score": 3,
"selected": false,
"text": "struct Junk(int N)\n{\n static int foo()\n {\n static if (N == 0)\n return 0;\n else static if ((N % 5) == 0)\n return N;\n else\n return Junk!(N - 1).foo();\n }\n}\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5963/"
] |
267,427
|
<p>I have a file with data listed as follows:</p>
<pre><code>0, 2, 10
10, 8, 10
10, 10, 10
10, 16, 10
15, 10, 16
17, 10, 16
</code></pre>
<p>I want to be able to input the file and split it into three arrays, in the process trimming all excess spaces and converting each element to integers.</p>
<p>For some reason I can't find an easy way to do this in c++. The only success I've had is by inputting each line into an array, and then regexing out all the spaces and then splitting it up. This entire process took me a good 20-30 lines of code and its a pain to modify for say another separator(eg. space), etc.</p>
<p>This is the python equivalent of what I would like to have in C++:</p>
<pre><code>f = open('input_hard.dat')
lines = f.readlines()
f.close()
#declarations
inint, inbase, outbase = [], [], []
#input parsing
for line in lines:
bits = string.split(line, ',')
inint.append(int(bits[0].strip()))
inbase.append(int(bits[1].strip()))
outbase.append(int(bits[2].strip()))
</code></pre>
<p>The ease of use of doing this in python is one of the reasons why I moved to it in the first place. However, I require to do this in C++ now and I would hate to have to use my ugly 20-30 line code.</p>
<p>Any help would be appreciated, thanks!</p>
|
[
{
"answer_id": 267449,
"author": "Matthew Smith",
"author_id": 20889,
"author_profile": "https://Stackoverflow.com/users/20889",
"pm_score": 2,
"selected": false,
"text": "vector<int> inint;\nvector<int> inbase;\nvector<int> outbase;\nwhile (fgets(buf, fh)) {\n char *tok = strtok(buf, \", \");\n inint.push_back(atoi(tok));\n tok = strtok(NULL, \", \");\n inbase.push_back(atoi(tok));\n tok = strtok(NULL, \", \");\n outbase.push_back(atoi(tok));\n}\n"
},
{
"answer_id": 267497,
"author": "Raymond Martineau",
"author_id": 33952,
"author_profile": "https://Stackoverflow.com/users/33952",
"pm_score": 1,
"selected": false,
"text": "string buf;\ngetline(cin, buf); \nstringstream par(buf);\n\nchar buf2[512];\npar.getline(buf2, 512, ','); /* Reads until the first token. */\n if (cin.peek() == ',')\n cin.ignore(1, ',');\ncin >> nextInt; \n"
},
{
"answer_id": 267563,
"author": "Head Geek",
"author_id": 12193,
"author_profile": "https://Stackoverflow.com/users/12193",
"pm_score": 1,
"selected": false,
"text": "#include <string>\n#include <vector>\n#include <boost/lexical_cast.hpp>\n#include <boost/regex.hpp>\n\nstd::vector<int> ParseFile(std::istream& in) {\n const boost::regex cItemPattern(\" *([0-9]+),?\");\n std::vector<int> return_value;\n\n std::string line;\n while (std::getline(in, line)) {\n string::const_iterator b=line.begin(), e=line.end();\n boost::smatch match;\n while (b!=e && boost::regex_search(b, e, match, cItemPattern)) {\n return_value.push_back(boost::lexical_cast<int>(match[1].str()));\n b=match[0].second;\n };\n };\n\n return return_value;\n}\n #include const boost::regex cItemPattern(\" *([0-9]+), *([0-9]+), *([0-9]+)\");\nstd::vector<int> vector1, vector2, vector3;\n\nstd::string line;\nwhile (std::getline(in, line)) {\n string::const_iterator b=line.begin(), e=line.end();\n boost::smatch match;\n while (b!=e && boost::regex_search(b, e, match, cItemPattern)) {\n vector1.push_back(boost::lexical_cast<int>(match[1].str()));\n vector2.push_back(boost::lexical_cast<int>(match[2].str()));\n vector3.push_back(boost::lexical_cast<int>(match[3].str()));\n b=match[0].second;\n };\n};\n"
},
{
"answer_id": 267722,
"author": "MattyT",
"author_id": 7405,
"author_profile": "https://Stackoverflow.com/users/7405",
"pm_score": 3,
"selected": false,
"text": "int main(int argc, char* argv[])\n{\n ifstream file(argv[1]);\n\n const unsigned maxIgnore = 10;\n const int delim = ',';\n int x,y,z;\n\n vector<int> vecx, vecy, vecz;\n\n while (file)\n {\n file >> x;\n file.ignore(maxIgnore, delim);\n file >> y;\n file.ignore(maxIgnore, delim);\n file >> z;\n\n vecx.push_back(x);\n vecy.push_back(y);\n vecz.push_back(z);\n }\n}\n"
},
{
"answer_id": 267936,
"author": "ididak",
"author_id": 28888,
"author_profile": "https://Stackoverflow.com/users/28888",
"pm_score": 4,
"selected": true,
"text": "FILE *fp = fopen(\"file.dat\", \"r\");\nint x, y, z;\nstd::vector<int> vx, vy, vz;\n\nwhile (fscanf(fp, \"%d, %d, %d\", &x, &y, &z) == 3) {\n vx.push_back(x);\n vy.push_back(y);\n vz.push_back(z);\n}\nfclose(fp);\n"
},
{
"answer_id": 267999,
"author": "da_m_n",
"author_id": 7165,
"author_profile": "https://Stackoverflow.com/users/7165",
"pm_score": 2,
"selected": false,
"text": "std::ifstream file(\"input_hard.dat\");\nstd::vector<int> inint, inbase, outbase;\n\nwhile (file.good()){\n int val1, val2, val3;\n char delim;\n file >> val1 >> delim >> val2 >> delim >> val3;\n\n inint.push_back(val1);\n inbase.push_back(val2);\n outbase.push_back(val3);\n}\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338360/"
] |
267,436
|
<p>For example, if I have a <em>unicode</em> string, I can encode it as an <em>ASCII</em> string like so:</p>
<pre><code>>>> u'\u003cfoo/\u003e'.encode('ascii')
'<foo/>'
</code></pre>
<p>However, I have e.g. this <em>ASCII</em> string:</p>
<pre><code>'\u003foo\u003e'
</code></pre>
<p>... that I want to turn into the same <em>ASCII</em> string as in my first example above:</p>
<pre><code>'<foo/>'
</code></pre>
|
[
{
"answer_id": 267444,
"author": "Ned Batchelder",
"author_id": 14343,
"author_profile": "https://Stackoverflow.com/users/14343",
"pm_score": 0,
"selected": false,
"text": ">>> s = '\\u003cfoo\\u003e'\n>>> eval('u\"'+s.replace('\"', r'\\\"')+'\"').encode('ascii')\n'<foo>'\n"
},
{
"answer_id": 267475,
"author": "hark",
"author_id": 34826,
"author_profile": "https://Stackoverflow.com/users/34826",
"pm_score": 7,
"selected": true,
"text": ">>> s = '\\u003cfoo/\\u003e'\n>>> s.decode( 'unicode-escape' )\nu'<foo/>'\n>>> s.decode( 'unicode-escape' ).encode( 'ascii' )\n'<foo/>'\n"
},
{
"answer_id": 11281948,
"author": "MakerDrone",
"author_id": 915372,
"author_profile": "https://Stackoverflow.com/users/915372",
"pm_score": 1,
"selected": false,
"text": ">>> s = '\\u003cfoo\\u003e'\n>>> eval('u\"'+s.replace('\"', r'\\\"')+'\"').encode('ascii')\n'<foo>'\n >>> s = '\\u003cfoo\\u003e'\n>>> s_unescaped = eval('u\"\"\"'+s.replace('\"', r'\\\"')+'-\"\"\"')[:-1]\n"
},
{
"answer_id": 22726482,
"author": "Okezie",
"author_id": 751528,
"author_profile": "https://Stackoverflow.com/users/751528",
"pm_score": 2,
"selected": false,
"text": "UnicodeEncodeError: 'ascii' codec can't encode characters in position 109-123: ordinal not in range(128)\n >>> s = '\\u003cfoo\\u003e'\n>>> s.decode( 'unicode-escape' ).encode( 'utf-8' )\n>>> <foo>\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] |
267,439
|
<p>Much related to <a href="https://stackoverflow.com/questions/245687/managing-reference-paths-between-x86-and-x64-workstations-in-a-team">this question</a>, we have a scenario on my team where we need to copy the contents of a folder for a suite of libraries and configuration files for said libraries to our folder where our test code is running from, as part of the test's deployment step.</p>
<p>Due to the installation size, and other factors, checking in this install folder into source control for sharing between team members just isn't viable.</p>
<p>The install path for the folder is either <strong>/Program Files/InternalTool/</strong> or <strong>/Program Files (x86)/InternalTool/</strong> depending on the installed environment. I want to setup my .testrunconfig file such that when a person gets the latest version of the solution, they don't have to worry about fixups for the path to the shared internal library suite.</p>
<p>Is there a way to make this seamless for all members involved, and if so, how could one accomplish this?</p>
<p>Restrictions are as follows:</p>
<ul>
<li>can't check in shared suite</li>
<li>shared suite has no override for installation path</li>
</ul>
<p>Is this possible, or am I asking for too much?</p>
|
[
{
"answer_id": 267444,
"author": "Ned Batchelder",
"author_id": 14343,
"author_profile": "https://Stackoverflow.com/users/14343",
"pm_score": 0,
"selected": false,
"text": ">>> s = '\\u003cfoo\\u003e'\n>>> eval('u\"'+s.replace('\"', r'\\\"')+'\"').encode('ascii')\n'<foo>'\n"
},
{
"answer_id": 267475,
"author": "hark",
"author_id": 34826,
"author_profile": "https://Stackoverflow.com/users/34826",
"pm_score": 7,
"selected": true,
"text": ">>> s = '\\u003cfoo/\\u003e'\n>>> s.decode( 'unicode-escape' )\nu'<foo/>'\n>>> s.decode( 'unicode-escape' ).encode( 'ascii' )\n'<foo/>'\n"
},
{
"answer_id": 11281948,
"author": "MakerDrone",
"author_id": 915372,
"author_profile": "https://Stackoverflow.com/users/915372",
"pm_score": 1,
"selected": false,
"text": ">>> s = '\\u003cfoo\\u003e'\n>>> eval('u\"'+s.replace('\"', r'\\\"')+'\"').encode('ascii')\n'<foo>'\n >>> s = '\\u003cfoo\\u003e'\n>>> s_unescaped = eval('u\"\"\"'+s.replace('\"', r'\\\"')+'-\"\"\"')[:-1]\n"
},
{
"answer_id": 22726482,
"author": "Okezie",
"author_id": 751528,
"author_profile": "https://Stackoverflow.com/users/751528",
"pm_score": 2,
"selected": false,
"text": "UnicodeEncodeError: 'ascii' codec can't encode characters in position 109-123: ordinal not in range(128)\n >>> s = '\\u003cfoo\\u003e'\n>>> s.decode( 'unicode-escape' ).encode( 'utf-8' )\n>>> <foo>\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14409/"
] |
267,451
|
<p>I would like to read/write encrypted XML files using LINQ to XML. Does anyone know how to use encryption algorithms built into the .NET Framework to encrypt the Stream used by the XDocument object?</p>
<p>I did try it, but you can't set the CryptoStream to Read/Write access. It only support Read or Write, which causes LINQ to XML to throw an exception.</p>
<p>Update: It would be nice to read/write the document "on the fly", but I am only required to read the encrypted xml file, manipulate it, then write it back out encrypted again.</p>
|
[
{
"answer_id": 267713,
"author": "Corbin March",
"author_id": 7625,
"author_profile": "https://Stackoverflow.com/users/7625",
"pm_score": 4,
"selected": true,
"text": "XDocument writeContacts = new XDocument(\n new XElement(\"contacts\",\n new XElement(\"contact\",\n new XElement(\"name\", \"Patrick Hines\"),\n new XElement(\"phone\", \"206-555-0144\",\n new XAttribute(\"type\", \"home\")),\n new XElement(\"phone\", \"425-555-0145\",\n new XAttribute(\"type\", \"work\")),\n new XElement(\"address\",\n new XElement(\"street1\", \"123 Main St\"),\n new XElement(\"city\", \"Mercer Island\"),\n new XElement(\"state\", \"WA\"),\n new XElement(\"postal\", \"68042\")\n )\n )\n )\n);\n\nRijndael RijndaelAlg = Rijndael.Create();\n\nFileStream writeStream = File.Open(\"data.xml\", FileMode.Create);\nCryptoStream cStream = new CryptoStream(writeStream,\n RijndaelAlg.CreateEncryptor(RijndaelAlg.Key, RijndaelAlg.IV),\n CryptoStreamMode.Write);\n\nStreamWriter writer = new StreamWriter(cStream);\n\nwriteContacts.Save(writer);\n\nwriter.Flush();\nwriter.Close();\n\nFileStream readStream = File.OpenRead(\"data.xml\");\n\ncStream = new CryptoStream(readStream,\n RijndaelAlg.CreateDecryptor(RijndaelAlg.Key, RijndaelAlg.IV),\n CryptoStreamMode.Read);\n\nXmlTextReader reader = new XmlTextReader(cStream);\n\nXDocument readContacts = XDocument.Load(reader);\n\n//manipulate with Linq and Save() when needed\n"
},
{
"answer_id": 267714,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "CryptoStream XDocument CryptoStream FileStream MemoryStream CryptoStream .Close()"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7831/"
] |
267,465
|
<p>On IBM DB2 v.9 windows, when someone connect to database by Server\Administrator user
DB2 database will automatically accept and grant all the permissions to this user?
But, in some case environment Administrator of server does not need to see every data in the database. So how to prevent Administrator use connect to database?</p>
|
[
{
"answer_id": 274355,
"author": "Kevin Beck",
"author_id": 24734,
"author_profile": "https://Stackoverflow.com/users/24734",
"pm_score": 0,
"selected": false,
"text": "CONNECT GRANT CONNECT ON DATABASE TO <user1>, <user2>, ...\n REVOKE CONNECT ON DATABASE FROM PUBLIC\n"
},
{
"answer_id": 287090,
"author": "Tanktalus",
"author_id": 23512,
"author_profile": "https://Stackoverflow.com/users/23512",
"pm_score": 0,
"selected": false,
"text": "sysadm"
},
{
"answer_id": 11067718,
"author": "Ian Bjorhovde",
"author_id": 154726,
"author_profile": "https://Stackoverflow.com/users/154726",
"pm_score": 0,
"selected": false,
"text": "SYSADM_GROUP SYSADM SYSADM_GROUP SYSADM_GROUP SYSADM CONNECT CONNECT"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24550/"
] |
267,473
|
<p>The exception mentions</p>
<pre><code>FILE* __cdecl _getstream
</code></pre>
<p>I'm calling <code>fopen</code> and it keeps crashing. </p>
<pre><code>AfxMessageBox("getting here 1");
FILE* filePtr = fopen(fileName, "rb");
AfxMessageBox("getting here 2");
</code></pre>
<p>For some reason, I never get to the second message box. Interestingly, when I'm in debug mode, the app works perfectly. Why?</p>
|
[
{
"answer_id": 24874294,
"author": "ArtHare",
"author_id": 1158478,
"author_profile": "https://Stackoverflow.com/users/1158478",
"pm_score": 0,
"selected": false,
"text": "HANDLE hMyFile = CreateFile(...);\nFILE* pFile = _fdopen( _open_osfhandle((long)hMyFile, <flags>), \"rb\" );\nCloseHandle(hMyFile);\n #include \"stdafx.h\"\n#include <Windows.h>\n#include <io.h>\n#include <assert.h>\n#include <fcntl.h>\nint _tmain(int argc, _TCHAR* argv[])\n{\n\n for(int x = 0;x < 1024; x++)\n {\n HANDLE hFile = CreateFile(L\"c:\\\\temp\\\\rawdata.txt\",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);\n FILE* pFile = _fdopen( _open_osfhandle((long)hFile, _O_RDONLY | _O_BINARY), \"rb\" );\n assert(pFile); // this assert will go off at x=509, because _getstream() only has 512 streams, and 3 are reserved for stdin/stdout/stderr\n CloseHandle(hFile);\n }\n\n return 0;\n}\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31325/"
] |
267,477
|
<p>I know that you can use a dummy "int" parameter on <code>operator++</code> and <code>operator--</code> to override the postfix versions of those operators, but I vaguely recall something about a dummy parameter that you could declare on a destructor. Does anyone know anything about that, and if so, what that dummy parameter did?</p>
<p>This was in my old Turbo C++ tutorial books, which I read when I was a teenager (i.e. a <em>long</em> time ago), so I might be completely misremembering it. That was also very early C++, before it was standardized, so it's possible that it was something Turbo C++-specific.</p>
|
[
{
"answer_id": 267505,
"author": "Thomas L Holaday",
"author_id": 29403,
"author_profile": "https://Stackoverflow.com/users/29403",
"pm_score": 2,
"selected": false,
"text": "class MyClass { /* ... */ };\n\nchar * raw_mem = new char [sizeof (MyClass)];\npMyClass = new (raw_mem) MyClass;\n// ...\npMyClass-->(~MyClass());\ndelete[] raw_mem;\n"
},
{
"answer_id": 267561,
"author": "puetzk",
"author_id": 14312,
"author_profile": "https://Stackoverflow.com/users/14312",
"pm_score": 4,
"selected": true,
"text": "void operator delete(void *, void *) throw();\nvoid operator delete(void *, const std::nothrow_t&) throw();\nvoid operator delete[](void *, void *) throw();\nvoid operator delete[](void *, const std::nothrow_t&) throw();\n void operator delete(void *)\n obj = new(x,y,z) Object(a,b,c) \n void *raw = operator new(sizeof(Object), x,y,z)\ntry {\n obj = new(raw) Object(a,b,c);\n} catch(...) {\n operator delete(raw,x,y,z);\n throw;\n}\n"
},
{
"answer_id": 300883,
"author": "mikeyk",
"author_id": 24389,
"author_profile": "https://Stackoverflow.com/users/24389",
"pm_score": 1,
"selected": false,
"text": "$ create foo.cxx\nclass foo\n{\n ~foo() {}\n};\n\n$ cxx foo.cxx\n\n$ type [.CXX_REPOSITORY]cxx$demangler_db.\nCX3$_ZN3FOOD1EV31GNTHJ foo::$complete$~foo()\nCX3$_ZN3FOOD2EV30KQI3A foo::$subobject$~foo()\nCX3$_ZN3FOOD9EV36HH9SB foo::~foo(int)\nCXXL$_ZDLPV void operator delete(void *)\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12193/"
] |
267,487
|
<p>I want to do something like this:</p>
<pre><code>SQL.Text := Format('select foo from bar where baz like ''%s%''',[SearchTerm]);
</code></pre>
<p>But Format doesn't like that last '%', of course. So how can I escape it? <code>\%</code>? <code>%%</code>? </p>
<p>Or do I have to do this:</p>
<pre><code>SQL.Text := Format('select foo from bar where baz like ''%s''',[SearchTerm+'%']);
</code></pre>
<p>?</p>
|
[
{
"answer_id": 267506,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 6,
"selected": true,
"text": "SQL.Text := Format('select foo from bar where baz like ''%s%%''',[SearchTerm]);\n"
},
{
"answer_id": 18956816,
"author": "Charmy Vora",
"author_id": 1309923,
"author_profile": "https://Stackoverflow.com/users/1309923",
"pm_score": 1,
"selected": false,
"text": " Format('select foo from bar where baz like ''%%%s%%'',[SearchString])\n select foo from bar where baz like '%SearchString%'\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/369/"
] |
267,488
|
<p>I'm having some trouble figuring out how to use more than one left outer join using LINQ to SQL. I understand how to use one left outer join. I'm using VB.NET. Below is my SQL syntax.</p>
<p><strong>T-SQL</strong></p>
<pre><code>SELECT
o.OrderNumber,
v.VendorName,
s.StatusName
FROM
Orders o
LEFT OUTER JOIN Vendors v ON
v.Id = o.VendorId
LEFT OUTER JOIN Status s ON
s.Id = o.StatusId
WHERE
o.OrderNumber >= 100000 AND
o.OrderNumber <= 200000
</code></pre>
|
[
{
"answer_id": 267542,
"author": "Jon Norton",
"author_id": 4797,
"author_profile": "https://Stackoverflow.com/users/4797",
"pm_score": 2,
"selected": false,
"text": "DataContext.ExecuteCommand(...)"
},
{
"answer_id": 267632,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 6,
"selected": false,
"text": "var query = from o in dc.Orders\n join v in dc.Vendors on o.VendorId equals v.Id into ov\n from x in ov.DefaultIfEmpty()\n join s in dc.Status on o.StatusId equals s.Id into os\n from y in os.DefaultIfEmpty()\n select new { o.OrderNumber, x.VendorName, y.StatusName }\n"
},
{
"answer_id": 268991,
"author": "Bryan Roth",
"author_id": 299,
"author_profile": "https://Stackoverflow.com/users/299",
"pm_score": 5,
"selected": false,
"text": "Dim db As New ContractDataContext()\n\nDim query = From o In db.Orders _\n Group Join v In db.Vendors _\n On v.VendorNumber Equals o.VendorNumber _\n Into ov = Group _\n From x In ov.DefaultIfEmpty() _\n Group Join s In db.Status _\n On s.Id Equals o.StatusId Into os = Group _\n From y In os.DefaultIfEmpty() _\n Where o.OrderNumber >= 100000 And o.OrderNumber <= 200000 _\n Select Vendor_Name = x.Name, _\n Order_Number = o.OrderNumber, _\n Status_Name = y.StatusName\n"
},
{
"answer_id": 1971086,
"author": "Amir",
"author_id": 40914,
"author_profile": "https://Stackoverflow.com/users/40914",
"pm_score": 9,
"selected": true,
"text": "into var query = \n from order in dc.Orders\n from vendor \n in dc.Vendors\n .Where(v => v.Id == order.VendorId)\n .DefaultIfEmpty()\n from status \n in dc.Status\n .Where(s => s.Id == order.StatusId)\n .DefaultIfEmpty()\n select new { Order = order, Vendor = vendor, Status = status } \n //Vendor and Status properties will be null if the left join is null\n var results = \n from expense in expenseDataContext.ExpenseDtos\n where expense.Id == expenseId //some expense id that was passed in\n from category \n // left join on categories table if exists\n in expenseDataContext.CategoryDtos\n .Where(c => c.Id == expense.CategoryId)\n .DefaultIfEmpty() \n // left join on expense type table if exists\n from expenseType \n in expenseDataContext.ExpenseTypeDtos\n .Where(e => e.Id == expense.ExpenseTypeId)\n .DefaultIfEmpty()\n // left join on currency table if exists\n from currency \n in expenseDataContext.CurrencyDtos\n .Where(c => c.CurrencyID == expense.FKCurrencyID)\n .DefaultIfEmpty() \n select new \n { \n Expense = expense,\n // category will be null if join doesn't exist\n Category = category,\n // expensetype will be null if join doesn't exist\n ExpenseType = expenseType,\n // currency will be null if join doesn't exist\n Currency = currency \n }\n"
},
{
"answer_id": 12452159,
"author": "Mitul",
"author_id": 581922,
"author_profile": "https://Stackoverflow.com/users/581922",
"pm_score": 3,
"selected": false,
"text": "Dim query = From order In dc.Orders\n From vendor In \n dc.Vendors.Where(Function(v) v.Id = order.VendorId).DefaultIfEmpty()\n From status In \n dc.Status.Where(Function(s) s.Id = order.StatusId).DefaultIfEmpty()\n Select Order = order, Vendor = vendor, Status = status \n"
},
{
"answer_id": 47174324,
"author": "Iam ck",
"author_id": 7707003,
"author_profile": "https://Stackoverflow.com/users/7707003",
"pm_score": 0,
"selected": false,
"text": " Dim result = (From csL In contractEntity.CSLogin.Where(Function(cs) cs.Login = login AndAlso cs.Password = password).DefaultIfEmpty\n From usrT In contractEntity.UserType.Where(Function(uTyp) uTyp.UserTypeID = csL.UserTyp).DefaultIfEmpty ' <== makes join left join\n From kunD In contractEntity.EmployeeMaster.Where(Function(kunDat) kunDat.CSLoginID = csL.CSLoginID).DefaultIfEmpty\n Select New With {\n .CSLoginID = csL.CSLoginID,\n .UserType = csL.UserTyp}).ToList()\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/299/"
] |
267,530
|
<p>I have two tables that I would like to join but I am getting an error from MySQL</p>
<pre><code>Table: books
bookTagNum ShelfTagNum
book1 1
book2 2
book3 2
Table: shelf
shelfNum shelfTagNum
1 shelf1
2 shelf2
</code></pre>
<p>I want my results to be:</p>
<pre><code>bookTagNum ShelfTagNum shelfNum
book1 shelf1 1
book2 shelf2 2
book3 shelf2 2
</code></pre>
<p>but instead I am also getting an extra result:</p>
<pre><code>book1 shelf2 2
</code></pre>
<p>I think my query is doing a cross product instead of a join:</p>
<pre><code>SELECT `books`.`bookTagNum` , `books`.`shelfNum` , `shelf`.`shelfTagNum` , `books`.`title`
FROM books, shelf
where `books`.`shelfNum`=`books`.`shelfNum`
ORDER BY `shelf`.`shelfTagNum` ASC
LIMIT 0 , 30
</code></pre>
<p>What am I doing wrong?</p>
|
[
{
"answer_id": 267531,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 3,
"selected": false,
"text": "where `books`.`shelfTagNum`=`shelf`.`shelfNum`\n books shelf where books shelfNum shelfNum JOIN"
},
{
"answer_id": 267532,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 0,
"selected": false,
"text": "SELECT `books`.`bookTagNum` , `books`.`shelfNum` , `shelf`.`shelfTagNum` , \n `books`.`title`\nFROM books, shelf\nwhere `books`.`shelftagNum`=`shelf`.`shelfNum`\nORDER BY `shelf`.`shelfTagNum` ASC\nLIMIT 0 , 30\n"
},
{
"answer_id": 267536,
"author": "Tor Haugen",
"author_id": 32050,
"author_profile": "https://Stackoverflow.com/users/32050",
"pm_score": 1,
"selected": false,
"text": "books shelfNum books shelfNum"
},
{
"answer_id": 267544,
"author": "Tor Haugen",
"author_id": 32050,
"author_profile": "https://Stackoverflow.com/users/32050",
"pm_score": 3,
"selected": false,
"text": "SELECT books.bookTagNum,books.shelfNum, shelf.shelfTagNum, books.title\nFROM books INNER JOIN shelf ON books.shelfNum = shelf.shelfTagNum\nORDER BY shelf.shelfTagNum\n SELECT books.bookTagNum,books.shelfNum, shelf.shelfTagNum, books.title\nFROM books LEFT OUTER JOIN shelf ON books.shelfNum = shelf.shelfTagNum\nORDER BY shelf.shelfTagNum\n SELECT books.bookTagNum,books.shelfNum, shelf.shelfTagNum, books.title\nFROM books RIGHT OUTER JOIN shelf ON books.shelfNum = shelf.shelfTagNum\nORDER BY shelf.shelfTagNum\n"
},
{
"answer_id": 267634,
"author": "Robert Paulson",
"author_id": 14033,
"author_profile": "https://Stackoverflow.com/users/14033",
"pm_score": 2,
"selected": false,
"text": "Table 1: Book\nBookID ShelfID BookName\n1 1 book1\n2 2 book2\n3 2 book3\n\nTable 2: Shelf\nShelfID ShelfName\n1 shelf1\n2 shelf2\n SELECT \n b.BookName,\n s.ShelfName\nFROM\n Book b\nJOIN Shelf s ON s.ShelfID = b.ShelfID\n > where `books`.`shelfNum`=`books`.`shelfNum`\n> ^^^^^--------------^^^^^------------- books repeated - this is an error\n WHERE"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28462/"
] |
267,534
|
<p>I asked this question before, <a href="https://stackoverflow.com/questions/264441/does-a-native-php-5-function-exist-that-does-the-following-in-1-line">Here</a> however I think I presented the problem poorly, and got quite a few replies that may have been useful to someone but did not address the actual question and so I pose the question again.</p>
<p>Is there a single-line native method in php that would allow me to do the following.
Please, please, I understand there are other ways to do this simple thing, but the question I present is does something exist <strong>natively in PHP</strong> that will <strong>grant me access to the array</strong> values directly <strong>without having to create a temporary array</strong>.</p>
<pre><code>$rand_place = explode(",",loadFile("csvOf20000places.txt")){rand(0,1000)};
</code></pre>
<p>This is a syntax error, however ideally it would be great if this worked!</p>
<p>Currently, it seems unavoidable that one must create a temporary array, ie</p>
<p><strong>The following is what I want to avoid:</strong></p>
<pre><code>$temporary_places_array = explode(",",loadFile("csvOf20000places.txt"));
$rand_place = $temporary_places_array[rand(0,1000)];
</code></pre>
<p>Also, i must note that my actual intentions are not to parse strings, or pull randomly from an array. <strong>I simply want access into the string without a temporary variable</strong>. This is just an example which i hope is easy to understand. There are many times service calls or things you do not have control over returns an array (such as the explode() function) and you just want access into it without having to create a temporary variable.</p>
<p><strong>NATIVELY NATIVELY NATIVELY, i know i can create a function that does it.</strong></p>
|
[
{
"answer_id": 267545,
"author": "Matthew Scharley",
"author_id": 15537,
"author_profile": "https://Stackoverflow.com/users/15537",
"pm_score": 0,
"selected": false,
"text": "$pos = 0;\n$num = 0;\nwhile(($pos = strpos($places, ',', $pos+1)) !== false) {$num++;}\n$which = rand(0, $num);\n$num = 0;\nwhile($num <= $which) {$pos = strpos($places, ',', $pos+1);}\n$random_place = substr($places, $pos, strpos($places, ',', $pos+1));\n"
},
{
"answer_id": 267552,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 1,
"selected": false,
"text": "function array_value($array, $key) {\n return $array[$key];\n}\n $places = \"alabama,alaska,arizona .... zimbabway\"; \n$random_place = array_value(explode(\",\", $places), rand(0, 1000));\n"
},
{
"answer_id": 267576,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 0,
"selected": false,
"text": "<?php\nfunction foo() {\n return new ArrayObject(explode(\",\", \"zero,one,two\"));\n}\necho foo()->offsetGet(1); // \"one\"\n?>\n echo (new ArrayObject(explode(\",\", \"zero,one,two\")))->offsetGet(2);\n"
},
{
"answer_id": 267606,
"author": "Jim Nelson",
"author_id": 32168,
"author_profile": "https://Stackoverflow.com/users/32168",
"pm_score": 1,
"selected": false,
"text": "$rand_place = explode(\",\",loadFile(\"csvOf20000places.txt\"));\n$rand_place = $rand_place[rand(0,1000)];\n"
},
{
"answer_id": 267611,
"author": "David",
"author_id": 9908,
"author_profile": "https://Stackoverflow.com/users/9908",
"pm_score": 0,
"selected": false,
"text": " //Grab and load our index\n$index = unserialize(file_get_contents('somefile.ext.ind'));\n//What it looks like\n$index = array( 0 => 83, 1 => 162, 2 => 178, ....);\n\n$fHandle = fopen(\"somefile.ext\",'RB');\n$randPos = rand(0, count($index));\nfseek($fHandle, $index[$randPos]);\n$line = explode(\",\", fgets($fHandle));\n $fHandle = fopen('somefile.ext','rb');\n$index = array();\nfor($i = 0; false !== ($char = fgetc($fHandle)); $i++){\n if($char === \"\\n\") $index[] = $i; \n}\n"
},
{
"answer_id": 267616,
"author": "Stephen Walcher",
"author_id": 25375,
"author_profile": "https://Stackoverflow.com/users/25375",
"pm_score": 1,
"selected": false,
"text": "list($rand_place) = array_slice(explode(',', loadFile(\"csvOf20000places.txt\")), array_rand(explode(',', loadFile(\"csvOf20000places.txt\"))), 1);\n list($rand_place) = array_slice(explode(',', loadFile(\"csvOf20000places.txt\")), {YOUR_NUMBER}, 1);\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34561/"
] |
267,538
|
<p>I would like to implement a telnet server in C. How would I proceed with this? Which RFCs should I look at? This is important to me, and I would appreciate any help.</p>
|
[
{
"answer_id": 271416,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "#include <glib.h>\n#include <gnet.h>\n\nvoid client_connect(GServer G_GNUC_UNUSED *server, GConn *conn, gpointer G_GNUC_UNUSED user_data){\n g_print(\"Connection from %s\\n\", conn->hostname);\n gnet_conn_disconnect(conn);\n gnet_conn_unref(conn); conn = NULL;\n}\n\nint main(void){\n GMainLoop *loop = g_main_loop_new(NULL, FALSE);\n GServer *server;\n gnet_init();\n server = gnet_server_new(NULL, 4000, client_connect, NULL);\n g_main_loop_run(loop);\n g_main_loop_unref(loop); loop = NULL;\n return 0;\n}\n"
},
{
"answer_id": 271475,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 2,
"selected": false,
"text": "stdin stdout $TERM"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,540
|
<p>I've met a really strange problem.</p>
<p>The code is as follow:</p>
<pre><code>::boost::shared_ptr<CQImageFileInfo> pInfo=CQUserViewDataManager::GetInstance()->GetImageFileInfo(nIndex);
Image* pImage=pInfo->m_pThumbnail;
if(pImage==NULL)
pImage=m_pStretchedDefaultThumbImage;
else
{
//
int sourceWidth = pInfo->GetWidth();
int sourceHeight = pInfo->GetHeight();
int destX = 0,
destY = 0;
float nPercent = 0;
float nPercentW = ((float)GetThumbImageWidth()/(float)sourceWidth);;
float nPercentH = ((float)GetThumbImageHeight()/(float)sourceHeight);
if(nPercentH < nPercentW)
{
nPercent = nPercentH;
destX = (int)((GetThumbImageWidth() - (sourceWidth * nPercent))/2);
}
else
{
nPercent = nPercentW;
destY = (int)((GetThumbImageHeight() - (sourceHeight * nPercent))/2);
}
int destWidth = (int)(sourceWidth * nPercent);
int destHeight = (int)(sourceHeight * nPercent);
rcShowImage=CRect(rc.left+destX, rc.top+destY,rc.left+destX+destWidth,rc.top+destY+destHeight);
}
ASSERT(pImage != NULL); // passed assertion...
graphics.DrawImage(pImage,rcShowImage.left,rcShowImage.top,
rcShowImage.Width(),rcShowImage.Height()); // problem happened here.
</code></pre>
<p>I received the following exception:</p>
<pre><code>First-chance exception at 0x004095b0 in ec.exe: 0xC0000005: Access violation reading location 0xfeeefef2.
Unhandled exception at 0x004095b0 in ec.exe: 0xC0000005: Access violation reading location 0xfeeefef2.
</code></pre>
<p>I have checked the <code>pImage</code>, I am sure when <code>graphics.DrawImage</code> is called, it is not <code>NULL</code>.</p>
<ul>
<li>why such a problem happened?</li>
<li>What is <code>0xfeeefef2</code>?</li>
</ul>
|
[
{
"answer_id": 267559,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 0,
"selected": false,
"text": "pImage == NULL rcShowImage"
},
{
"answer_id": 267564,
"author": "Martin Cote",
"author_id": 9936,
"author_profile": "https://Stackoverflow.com/users/9936",
"pm_score": 2,
"selected": false,
"text": "pImage=m_pStretchedDefaultThumbImage;\n"
},
{
"answer_id": 267584,
"author": "bk1e",
"author_id": 8090,
"author_profile": "https://Stackoverflow.com/users/8090",
"pm_score": 4,
"selected": false,
"text": "0xfeeefeee 0xfeeefef2 0xfeeefeee+4"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25749/"
] |
267,578
|
<p>I use ASP.Net and I have a custom 404 page. When user pastes url that is not found it will redirected to the custom 404 page. However google indexes my custom 404 page. Search 404(page not found).</p>
<p>Anyone have solution?</p>
|
[
{
"answer_id": 267708,
"author": "Sean Reilly",
"author_id": 8313,
"author_profile": "https://Stackoverflow.com/users/8313",
"pm_score": 1,
"selected": false,
"text": "<META NAME=\"ROBOTS\" CONTENT=\"NOINDEX\">\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,607
|
<p>I have been given two different Microsoft Word document that my virus scanner has warned me contains macros. These should be simple text files, and the person who sent them doesn't even know what a macro is; they may be a mistake on his part, but they might be signs of a malicious infection. My installation of OpenOffice.org is set not to load macros at all, as I rarely use them, so I am not concerned about the security of my system. What I would like to be able to do is find out what those macros do without exposing my system to any malicious intent from those macros, in order to tell the person who sent me the documents whether or not he is spreading an infection.</p>
|
[
{
"answer_id": 23863755,
"author": "Martin Kealey",
"author_id": 5781773,
"author_profile": "https://Stackoverflow.com/users/5781773",
"pm_score": 1,
"selected": false,
"text": "Tools Macros Organize Macros OpenOffice.org Basic OpenOffice.org Basic Macros Edit"
},
{
"answer_id": 32720772,
"author": "PsychoData",
"author_id": 2238544,
"author_profile": "https://Stackoverflow.com/users/2238544",
"pm_score": 3,
"selected": false,
"text": "Enable Content"
},
{
"answer_id": 41672226,
"author": "Emjay",
"author_id": 4142120,
"author_profile": "https://Stackoverflow.com/users/4142120",
"pm_score": 3,
"selected": false,
"text": ".\n├── [Content_Types].xml\n├── docProps\n│ ├── app.xml\n│ ├── core.xml\n│ └── custom.xml\n├── _rels\n└── word\n ├── document.xml\n ├── fontTable.xml\n ├── _rels\n │ ├── document.xml.rels\n │ └── vbaProject.bin.rels\n ├── settings.xml\n ├── styles.xml\n ├── theme\n │ └── theme1.xml\n ├── vbaData.xml\n ├── vbaProject.bin\n └── webSettings.xml\n"
},
{
"answer_id": 47908674,
"author": "Noelkd",
"author_id": 1663352,
"author_profile": "https://Stackoverflow.com/users/1663352",
"pm_score": 2,
"selected": false,
"text": "python oledump.py \"your_word.doc\" -s a -v\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16398/"
] |
267,609
|
<p>I'd like to know what are the most useful JQuery plugins. I'm particularly interested in those which are likely to be useful in general UI development, such as <a href="http://tablesorter.com" rel="noreferrer">Tablesorter</a>, rather than those which serve uncommon needs.</p>
<p>If you could provide a very brief description of the plugin's purpose, that would be really helpful.</p>
<p>Thanks,
Don</p>
|
[
{
"answer_id": 267626,
"author": "hugoware",
"author_id": 17091,
"author_profile": "https://Stackoverflow.com/users/17091",
"pm_score": 4,
"selected": false,
"text": "var results = $.from(data)\n .ignoreCase()\n .startsWith(\"firstName\",\"m\")\n .or(\"n\")\n .isNot(\"administrator\")\n .orderBy(\"lastName\")\n .select();\n"
},
{
"answer_id": 2792267,
"author": "user335900",
"author_id": 335900,
"author_profile": "https://Stackoverflow.com/users/335900",
"pm_score": 2,
"selected": false,
"text": "alert()"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] |
267,613
|
<p>Im trying to get into some basic JavaFX game development and I'm getting confused with some circle maths.</p>
<p>I have a circle at (x:250, y:250) with a radius of 50.</p>
<p>My objective is to make a smaller circle to be placed on the circumference of the above circle based on the position of the mouse.</p>
<p>Where Im getting confused is with the coordinate space and the Trig behind it all.</p>
<p>My issues come from the fact that the X/Y space on the screen is not centered at 0,0. But the top left of the screen is 0,0 and the bottom right is 500,500.</p>
<p>My calculations are:</p>
<pre><code>var xpos:Number = mouseEvent.getX();
var ypos:Number = mouseEvent.getY();
var center_pos_x:Number = 250;
var center_pos_y:Number = 250;
var length = ypos - center_pos_y;
var height = xpos - center_pos_x;
var angle_deg = Math.toDegrees(Math.atan(height / length));
var angle_rad = Math.toRadians(angle_deg);
var radius = 50;
moving_circ_xpos = (radius * Math.cos(angle_rad)) + center_pos_x;
moving_circ_ypos = (radius * Math.sin(angle_rad)) + center_pos_y;
</code></pre>
<p>I made the app print out the angle (angle_deg) that I have calculated when I move the mouse and my output is below:</p>
<p>When the mouse is (in degrees moving anti-clockwise):</p>
<ul>
<li>directly above the circle and horizontally inline with the center, the angle is -0</li>
<li>to the left and vertically centered, the angle is -90</li>
<li>directly below the circle and horizontally inline with the center, the angle is 0</li>
<li>to the right and vertically centered, the angle is 90</li>
</ul>
<p>So, what can I do to make it 0, 90, 180, 270??</p>
<p>I know it must be something small, but I just cant think of what it is...</p>
<p>Thanks for any help
(and no, this is not an assignment)</p>
|
[
{
"answer_id": 267622,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 3,
"selected": true,
"text": "atan(height/length) atan2 y x"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26310/"
] |
267,615
|
<p>Using jquery how do I focus the first element (edit field, text area, dropdown field, etc)
in the form when the page load?</p>
<p>Something like:</p>
<pre><code>document.forms[0].elements[0].focus();
</code></pre>
<p>but using jquery.</p>
<p>Another requirement, don't focus the first element when the form has class="filter".</p>
|
[
{
"answer_id": 267645,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 6,
"selected": false,
"text": "$('form:not(.filter) :input:visible:enabled:first').focus()\n <input /> <select> <textarea> filter"
},
{
"answer_id": 267646,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": false,
"text": " $(document).ready( function() {\n $('input.js-initial-focus:first').focus(); // choose first just in case\n });\n"
},
{
"answer_id": 268076,
"author": "Zakaria",
"author_id": 3370,
"author_profile": "https://Stackoverflow.com/users/3370",
"pm_score": 6,
"selected": true,
"text": "$(function() {\n $(\"form:not(.filter) :input:visible:enabled:first\").focus();\n});\n $('form :input:first')"
},
{
"answer_id": 2321161,
"author": "stun",
"author_id": 138284,
"author_profile": "https://Stackoverflow.com/users/138284",
"pm_score": 2,
"selected": false,
"text": "function focusFirstFormField() {\n try {\n var selector = $(\"#formid\");\n if (selector.length >= 1 && selector[0] && selector[0].elements && selector[0].elements.length > 0) {\n var elements = selector[0].elements;\n var length = elements.length;\n for (var i = 0; i < length; i++) {\n var elem = elements[i];\n var type = elem.type;\n\n // ignore images, hidden fields, buttons, and submit-buttons\n if (elem.style.display != \"none\" /* check for visible */ && type != \"image\" && type != \"hidden\" && type != \"button\" && type != \"submit\") {\n elem.focus();\n break;\n }\n }\n }\n }\n catch(err) { /* ignore error if any */ }\n}\n"
},
{
"answer_id": 7668717,
"author": "George",
"author_id": 421601,
"author_profile": "https://Stackoverflow.com/users/421601",
"pm_score": 0,
"selected": false,
"text": "$(\":text:visible:enabled:first\").focus();\n $(\":text:visible:enabled:first\").not(\"div .dialog input\").focus();\n"
},
{
"answer_id": 18567102,
"author": "Avinash Saini",
"author_id": 2226601,
"author_profile": "https://Stackoverflow.com/users/2226601",
"pm_score": 2,
"selected": false,
"text": "$(\"form\").find('input[type=text],textarea,select').filter(':visible:first').focus();\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3370/"
] |
267,628
|
<p>I have both Fruityloops and Propellerheads Reason software synths on my Windows PC.</p>
<p>Any way I can get at and script these from either Visual Basic or Python? Or at least send Midi messages to the synths from code?</p>
<p>Update : attempts to use something like a "midi-mapper" (thanks for link MusiGenesis) don't seem to work. I don't think Reason or FL Studio act like standard GM Midi synths.</p>
<p>Update 2 : If you're interested in this question, <a href="https://stackoverflow.com/questions/427037/scripting-lmms-from-python">check out this too</a>.</p>
|
[
{
"answer_id": 2840001,
"author": "Wouter van Nifterick",
"author_id": 38813,
"author_profile": "https://Stackoverflow.com/users/38813",
"pm_score": 2,
"selected": false,
"text": "Your Application Virtual MIDI Port FruityLoops"
},
{
"answer_id": 4439944,
"author": "zslevi",
"author_id": 95899,
"author_profile": "https://Stackoverflow.com/users/95899",
"pm_score": 0,
"selected": false,
"text": "// Insert New\n\nsong.newLane(\"MyMidiLane\", type(\"Midi\"));\nlane = song.getLane(\"MyMidiLane\");\n\npart = lane.newPart( time(\"10.0:000\"), time(\"4.0:000\") );\n\npart.insertNote(note(\"c#3\"), time(\"11.2:000\"), time(\"2:0\"), 120 );\npart.insertNote(note(\"f3\"), time(\"11.3:000\"), time(\"1:0\"), 100 );\npart.insertNote(note(\"g#3\"), time(\"11.3:000\"), time(\"1:0\"), 100 );\npart.insertNote(note(\"b3\"), time(\"11.3:000\"), time(\"0:64\"), 100 );\npart.removeNote(note(\"f3\"), time(\"11.3:000\"));\n\npart = song.newLane(\"MyTextLane\",\ntype(\"Text\")).newPart(time(\"24.0:000\"), time(\"10.0:000\"));\npart.text = \"This is the test text to be inserted.\";\npart.lane.parts[0].remove(); // remove initially inserted text-part \n lane = song.getLane(\"MyMidiLane\");\n// a lane has a fixed instrument assigned\n\n\nlane.parts[0].notes[0].duration=64\nlane.parts[0].notes[1].duration=32\nlane.parts[0].notes[1].startTick=120\n// Parts are blocks of notes that you can drag around together in the Frinika GUI.\n// They're like patterns in trackers.\nfor (i in lane.parts[0].notes){\n println(\"i: \"+i+\", n: \"+noteName(lane.parts[0].notes[i].note));\n println(\"i: \"+i+\", dur: \"+lane.parts[0].notes[i].duration);\n println(\"i: \"+i+\", startT: \"+lane.parts[0].notes[i].startTick);\n} \n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8482/"
] |
267,629
|
<p>What's your experience with <a href="http://www.doctrine-project.org/" rel="noreferrer">doctrine</a>?
I've never been much of an ORM kind of guy, I mostlymanaged with just some basic db abstraction layer like adodb. </p>
<p>But I understood all the concepts and benifits of it. So when a project came along that needed an ORM I thought that I'd give one of the ORM framework a try. </p>
<p>I've to decide between doctrine and propel so I choose doctrine because I didn't want to handle the phing requirement.</p>
<p>I don't know what I did wrong. I came in with the right mindset. And I am by no means a 'junior' php kiddie. But I've been fighting the system each step of the way. There's a lot of documentation but it all feels a little disorganize. And simple stuff like YAML to db table creation just wouldn;t work and just bork out without even an error or anything. A lot of other stuff works a little funky require just that extra bit of tweaking before working.</p>
<p>Maybe I made some soft of stupid newbie assumption here that once I found out what it is I'll have the aha moment. But now I'm totally hating the system.</p>
<p>Is there maybe some tips anyone can give or maybe point me to a good resource on the subject or some authoritative site/person about this? Or maybe just recommend another ORM framework that 'just works"?</p>
|
[
{
"answer_id": 32977773,
"author": "Dennis",
"author_id": 2883328,
"author_profile": "https://Stackoverflow.com/users/2883328",
"pm_score": 3,
"selected": false,
"text": "doctrine orm:validate-schema"
},
{
"answer_id": 37661758,
"author": "Dennis",
"author_id": 2883328,
"author_profile": "https://Stackoverflow.com/users/2883328",
"pm_score": 2,
"selected": false,
"text": "SELECT i, p \nFROM \\Entity\\Item i\nJOIN i.product p\nWHERE ...\n Item Product Item.product_id Product.id Product Product.model Item //SELECT i, p\n$ret[0]->getProduct()->getModel(); \n\n//SELECT i as item, p as product\n$ret[0]['item']->getProduct()->getModel(); \n\n//SELECT i as item, p.model as model\n$ret[0]['model']; \n SELECT"
},
{
"answer_id": 44481910,
"author": "darjus",
"author_id": 1599243,
"author_profile": "https://Stackoverflow.com/users/1599243",
"pm_score": 0,
"selected": false,
"text": " public function countNumberPrintedForCategory(Category $category)\n {\n $conn = $this->getEntityManager()\n ->getConnection();\n $sql = '\n SELECT SUM(fc.numberPrinted) as fortunesPrinted, AVG(fc.numberPrinted) as fortunesAverage, cat.name\n FROM fortune_cookie fc\n INNER JOIN category cat ON cat.id = fc.category_id\n WHERE fc.category_id = :category\n ';\n $stmt = $conn->prepare($sql);\n $stmt->execute(array('category' => $category->getId()));\n return $stmt->fetch();\n... lines 30 - 37\n }\n"
},
{
"answer_id": 51878223,
"author": "Peter Matisko",
"author_id": 7381430,
"author_profile": "https://Stackoverflow.com/users/7381430",
"pm_score": 3,
"selected": false,
"text": "$product->save() $mapper->save($product) $model $modelMap $modelMapper->store($model)"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2976/"
] |
267,643
|
<p>Does anyone know how to generate SQL scripts from a query?</p>
<p>For example, </p>
<ol>
<li>Script some tables.</li>
<li>Do custom action 1.</li>
<li>Script the views. </li>
<li>Do custom action 2.</li>
<li>Etc.</li>
</ol>
|
[
{
"answer_id": 267831,
"author": "Alexander Prokofyev",
"author_id": 11256,
"author_profile": "https://Stackoverflow.com/users/11256",
"pm_score": 0,
"selected": false,
"text": "select 'UPDATE '+table_name+ ' SET description=''(new!) ''+description WHERE description_date>''2008-11-01''' \n from information_schema.tables where table_name like '%Description'\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,658
|
<p>I have the following table schema;</p>
<pre><code>CREATE TABLE `db1`.`sms_queue` (
`Id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`Message` VARCHAR(160) NOT NULL DEFAULT 'Unknown Message Error',
`CurrentState` VARCHAR(10) NOT NULL DEFAULT 'None',
`Phone` VARCHAR(14) DEFAULT NULL,
`Created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`LastUpdated` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,
`TriesLeft` tinyint NOT NULL DEFAULT 3,
PRIMARY KEY (`Id`)
)
ENGINE = InnoDB;
</code></pre>
<p>It fails with the following error:</p>
<pre><code>ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause.
</code></pre>
<p>My question is, can I have both of those fields? or do I have to manually set a LastUpdated field during each transaction?</p>
|
[
{
"answer_id": 807613,
"author": "Bogdan Gusiev",
"author_id": 91610,
"author_profile": "https://Stackoverflow.com/users/91610",
"pm_score": 7,
"selected": false,
"text": "create table test_table( \n id integer not null auto_increment primary key, \n stamp_created timestamp default '0000-00-00 00:00:00', \n stamp_updated timestamp default now() on update now() \n); \n null insert mysql> insert into test_table(stamp_created, stamp_updated) values(null, null); \nQuery OK, 1 row affected (0.06 sec)\n\nmysql> select * from test_table; \n+----+---------------------+---------------------+ \n| id | stamp_created | stamp_updated |\n+----+---------------------+---------------------+\n| 2 | 2009-04-30 09:44:35 | 2009-04-30 09:44:35 |\n+----+---------------------+---------------------+\n2 rows in set (0.00 sec) \n\nmysql> update test_table set id = 3 where id = 2; \nQuery OK, 1 row affected (0.05 sec) Rows matched: 1 Changed: 1 Warnings: 0 \n\nmysql> select * from test_table;\n+----+---------------------+---------------------+\n| id | stamp_created | stamp_updated | \n+----+---------------------+---------------------+ \n| 3 | 2009-04-30 09:44:35 | 2009-04-30 09:46:59 | \n+----+---------------------+---------------------+ \n2 rows in set (0.00 sec) \n"
},
{
"answer_id": 6470406,
"author": "webkraller",
"author_id": 814368,
"author_profile": "https://Stackoverflow.com/users/814368",
"pm_score": 5,
"selected": false,
"text": "CREATE TRIGGER <trigger_name> BEFORE INSERT ON <table_name> FOR EACH ROW SET NEW.<timestamp_field> = CURRENT_TIMESTAMP;\n"
},
{
"answer_id": 16414306,
"author": "alien",
"author_id": 1611949,
"author_profile": "https://Stackoverflow.com/users/1611949",
"pm_score": 5,
"selected": false,
"text": "CREATE TABLE `entity` (\n `entityid` int(11) NOT NULL AUTO_INCREMENT,\n `createDate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n `lastModified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n `name` varchar(255) DEFAULT NULL,\n `comment` text,\n PRIMARY KEY (`entityid`),\n)\n DELIMITER ;;\nCREATE trigger entityinsert BEFORE INSERT ON entity FOR EACH ROW BEGIN SET NEW.createDate=IF(ISNULL(NEW.createDate) OR NEW.createDate='0000-00-00 00:00:00', CURRENT_TIMESTAMP, IF(NEW.createDate<CURRENT_TIMESTAMP, NEW.createDate, CURRENT_TIMESTAMP));SET NEW.lastModified=NEW.createDate; END;;\nDELIMITER ;\nCREATE trigger entityupdate BEFORE UPDATE ON entity FOR EACH ROW SET NEW.lastModified=IF(NEW.lastModified<OLD.lastModified, OLD.lastModified, CURRENT_TIMESTAMP);\n"
},
{
"answer_id": 19984380,
"author": "Kingz",
"author_id": 1642266,
"author_profile": "https://Stackoverflow.com/users/1642266",
"pm_score": 2,
"selected": false,
"text": "DROP TABLE IF EXISTS `provider_org_group` ;\nCREATE TABLE IF NOT EXISTS `provider_org_group` (\n `id` INT NOT NULL,\n `name` VARCHAR(100) NOT NULL,\n `type` VARCHAR(100) NULL,\n `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n `insert_src_ver_id` INT NULL,\n `updated` TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP,\n `update_src_ver_id` INT NULL,\n `version` INT NULL,\n PRIMARY KEY (`id`),\n UNIQUE INDEX `id_UNIQUE` (`id` ASC),\n UNIQUE INDEX `name_UNIQUE` (`name` ASC))\nENGINE = InnoDB;\n ERROR 1293 (HY000): Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause\n 0 row(s) affected 0.093 sec\n"
},
{
"answer_id": 20347643,
"author": "Shaheen Ghiassy",
"author_id": 1179897,
"author_profile": "https://Stackoverflow.com/users/1179897",
"pm_score": 5,
"selected": false,
"text": "create table tweet ( \n id integer not null auto_increment primary key, \n stamp_created timestamp default now(), \n stamp_updated timestamp default now() on update now(),\n message varchar(163)\n)\n"
},
{
"answer_id": 35291337,
"author": "user5903005",
"author_id": 5903005,
"author_profile": "https://Stackoverflow.com/users/5903005",
"pm_score": 2,
"selected": false,
"text": "create table test_table( \nid integer not null auto_increment primary key, \nstamp_created timestamp default '0000-00-00 00:00:00', \nstamp_updated timestamp default now() on update now() \n); \n"
},
{
"answer_id": 50190396,
"author": "Josua Marcel C",
"author_id": 1562112,
"author_profile": "https://Stackoverflow.com/users/1562112",
"pm_score": 2,
"selected": false,
"text": "CREATE TABLE test_table( \n id integer not null auto_increment primary key, \n stamp_created TIMESTAMP DEFAULT now(), \n stamp_updated TIMESTAMP DEFAULT '0000-00-00 00:00:00' ON UPDATE now() \n); \n stamp_created now() stamp_updated '0000-00-00 00:00:00'"
},
{
"answer_id": 50860455,
"author": "Ioannis Chrysochos",
"author_id": 5796809,
"author_profile": "https://Stackoverflow.com/users/5796809",
"pm_score": 2,
"selected": false,
"text": "Posts modified_at created_at"
},
{
"answer_id": 70290588,
"author": "Flash Noob",
"author_id": 12106367,
"author_profile": "https://Stackoverflow.com/users/12106367",
"pm_score": 2,
"selected": false,
"text": " create table users( \n id integer not null auto_increment primary key, \n created_date timestamp default now(), \n modified_date timestamp default now() on update now() \n ); \n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264/"
] |
267,672
|
<p>I am trying to use native windows API with Qt using mingw toolset. There are link problems with some functions. What happens? Is this a bug with mingw name mangling?</p>
<pre><code>#ifdef Q_WS_WIN
HWND hwnd = QWidget::winId();
HDC hdcEMF = CreateEnhMetaFile(NULL, NULL, NULL, NULL ) ;
Rectangle(hdcEMF,100,100,200,200);
HENHMETAFILE hemf = CloseEnhMetaFile(hdcEMF);
OpenClipboard(hwnd);
EmptyClipboard();
SetClipboardData(CF_ENHMETAFILE,hemf);
CloseClipboard();
#else </code></pre>
<p>The errors:</p>
<p>undefined reference to `CreateEnhMetaFileW@16'</p>
<p>undefined reference to `Rectangle@20'</p>
<p>undefined reference to `CloseEnhMetaFile@4'</p>
|
[
{
"answer_id": 267678,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 3,
"selected": true,
"text": "CreateEnhMetaFileW() CloseEnhMetaFile() -lgdi32 -L/path/to/folder/containing/the/library -lgdi32"
},
{
"answer_id": 3670693,
"author": "torn",
"author_id": 340318,
"author_profile": "https://Stackoverflow.com/users/340318",
"pm_score": 2,
"selected": false,
"text": "#include <qt_windows.h>\n LIBS += -luser32 -lshell32 -lgdi32\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19884/"
] |
267,674
|
<p>Is it possible to inspect the return value of a function in gdb assuming the return value is <strong>not</strong> assigned to a variable?</p>
|
[
{
"answer_id": 267682,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 6,
"selected": false,
"text": "EAX print $eax long long double structs classes"
},
{
"answer_id": 267687,
"author": "hark",
"author_id": 34826,
"author_profile": "https://Stackoverflow.com/users/34826",
"pm_score": 8,
"selected": true,
"text": "int fun() {\n return 42;\n}\n\nint main( int argc, char *v[] ) {\n fun();\n return 0;\n}\n (gdb) r\nStarting program: /usr/home/hark/a.out \n\nBreakpoint 1, fun () at test.c:2\n2 return 42;\n(gdb) finish\nRun till exit from #0 fun () at test.c:2\nmain () at test.c:7\n7 return 0;\nValue returned is $1 = 42\n(gdb) \n finish fin f frame"
},
{
"answer_id": 1123107,
"author": "RandomNickName42",
"author_id": 67819,
"author_profile": "https://Stackoverflow.com/users/67819",
"pm_score": 3,
"selected": false,
"text": "gdb ls\nThis GDB was configured as \"ppc64-yellowdog-linux-gnu\"...\n(no debugging symbols found)\nUsing host libthread_db library \"/lib64/libthread_db.so.1\".\n\n(gdb) break __libc_start_main\nBreakpoint 1 at 0x10013cb0\n(gdb) r\nStarting program: /bin/ls\n(no debugging symbols found)\n(no debugging symbols found)\n(no debugging symbols found)\n(no debugging symbols found)\n(no debugging symbols found)\n(no debugging symbols found)\nBreakpoint 1 at 0xfdfed3c\n(no debugging symbols found)\n[Thread debugging using libthread_db enabled]\n[New Thread 4160418656 (LWP 10650)]\n(no debugging symbols found)\n(no debugging symbols found)\n[Switching to Thread 4160418656 (LWP 10650)]\n\nBreakpoint 1, 0x0fdfed3c in __libc_start_main () from /lib/libc.so.6\n(gdb) info frame\nStack level 0, frame at 0xffd719a0:\n pc = 0xfdfed3c in __libc_start_main; saved pc 0x0\n called by frame at 0x0\n Arglist at 0xffd71970, args:\n Locals at 0xffd71970, Previous frame's sp is 0xffd719a0\n Saved registers:\n r24 at 0xffd71980, r25 at 0xffd71984, r26 at 0xffd71988, r27 at 0xffd7198c,\n r28 at 0xffd71990, r29 at 0xffd71994, r30 at 0xffd71998, r31 at 0xffd7199c,\n pc at 0xffd719a4, lr at 0xffd719a4\n(gdb) frame 0\n#0 0x0fdfed3c in __libc_start_main () from /lib/libc.so.6\n(gdb) info fr\nStack level 0, frame at 0xffd719a0:\n pc = 0xfdfed3c in __libc_start_main; saved pc 0x0\n called by frame at 0x0\n Arglist at 0xffd71970, args:\n Locals at 0xffd71970, Previous frame's sp is 0xffd719a0\n Saved registers:\n r24 at 0xffd71980, r25 at 0xffd71984, r26 at 0xffd71988, r27 at 0xffd7198c,\n r28 at 0xffd71990, r29 at 0xffd71994, r30 at 0xffd71998, r31 at 0xffd7199c,\n pc at 0xffd719a4, lr at 0xffd719a4\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11688/"
] |
267,685
|
<p>This question is regarding the performance issue in Mac OS X</p>
<p>Canvas3D object is embedded in a JPanel; then the panel is integrated with the rest of the Swing-built application. Within that Canvas I am rendering a simple cube by applying
certain transformations. At the initial launch It works fine. But when i try to resize the window or perform some operations on vertical or horizontal split bar buttons.Swing components take certain time to appear on the screen. A flashy white coloured thing appears first then swing components will appear? ( Totally saying flickering kind of stuff will happen). Is there any to solve this issue? </p>
<p>Kindly help me in this regard.</p>
<p>J3DSwinger</p>
|
[
{
"answer_id": 267682,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 6,
"selected": false,
"text": "EAX print $eax long long double structs classes"
},
{
"answer_id": 267687,
"author": "hark",
"author_id": 34826,
"author_profile": "https://Stackoverflow.com/users/34826",
"pm_score": 8,
"selected": true,
"text": "int fun() {\n return 42;\n}\n\nint main( int argc, char *v[] ) {\n fun();\n return 0;\n}\n (gdb) r\nStarting program: /usr/home/hark/a.out \n\nBreakpoint 1, fun () at test.c:2\n2 return 42;\n(gdb) finish\nRun till exit from #0 fun () at test.c:2\nmain () at test.c:7\n7 return 0;\nValue returned is $1 = 42\n(gdb) \n finish fin f frame"
},
{
"answer_id": 1123107,
"author": "RandomNickName42",
"author_id": 67819,
"author_profile": "https://Stackoverflow.com/users/67819",
"pm_score": 3,
"selected": false,
"text": "gdb ls\nThis GDB was configured as \"ppc64-yellowdog-linux-gnu\"...\n(no debugging symbols found)\nUsing host libthread_db library \"/lib64/libthread_db.so.1\".\n\n(gdb) break __libc_start_main\nBreakpoint 1 at 0x10013cb0\n(gdb) r\nStarting program: /bin/ls\n(no debugging symbols found)\n(no debugging symbols found)\n(no debugging symbols found)\n(no debugging symbols found)\n(no debugging symbols found)\n(no debugging symbols found)\nBreakpoint 1 at 0xfdfed3c\n(no debugging symbols found)\n[Thread debugging using libthread_db enabled]\n[New Thread 4160418656 (LWP 10650)]\n(no debugging symbols found)\n(no debugging symbols found)\n[Switching to Thread 4160418656 (LWP 10650)]\n\nBreakpoint 1, 0x0fdfed3c in __libc_start_main () from /lib/libc.so.6\n(gdb) info frame\nStack level 0, frame at 0xffd719a0:\n pc = 0xfdfed3c in __libc_start_main; saved pc 0x0\n called by frame at 0x0\n Arglist at 0xffd71970, args:\n Locals at 0xffd71970, Previous frame's sp is 0xffd719a0\n Saved registers:\n r24 at 0xffd71980, r25 at 0xffd71984, r26 at 0xffd71988, r27 at 0xffd7198c,\n r28 at 0xffd71990, r29 at 0xffd71994, r30 at 0xffd71998, r31 at 0xffd7199c,\n pc at 0xffd719a4, lr at 0xffd719a4\n(gdb) frame 0\n#0 0x0fdfed3c in __libc_start_main () from /lib/libc.so.6\n(gdb) info fr\nStack level 0, frame at 0xffd719a0:\n pc = 0xfdfed3c in __libc_start_main; saved pc 0x0\n called by frame at 0x0\n Arglist at 0xffd71970, args:\n Locals at 0xffd71970, Previous frame's sp is 0xffd719a0\n Saved registers:\n r24 at 0xffd71980, r25 at 0xffd71984, r26 at 0xffd71988, r27 at 0xffd7198c,\n r28 at 0xffd71990, r29 at 0xffd71994, r30 at 0xffd71998, r31 at 0xffd7199c,\n pc at 0xffd719a4, lr at 0xffd719a4\n"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
267,693
|
<p>I have a .NET assembly that (for reasons outside my control) <em>must</em> be in the GAC. However, the same assembly is used by another program, which has a its own copy of an older version of the same assembly. It must use its own copy and not whatever is in the GAC. Proper versioning is probably more hassle than it's worth in this case, for reasons I won't go into. My questions is: <strong>is there anyway to tell .NET: just use THIS DLL, right here in this directory - ignore whatever you find in the GAC or anywhere else</strong>.</p>
|
[
{
"answer_id": 267729,
"author": "Corbin March",
"author_id": 7625,
"author_profile": "https://Stackoverflow.com/users/7625",
"pm_score": 6,
"selected": false,
"text": "<runtime>\n <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n <dependentAssembly>\n <assemblyIdentity name=\"YourAssembly\" publicKeyToken=\"AAAAAAAAAAAA\" culture=\"neutral\"/>\n <bindingRedirect oldVersion=\"0.0.0.0-5.2.1.0\" newVersion=\"5.0.8.1\"/>\n </dependentAssembly>\n </assemblyBinding>\n</runtime>\n"
},
{
"answer_id": 25195931,
"author": "dasons",
"author_id": 2728644,
"author_profile": "https://Stackoverflow.com/users/2728644",
"pm_score": 2,
"selected": false,
"text": "ildasm ilasm"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20336/"
] |
267,704
|
<p>Is there an easy way to modify this code so that the target URL opens in the SAME window?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><a href="javascript:q=(document.location.href);void(open('http://example.com/submit.php?url='+escape(q),'','resizable,location,menubar,toolbar,scrollbars,status'));">click here</a>``</code></pre>
</div>
</div>
</p>
|
[
{
"answer_id": 267705,
"author": "Stephen Walcher",
"author_id": 25375,
"author_profile": "https://Stackoverflow.com/users/25375",
"pm_score": 3,
"selected": false,
"text": "<a href=\"javascript:;\" onclick=\"window.location = 'http://example.com/submit.php?url=' + escape(document.location.href);'\">Go</a>;\n"
},
{
"answer_id": 267712,
"author": "keparo",
"author_id": 19468,
"author_profile": "https://Stackoverflow.com/users/19468",
"pm_score": 7,
"selected": true,
"text": "<a href=\"javascript:q=(document.location.href);void(open('http://example.com/submit.php?url='+escape(q),'_self','resizable,location,menubar,toolbar,scrollbars,status'));\">click here</a>\n"
},
{
"answer_id": 267775,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 1,
"selected": false,
"text": "$(function() {\n $('a[href$=\"url=\"]') // all links whose href ends in \"url=\"\n .each(function(i, el) {\n this.href += escape(document.location.href);\n })\n ;\n});\n <a href=\"http://example.com/submit.php?url=\">...</a>\n"
},
{
"answer_id": 6747873,
"author": "Valentine Nzekwe",
"author_id": 852055,
"author_profile": "https://Stackoverflow.com/users/852055",
"pm_score": 2,
"selected": false,
"text": " $(this).click(function (j) {\n var href = ($(this).attr('href'));\n window.location = href;\n return true;\n"
},
{
"answer_id": 7181778,
"author": "parwaze",
"author_id": 910527,
"author_profile": "https://Stackoverflow.com/users/910527",
"pm_score": 6,
"selected": false,
"text": "<script type=\"text/javascript\">\nwindow.open ('YourNewPage.htm','_self',false)\n</script>\n"
},
{
"answer_id": 36172829,
"author": "Felceris Juozas",
"author_id": 5665432,
"author_profile": "https://Stackoverflow.com/users/5665432",
"pm_score": 2,
"selected": false,
"text": "<button name=\"redirect\" onClick=\"redirect()\">button name</button>\n<script type=\"text/javascript\">\nfunction redirect(){\nvar url = \"http://www.google.com\";\nwindow.open(url, '_top');\n}\n</script>\n"
},
{
"answer_id": 55719795,
"author": "Kamil Kiełczewski",
"author_id": 860099,
"author_profile": "https://Stackoverflow.com/users/860099",
"pm_score": 0,
"selected": false,
"text": "<a href=\"#\" \n onclick=\"location='http://example.com/submit.php?url='+escape(location)\"\n >click here</a>"
}
] |
2008/11/06
|
[
"https://Stackoverflow.com/questions/267704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34964/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.