qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
15,350 | <p>After watching every possible YouTube video on the subject and reading any source available, and although I'm a PhD and quite computer savvy, I still can't make my Anet A6 (no probe) behave in terms of Z offset. I upgraded to silicone bed buffers instead of the stock springs; now my bed is ~5 mm raised, and I don't ... | [
{
"answer_id": 15353,
"author": "octopus8",
"author_id": 26170,
"author_profile": "https://3dprinting.stackexchange.com/users/26170",
"pm_score": 0,
"selected": false,
"text": "<p>Setting any offset will move the whole print ("effectively shifts the coordinate space") - so you ... | 2021/01/17 | [
"https://3dprinting.stackexchange.com/questions/15350",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/26360/"
] | After watching every possible YouTube video on the subject and reading any source available, and although I'm a PhD and quite computer savvy, I still can't make my Anet A6 (no probe) behave in terms of Z offset. I upgraded to silicone bed buffers instead of the stock springs; now my bed is ~5 mm raised, and I don't kno... | So the new silicone buffers raised the bed by 5 mm? When this happens, you should raise the endstop also with 5 mm. Else the printer will go down to the Z endstop that is effectively 5 mm below the level of the bed. I guess the buffers cannot be compressed by 5 mm, so you need to move the endstop up to the level your b... |
15,356 | <p>I just bought an Ender 3 Max and from the start I knew something was wrong. I figured out the problem: it is with the first few millimeters of the Z axis movement.</p>
<p>I turn on my 3D printer, go to prepare, move axis, move Z, move 1 mm.</p>
<p>Then I tell the printer to move up 1 mm. But in reality it only moves... | [
{
"answer_id": 15360,
"author": "0scar",
"author_id": 5740,
"author_profile": "https://3dprinting.stackexchange.com/users/5740",
"pm_score": 2,
"selected": false,
"text": "<p>Your printer probably has an issue with binding in the lower region (binding means extra friction possibly causin... | 2021/01/18 | [
"https://3dprinting.stackexchange.com/questions/15356",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/26364/"
] | I just bought an Ender 3 Max and from the start I knew something was wrong. I figured out the problem: it is with the first few millimeters of the Z axis movement.
I turn on my 3D printer, go to prepare, move axis, move Z, move 1 mm.
Then I tell the printer to move up 1 mm. But in reality it only moves up 0.3 mm. I t... | Your printer probably has an issue with binding in the lower region (binding means extra friction possibly causing the Z stepper to skip steps). Disconnect the lead screw an manually move the X gantry up and down. If there is binding, you need to find why this happens, with the unfortunate design of the Ender, many peo... |
15,421 | <p>I was printing an object and it started to drag so I stopped it.</p>
<p>Went to move the Z-axis up so I could clear the bed and Z-axis would not budge.
I switched the printer off and manually turned the motors to get the Z up.
Cleared the bed, switched on and homed the printer. When it came to home the Z, BLTouch de... | [
{
"answer_id": 15422,
"author": "dandavis",
"author_id": 10437,
"author_profile": "https://3dprinting.stackexchange.com/users/10437",
"pm_score": 3,
"selected": true,
"text": "<p>extruder clicking means you're getting backed up, grinding.</p>\n<ul>\n<li>Make the hotend hotter so you can ... | 2021/01/24 | [
"https://3dprinting.stackexchange.com/questions/15421",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/23645/"
] | I was printing an object and it started to drag so I stopped it.
Went to move the Z-axis up so I could clear the bed and Z-axis would not budge.
I switched the printer off and manually turned the motors to get the Z up.
Cleared the bed, switched on and homed the printer. When it came to home the Z, BLTouch deployed an... | extruder clicking means you're getting backed up, grinding.
* Make the hotend hotter so you can melt filament 3X faster than expected; most materials have quite a range; aim high.
* Slow down the cooling fan; a lot of them can cool the hotend.
* You have a silicone boot on the nozzle? that will help some.
* Use a larg... |
15,456 | <p>I have an Ender 5 with an auto bed leveling sensor (TRU-LEV 600).</p>
<p>It is working fine, however, as the sensor probes the bed, the nozzle and the bed cool down and are not staying heated as it is getting the points, even though they were heated up in the first place.</p>
<p>How do I stop the bed and hotend from... | [
{
"answer_id": 15460,
"author": "octopus8",
"author_id": 26170,
"author_profile": "https://3dprinting.stackexchange.com/users/26170",
"pm_score": 1,
"selected": false,
"text": "<p>For Marlin firmware, you should <strong>check the setting <code>PROBING_HEATERS_OFF</code></strong> in <em>C... | 2021/01/26 | [
"https://3dprinting.stackexchange.com/questions/15456",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/25241/"
] | I have an Ender 5 with an auto bed leveling sensor (TRU-LEV 600).
It is working fine, however, as the sensor probes the bed, the nozzle and the bed cool down and are not staying heated as it is getting the points, even though they were heated up in the first place.
How do I stop the bed and hotend from cooling down w... | For Marlin firmware, you should **check the setting `PROBING_HEATERS_OFF`** in *Configuration.h* file:
```
//#define PROBING_HEATERS_OFF // Turn heaters off when probing
#if ENABLED(PROBING_HEATERS_OFF)
//#define WAIT_FOR_BED_HEATER // Wait for bed to heat back up between probes (to improve accuracy)
#endi... |
15,816 | <p>I am building a 3D printer from scratch, the bed will only move on Z and the head will stay at the top of the printer and move X and Y.</p>
<p>How do I modify the Marlin firmware to have the bed lower as it prints instead of lift like most printers.</p>
| [
{
"answer_id": 15819,
"author": "Trish",
"author_id": 8884,
"author_profile": "https://3dprinting.stackexchange.com/users/8884",
"pm_score": 0,
"selected": false,
"text": "<p>To understand normal commands from a basic printer slicer, all movement commands in g-code are written to be away... | 2021/03/08 | [
"https://3dprinting.stackexchange.com/questions/15816",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/27229/"
] | I am building a 3D printer from scratch, the bed will only move on Z and the head will stay at the top of the printer and move X and Y.
How do I modify the Marlin firmware to have the bed lower as it prints instead of lift like most printers. | You can control in Marlin what the direction of the stepper motor is, e.g. my Hypercube CoreXY printer (which has a similar setup like you described) has the following set (in the Marlin [`Configuration.h`](https://github.com/MarlinFirmware/Marlin/blob/2.0.x/Marlin/Configuration.h) file) to ensure the platform raises w... |
15,954 | <p>I've updated my Ender 3 with V4.2.7 mainboard, BLTouch and 400XL kit (extends the capabilities of your Creality Ender 3 3D Printer to a 400 mm X, 400 mm Y and a 500 mm Z printing platform). Now I need to update the firmware. YouTube did not provide any help: i.e.: out of date, so cryptic as to be unusable. Marlin &a... | [
{
"answer_id": 15956,
"author": "Joel Huebner",
"author_id": 15005,
"author_profile": "https://3dprinting.stackexchange.com/users/15005",
"pm_score": 1,
"selected": false,
"text": "<p>I've done the board upgrade on my Ender 3 Pro. As I've read the BLTouch is easy to install. I'd go over ... | 2021/03/26 | [
"https://3dprinting.stackexchange.com/questions/15954",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/27509/"
] | I've updated my Ender 3 with V4.2.7 mainboard, BLTouch and 400XL kit (extends the capabilities of your Creality Ender 3 3D Printer to a 400 mm X, 400 mm Y and a 500 mm Z printing platform). Now I need to update the firmware. YouTube did not provide any help: i.e.: out of date, so cryptic as to be unusable. Marlin & Cre... | Without knowing exactly which Youtube videos you've looked at, I think where I would start is by downloading the latest Marlin Fimrware and configuration files for the Ender 3 with 4.2.7 board:
[Latest Release of Marlin Firmware on Github](https://github.com/MarlinFirmware/Marlin/archive/2.0.x.zip)
[Configuration Fil... |
16,113 | <p>My custom 3D printer prints everything inverted. I guess this is a homing problem as the motor moves in correct direction.</p>
<p>In Pronterface,</p>
<ul>
<li>if I press -Y — bed moves forward (towards the Y endstop)</li>
<li>if I press +Y — bed moves backward (away from Y endstop)</li>
<li>if I press -X — hotend mo... | [
{
"answer_id": 16104,
"author": "Rykara",
"author_id": 16811,
"author_profile": "https://3dprinting.stackexchange.com/users/16811",
"pm_score": 3,
"selected": true,
"text": "<h1>Heater polarity doesn't matter</h1>\n<p>The heater cartridges are just large resistors and so polarity is irre... | 2021/04/17 | [
"https://3dprinting.stackexchange.com/questions/16113",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/27919/"
] | My custom 3D printer prints everything inverted. I guess this is a homing problem as the motor moves in correct direction.
In Pronterface,
* if I press -Y — bed moves forward (towards the Y endstop)
* if I press +Y — bed moves backward (away from Y endstop)
* if I press -X — hotend moves left (towards the X endstop)
... | Heater polarity doesn't matter
==============================
The heater cartridges are just large resistors and so polarity is irrelevant. Either can be positive or negative.
You can extend the leads by cutting and splicing in ~20 gauge wires\* to a two pin JST connector line you suggest.
---
\*At 24 volts and 30 ... |
16,210 | <p>My Ender 5 Plus (original) does not perform leveling.</p>
<p>After the self-leveling command, the Z axis only descends.
I have already exchanged the BLTouch three times, and the problem remains unchanged.</p>
<p>I bought my E5P in December, in America, to bring it to Brazil, I had to completely dismantle it.</p>
<p>... | [
{
"answer_id": 16365,
"author": "Mr Dean E Sarelius",
"author_id": 28536,
"author_profile": "https://3dprinting.stackexchange.com/users/28536",
"pm_score": 1,
"selected": false,
"text": "<p>I had the same problem with my Ender 5 Plus.</p>\n<p>There is a small set screw at the top of the ... | 2021/04/28 | [
"https://3dprinting.stackexchange.com/questions/16210",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/28103/"
] | My Ender 5 Plus (original) does not perform leveling.
After the self-leveling command, the Z axis only descends.
I have already exchanged the BLTouch three times, and the problem remains unchanged.
I bought my E5P in December, in America, to bring it to Brazil, I had to completely dismantle it.
Machine reassembled, ... | I had the same problem with my Ender 5 Plus.
There is a small set screw at the top of the BLTouch you will need to tighten this in to adjust the location of the sensor pin. Keep screwing it more and more until you see it initialize reliably that is it should move out and back twice to initialize.
When the BLTouch ini... |
16,279 | <p><strong>My setup</strong></p>
<ul>
<li>Ender 3</li>
<li>Creality glass bed</li>
<li>Creality 3D BL Touch auto bed levelling kit v1</li>
<li>Creality 3D silent mainboard v4.2.7</li>
<li>OctoPrint running on a Raspberry Pi 4 connected over USB (with the 5 V pin covered with a piece of tape to prevent powering the main... | [
{
"answer_id": 18472,
"author": "Trimsley",
"author_id": 32131,
"author_profile": "https://3dprinting.stackexchange.com/users/32131",
"pm_score": 0,
"selected": false,
"text": "<p>I had the exact same issue as you and had done all the fixes you mentioned. The only thing that solved it fo... | 2021/05/12 | [
"https://3dprinting.stackexchange.com/questions/16279",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/28336/"
] | **My setup**
* Ender 3
* Creality glass bed
* Creality 3D BL Touch auto bed levelling kit v1
* Creality 3D silent mainboard v4.2.7
* OctoPrint running on a Raspberry Pi 4 connected over USB (with the 5 V pin covered with a piece of tape to prevent powering the mainboard)
**Problem**
Despite starting with `G28` & `G2... | Had similar problems. I even did a 10x10 grid just to find out that my printing bed wasn't actually flat.
It actually had dips in it.
I would have to look up the command, but I actually just lowered the nozzle by 0.050 mm at a time. Eventually it got too low, and then I backed it off in even smaller increments.
I al... |
16,546 | <p>I have a Tevo Flash. Normally, I don't care about perpendicularity with respect to the table. But now I have a 5" disc on a ball bearing, held by a 3D printed tube with a flat bottom. If the tube's axis is not 100 % perpendicular to the bottom, the disc, when spun, wobbles at the edge: ~1/8".</p>
<p><a hre... | [
{
"answer_id": 16550,
"author": "R.. GitHub STOP HELPING ICE",
"author_id": 11157,
"author_profile": "https://3dprinting.stackexchange.com/users/11157",
"pm_score": 0,
"selected": false,
"text": "<p>If you've measured the frame and it's not square, that's almost surely your problem and y... | 2021/06/17 | [
"https://3dprinting.stackexchange.com/questions/16546",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/14316/"
] | I have a Tevo Flash. Normally, I don't care about perpendicularity with respect to the table. But now I have a 5" disc on a ball bearing, held by a 3D printed tube with a flat bottom. If the tube's axis is not 100 % perpendicular to the bottom, the disc, when spun, wobbles at the edge: ~1/8".
[*:
>
> Note: this has nothing to do with bed leveling. The bed is level, the printer has a BLTouch.
>
>
>
[Having a BLTouch doesn't imply the bed is level!](/a/16605) The bed is level when the nozzle moves in the same plane pa... |
17,853 | <p>I'm just learning how to use a 3D printer, I have an Anycubic Mega Zero 2.0.</p>
<p>When I start printing the PLA filament doesn't want to adhere very well. I have leveled it out and all of my corners on my test print adhere well. However, when I go to print anything besides the test print I get basically a small be... | [
{
"answer_id": 17854,
"author": "0scar",
"author_id": 5740,
"author_profile": "https://3dprinting.stackexchange.com/users/5740",
"pm_score": 2,
"selected": false,
"text": "<p>If you look at the multiple lines of the skirt, you see that none of the printed lines are touching the other lai... | 2021/08/05 | [
"https://3dprinting.stackexchange.com/questions/17853",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/30634/"
] | I'm just learning how to use a 3D printer, I have an Anycubic Mega Zero 2.0.
When I start printing the PLA filament doesn't want to adhere very well. I have leveled it out and all of my corners on my test print adhere well. However, when I go to print anything besides the test print I get basically a small bead - it d... | If you look at the multiple lines of the skirt, you see that none of the printed lines are touching the other laid down lines. This is an indication for under extrusion or a too large of a gap between the nozzle and the bed (or both). Considering you are talking about a bead/drop/blob of hot filament not adhering to th... |
18,135 | <p>I'm trying to 3D print a lattice work or truss, basically some beams forming a rectangle and additional beams forming the diagonals and where those beams cross, they should be fused. So, something like this:</p>
<p><a href="https://i.stack.imgur.com/gdKj1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.img... | [
{
"answer_id": 18136,
"author": "fred_dot_u",
"author_id": 854,
"author_profile": "https://3dprinting.stackexchange.com/users/854",
"pm_score": 1,
"selected": false,
"text": "<p>If on even layers, the routing is in one direction and on odd layers, the routing is the opposite diagonal, yo... | 2021/09/25 | [
"https://3dprinting.stackexchange.com/questions/18135",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/31349/"
] | I'm trying to 3D print a lattice work or truss, basically some beams forming a rectangle and additional beams forming the diagonals and where those beams cross, they should be fused. So, something like this:
[](https://i.stack.imgur.com/gdKj1.jpg)
The problem is t... | Yes you can!
------------
To have stronger prints you would have to choose the correct direction of filament deposition paths/traces. This answer demonstrates changing the direction of the filament path in Ultimaker Cura slicer.
To do this, it requires some tinkering of your model and choosing the correct slicer para... |
18,207 | <p>I bought an Ender 3 V2 printer and printed successfully with PLA and PLA+. Ender 3 V2 is rated at <= 250 °C but when I set temperature above 200 °C to print to PLA+, I get an error message "Nozzle is too lowperature" and the printer freezes (the term lowperature is actual and not a typo error).</p>
<p>I... | [
{
"answer_id": 18213,
"author": "Proxy303",
"author_id": 28485,
"author_profile": "https://3dprinting.stackexchange.com/users/28485",
"pm_score": 2,
"selected": false,
"text": "<p>This sounds like a bad thermistor. Try replacing the head thermistor, see if this fixes it.</p>\n<p>As for t... | 2021/10/06 | [
"https://3dprinting.stackexchange.com/questions/18207",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/31470/"
] | I bought an Ender 3 V2 printer and printed successfully with PLA and PLA+. Ender 3 V2 is rated at <= 250 °C but when I set temperature above 200 °C to print to PLA+, I get an error message "Nozzle is too lowperature" and the printer freezes (the term lowperature is actual and not a typo error).
I tried to raise the te... | This sounds like a bad thermistor. Try replacing the head thermistor, see if this fixes it.
As for the strange error message, it looks like the word Temperature is being drawn on the wrong line, and then "is too low" writes over it.
See the way the word lines up below:
```
nozzle temperature
is too lowperature
``` |
18,376 | <p>I am at a school with several Makerbot Replicator+ – a total of 9 of them.</p>
<p>So, they seem to print fine and I can hook up to two of them to one laptop (they are some Lenovo models from a few years back) using Makerbot Print. Well and good.</p>
<p>But I wanted to hook them up to my MacBook Pro (2020, OS X Catal... | [
{
"answer_id": 18377,
"author": "Greenonline",
"author_id": 4762,
"author_profile": "https://3dprinting.stackexchange.com/users/4762",
"pm_score": 3,
"selected": true,
"text": "<p><em><strong>It would seem that the printer control board doesn't use a CH340 (see bottom of this answer) and... | 2021/11/15 | [
"https://3dprinting.stackexchange.com/questions/18376",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/31967/"
] | I am at a school with several Makerbot Replicator+ – a total of 9 of them.
So, they seem to print fine and I can hook up to two of them to one laptop (they are some Lenovo models from a few years back) using Makerbot Print. Well and good.
But I wanted to hook them up to my MacBook Pro (2020, OS X Catalina) with the U... | ***It would seem that the printer control board doesn't use a CH340 (see bottom of this answer) and therefore this answer should be ignored.***
---
### CH340 and OS X incompatibility
The reason your Mac might not see the printers *could* be down to the USB interface ***on the printer controller board***.
If it is i... |
18,567 | <p>I have a new Creality Ender 2 Pro with a Creality 4.2.3 mainboard. I'm attempting to compile Marlin to fix a bug. How can I tell what driver chips I have on this board?</p>
<p>I've narrowed it down to likely <code>A4988</code> or <code>TMC2208_STANDALONE</code> or possibly the <code>TMC2225</code>. Strangely Crealit... | [
{
"answer_id": 18570,
"author": "spuder",
"author_id": 28932,
"author_profile": "https://3dprinting.stackexchange.com/users/28932",
"pm_score": 3,
"selected": true,
"text": "<p>According to <a href=\"https://github.com/MarlinFirmware/Configurations/pull/633#issuecomment-995206382\" rel=\... | 2021/12/15 | [
"https://3dprinting.stackexchange.com/questions/18567",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/28932/"
] | I have a new Creality Ender 2 Pro with a Creality 4.2.3 mainboard. I'm attempting to compile Marlin to fix a bug. How can I tell what driver chips I have on this board?
I've narrowed it down to likely `A4988` or `TMC2208_STANDALONE` or possibly the `TMC2225`. Strangely Creality only has documentation for the 4.2.2 and... | According to ['The-EG' comment](https://github.com/MarlinFirmware/Configurations/pull/633#issuecomment-995206382) in this GitHub issue, [Add Creality Ender 2 Pro config #633](https://github.com/MarlinFirmware/Configurations/pull/633), you can often determine the stepper drivers by one of a few ways:
1. Listen to the s... |
18,568 | <p>Why do concrete 3D printers lay the concrete in a zigzag shape? I know pouring it in a straight line makes it unstable, but the zigzag shape reduces the contact of the top layer to the layer below. What is the advantage?</p>
| [
{
"answer_id": 18570,
"author": "spuder",
"author_id": 28932,
"author_profile": "https://3dprinting.stackexchange.com/users/28932",
"pm_score": 3,
"selected": true,
"text": "<p>According to <a href=\"https://github.com/MarlinFirmware/Configurations/pull/633#issuecomment-995206382\" rel=\... | 2021/12/15 | [
"https://3dprinting.stackexchange.com/questions/18568",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/32308/"
] | Why do concrete 3D printers lay the concrete in a zigzag shape? I know pouring it in a straight line makes it unstable, but the zigzag shape reduces the contact of the top layer to the layer below. What is the advantage? | According to ['The-EG' comment](https://github.com/MarlinFirmware/Configurations/pull/633#issuecomment-995206382) in this GitHub issue, [Add Creality Ender 2 Pro config #633](https://github.com/MarlinFirmware/Configurations/pull/633), you can often determine the stepper drivers by one of a few ways:
1. Listen to the s... |
18,575 | <p>It seems there are some missing lines on the outer wall on the Z-axis with my prints. I'm not able to pinpoint the problem. Does anyone have ideas about what might be wrong with my setup/settings?</p>
<p>Example:</p>
<p><a href="https://i.stack.imgur.com/3q1k3.jpg" rel="nofollow noreferrer" title="Printed model with... | [
{
"answer_id": 18570,
"author": "spuder",
"author_id": 28932,
"author_profile": "https://3dprinting.stackexchange.com/users/28932",
"pm_score": 3,
"selected": true,
"text": "<p>According to <a href=\"https://github.com/MarlinFirmware/Configurations/pull/633#issuecomment-995206382\" rel=\... | 2021/12/16 | [
"https://3dprinting.stackexchange.com/questions/18575",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/32326/"
] | It seems there are some missing lines on the outer wall on the Z-axis with my prints. I'm not able to pinpoint the problem. Does anyone have ideas about what might be wrong with my setup/settings?
Example:
[ in this GitHub issue, [Add Creality Ender 2 Pro config #633](https://github.com/MarlinFirmware/Configurations/pull/633), you can often determine the stepper drivers by one of a few ways:
1. Listen to the s... |
18,587 | <p>I have an Ender 3 V1 with a glass Creality plate. I was having difficulty using manual levelling and my prints were struggling, so I ordered a 3DTouch. I have installed the 3DTouch and used Creality's BLTouch firmware. But my bed is still not level.</p>
<p>So my build is an Ender 3 V1 with:</p>
<ul>
<li>Extruder upg... | [
{
"answer_id": 18570,
"author": "spuder",
"author_id": 28932,
"author_profile": "https://3dprinting.stackexchange.com/users/28932",
"pm_score": 3,
"selected": true,
"text": "<p>According to <a href=\"https://github.com/MarlinFirmware/Configurations/pull/633#issuecomment-995206382\" rel=\... | 2021/12/18 | [
"https://3dprinting.stackexchange.com/questions/18587",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/32347/"
] | I have an Ender 3 V1 with a glass Creality plate. I was having difficulty using manual levelling and my prints were struggling, so I ordered a 3DTouch. I have installed the 3DTouch and used Creality's BLTouch firmware. But my bed is still not level.
So my build is an Ender 3 V1 with:
* Extruder upgraded to all-metal ... | According to ['The-EG' comment](https://github.com/MarlinFirmware/Configurations/pull/633#issuecomment-995206382) in this GitHub issue, [Add Creality Ender 2 Pro config #633](https://github.com/MarlinFirmware/Configurations/pull/633), you can often determine the stepper drivers by one of a few ways:
1. Listen to the s... |
18,629 | <p>I have a 3018 Pro CNC and being trying cutting a contour of a simple circular part:</p>
<p><a href="https://i.stack.imgur.com/w3mDe.png" rel="nofollow noreferrer" title="Screenshot of Fusion 360 model and route"><img src="https://i.stack.imgur.com/w3mDe.png" alt="Screenshot of Fusion 360 model and route" title="Scre... | [
{
"answer_id": 18645,
"author": "cmm",
"author_id": 2082,
"author_profile": "https://3dprinting.stackexchange.com/users/2082",
"pm_score": 2,
"selected": false,
"text": "<p>It is hard to be sure from the picture. When I wrote this answer, material you were cutting looked like clear plas... | 2021/12/24 | [
"https://3dprinting.stackexchange.com/questions/18629",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/8008/"
] | I have a 3018 Pro CNC and being trying cutting a contour of a simple circular part:
[](https://i.stack.imgur.com/w3mDe.png "Screenshot of Fusion 360 model and route")
G-code:
```
(TestKnobContou... | I've ran the code on my own CNC machine. I slightly adapted the code as my machine doesn't understand the movement without the instruction code:
```
Z1 F10.0
Z-2.9
X10.792 Z-2.938 F10.0
X10.771 Z-2.971
X10.738 Z-2.992
X10.7 Z-3
X10.6
X10.562 Y0.092
X10.529 Y0.071
X10.508 Y0.038
X10.5 Y0
```
is changed to
```
G1 Z1 ... |
18,639 | <p>I recently got a KP3S Kingroon 3D printer and have been trying to set it up.</p>
<p>After a couple of test prints, the Y-axis seems to only move in one direction. At first, I thought it was a motor issue, but when I go into the manual move directions for the Y-axis it seems that both inputs lead to the motor spinnin... | [
{
"answer_id": 18640,
"author": "0scar",
"author_id": 5740,
"author_profile": "https://3dprinting.stackexchange.com/users/5740",
"pm_score": 0,
"selected": false,
"text": "<p>The question body has changed to rule out broken endstops. As a generic answer for steppers only going into a sin... | 2021/12/26 | [
"https://3dprinting.stackexchange.com/questions/18639",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/32439/"
] | I recently got a KP3S Kingroon 3D printer and have been trying to set it up.
After a couple of test prints, the Y-axis seems to only move in one direction. At first, I thought it was a motor issue, but when I go into the manual move directions for the Y-axis it seems that both inputs lead to the motor spinning in the ... | The answer might just be replace the mother board.
If I understood everything correctly there are 5 things to check to break down the problem:
* the motor,
* the cable,
* the stepper connection,
* the software input, and
* the firmware.
Using Repetier I disproved that the software was broken. By switching the X step... |
18,704 | <p>I need to 3D print several composites. The constituent materials are photopolymer resins. The composites are very similar to a Rubik's cube. Considering it that way, each voxel (every small piece of the Rubik's cube) is either entirely printed by material A or B.</p>
<p>I have the binary files ready for the parts. M... | [
{
"answer_id": 18706,
"author": "Trish",
"author_id": 8884,
"author_profile": "https://3dprinting.stackexchange.com/users/8884",
"pm_score": 0,
"selected": false,
"text": "<p>Stratasys industrial machines generally use proprietary software to prepare the print files for printing and don'... | 2022/01/09 | [
"https://3dprinting.stackexchange.com/questions/18704",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/32618/"
] | I need to 3D print several composites. The constituent materials are photopolymer resins. The composites are very similar to a Rubik's cube. Considering it that way, each voxel (every small piece of the Rubik's cube) is either entirely printed by material A or B.
I have the binary files ready for the parts. More speci... | It appears that your question is directed to solving the problem of converting your file of parameters to a 3D printable form. I'm far from an OpenSCAD wizard, but I suspect that your parameters file could be read into a properly coded OpenSCAD document to create the necessary STL to be printed.
Your reference of I, J... |
18,757 | <p>I'm running a stock Ender 5 pro with the filament that came with it, and using Creality Slicer 4.8.2, but I'm only able to get reliable bed adhesion if I increase the bed temperature from 50 to 60 °C for the bottom layer and decrease the print head speed by about 75 % from the default profile for the Ender 5.</p>
<p... | [
{
"answer_id": 18758,
"author": "R.. GitHub STOP HELPING ICE",
"author_id": 11157,
"author_profile": "https://3dprinting.stackexchange.com/users/11157",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming Creality's stock firmware still doesn't have Linear Advance enabled, there's a f... | 2022/01/16 | [
"https://3dprinting.stackexchange.com/questions/18757",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/29097/"
] | I'm running a stock Ender 5 pro with the filament that came with it, and using Creality Slicer 4.8.2, but I'm only able to get reliable bed adhesion if I increase the bed temperature from 50 to 60 °C for the bottom layer and decrease the print head speed by about 75 % from the default profile for the Ender 5.
The mach... | Your bed is too low - raise it by turning the knobs underneath.
The first layer should not look like strings sitting on the bed as per your photo. Instead it should be a wider strip that looks somewhat like an electronic circuit trace, or like someone has pushed wet paint out of a tube that is being wiped across the s... |
18,761 | <p>Is there a machine (for hobbyists) that will make filament based on the type of plastic I put in. I will sort the plastic before I will put it in the machine.</p>
<p>I have seen the <a href="http://filabot.com" rel="nofollow noreferrer">filabot</a> but this uses only plastic from previous prints not plastic types Po... | [
{
"answer_id": 18762,
"author": "user10489",
"author_id": 28397,
"author_profile": "https://3dprinting.stackexchange.com/users/28397",
"pm_score": 0,
"selected": false,
"text": "<p>The source of the plastic doesn't matter a lot.</p>\n<p>What matters is the plastic's composition and chemi... | 2022/01/17 | [
"https://3dprinting.stackexchange.com/questions/18761",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/31762/"
] | Is there a machine (for hobbyists) that will make filament based on the type of plastic I put in. I will sort the plastic before I will put it in the machine.
I have seen the [filabot](http://filabot.com) but this uses only plastic from previous prints not plastic types Polyethylene Terephthalate (PET or PETE) or High... | >
> I am asking if there is a machine that can turn a plastic bottle into usable filament.
>
>
>
I've seen several projects ([one example](https://hackaday.com/2021/06/29/petbot-turn-pet-bottles-into-filament/), and [another](https://youtu.be/Eecbdb0bQWQ)) where plastic bottles are sliced into long tapes, and the ... |
19,025 | <p>I'd like to force Klipper to perform power on (using <code>M80</code>) before homing. For this purpose I'm trying to override <code>G28</code>:</p>
<pre><code>[gcode_macro G28]
rename_existing: G28_BASE
gcode:
M80
G28_BASE { rawparams }
</code></pre>
<p>But for some reason this does not work, I'm getting the fol... | [
{
"answer_id": 19026,
"author": "R.. GitHub STOP HELPING ICE",
"author_id": 11157,
"author_profile": "https://3dprinting.stackexchange.com/users/11157",
"pm_score": 3,
"selected": true,
"text": "<p>Because of the way parameters work differently (<code>Sx</code> vs <code>NAME=x</code>) fo... | 2022/02/27 | [
"https://3dprinting.stackexchange.com/questions/19025",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/5033/"
] | I'd like to force Klipper to perform power on (using `M80`) before homing. For this purpose I'm trying to override `G28`:
```
[gcode_macro G28]
rename_existing: G28_BASE
gcode:
M80
G28_BASE { rawparams }
```
But for some reason this does not work, I'm getting the following error:
```
G-Code macro rename of diff... | Because of the way parameters work differently (`Sx` vs `NAME=x`) for gcode style commands vs Klipper extended ones, the rename has to be to the "same type" of command. `G28_BASE` does not fit the pattern to be considered a "gcode style" one. Use `G9028` or `G28.1` or something instead and it should work. |
19,048 | <p>OK here's some background of the problem:</p>
<p>Symptoms:</p>
<ul>
<li><p>All retracts on the extruder produce a screeching noise. The extruder extrudes normally all other times.</p>
</li>
<li><p>Any fast move on the Z-axis also produces a screeching noise and the Z-axis will move normally at all other times.</p>
<... | [
{
"answer_id": 19030,
"author": "Zeiss Ikon",
"author_id": 28508,
"author_profile": "https://3dprinting.stackexchange.com/users/28508",
"pm_score": 3,
"selected": false,
"text": "<p>If you have an empty spool of the same brand, you could weigh the empty spool and the one you're trying to... | 2022/03/04 | [
"https://3dprinting.stackexchange.com/questions/19048",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/33395/"
] | OK here's some background of the problem:
Symptoms:
* All retracts on the extruder produce a screeching noise. The extruder extrudes normally all other times.
* Any fast move on the Z-axis also produces a screeching noise and the Z-axis will move normally at all other times.
* This appears to happen regardless of any... | If you have an empty spool of the same brand, you could weigh the empty spool and the one you're trying to "measure" to get an approximate weight of the remaining filament. Divide by the (presumably available from manufacturer) weight per meter to get a rough length in meters, if that's more useful to you than weight. |
19,353 | <p>Most of the guides I can find are just canned responses to specific questions. Instead I'm looking for something meant to teach good fundamental understanding and core needed skills. Beginner's guides are common in other hobbies but I am having trouble finding one for 3d printing.</p>
| [
{
"answer_id": 19354,
"author": "Kilisi",
"author_id": 31811,
"author_profile": "https://3dprinting.stackexchange.com/users/31811",
"pm_score": 0,
"selected": false,
"text": "<p>Thera are plenty of such guides. But from necessity they deal with specifics, there are too many things to cov... | 2022/05/07 | [
"https://3dprinting.stackexchange.com/questions/19353",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/34019/"
] | Most of the guides I can find are just canned responses to specific questions. Instead I'm looking for something meant to teach good fundamental understanding and core needed skills. Beginner's guides are common in other hobbies but I am having trouble finding one for 3d printing. | Here's a brief outline I threw out in chat once. I'm marking this as a "community Wiki" answer so feel free to edit.
It is not a full Primer, so should date better than a Word6.0 manual.
---
Start by reading the instructions that came with your printer. There's a high chance that some assembly is required, and if yo... |
19,359 | <p>Looking to print a new part for a home appliance. There's going to need to be a new model created with the customizations made, but the model (after printing) will have to fit where the old part was. Is there any 3D modeling software that is better for this purpose? Will I just have to guess at proper proportions an... | [
{
"answer_id": 19354,
"author": "Kilisi",
"author_id": 31811,
"author_profile": "https://3dprinting.stackexchange.com/users/31811",
"pm_score": 0,
"selected": false,
"text": "<p>Thera are plenty of such guides. But from necessity they deal with specifics, there are too many things to cov... | 2022/05/08 | [
"https://3dprinting.stackexchange.com/questions/19359",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/34019/"
] | Looking to print a new part for a home appliance. There's going to need to be a new model created with the customizations made, but the model (after printing) will have to fit where the old part was. Is there any 3D modeling software that is better for this purpose? Will I just have to guess at proper proportions and h... | Here's a brief outline I threw out in chat once. I'm marking this as a "community Wiki" answer so feel free to edit.
It is not a full Primer, so should date better than a Word6.0 manual.
---
Start by reading the instructions that came with your printer. There's a high chance that some assembly is required, and if yo... |
19,380 | <p>I want to put relief text on curved surface but can't find way to do that in OpenSCAD. I'm aware it's possible to bend text in Blender and then <code>import stl</code>, but I don't like this workflow. I found sort of working solution but it's not perfect.</p>
<pre><code>$fn=50;
module bend_text(caption, angle, text... | [
{
"answer_id": 19364,
"author": "Criggie",
"author_id": 12956,
"author_profile": "https://3dprinting.stackexchange.com/users/12956",
"pm_score": 3,
"selected": true,
"text": "<p>Yes - you should be able to turn the extruder by hand when it is unplugged and therefore not powered.</p>\n<p>... | 2022/05/12 | [
"https://3dprinting.stackexchange.com/questions/19380",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/34129/"
] | I want to put relief text on curved surface but can't find way to do that in OpenSCAD. I'm aware it's possible to bend text in Blender and then `import stl`, but I don't like this workflow. I found sort of working solution but it's not perfect.
```
$fn=50;
module bend_text(caption, angle, text_height, text_width, tex... | Yes - you should be able to turn the extruder by hand when it is unplugged and therefore not powered.
The V2 comes with a blue plastic knob for this purpose, it may be too small to turn the shaft by hand.
When powered and "steppers enabled" the motors need a lot more force to overcome, but even that can be done by ha... |
19,411 | <p>Ender 3 Pro, PLA, temps 200 °C and 60 °C.</p>
<p>I want to not heat the nozzle until after Auto Bed Leveling (CR Touch) is complete. I can do that in the start G-code, but by then, Cura has already heated the nozzle to the temp specified under material and filament starts oozing out during bed leveling. I'd rather... | [
{
"answer_id": 19412,
"author": "0scar",
"author_id": 5740,
"author_profile": "https://3dprinting.stackexchange.com/users/5740",
"pm_score": 0,
"selected": false,
"text": "<p>Go to the <code>Settings</code> -> <code>Printers</code> menu from the top menu,</p>\n<p><a href=\"https://i.s... | 2022/05/21 | [
"https://3dprinting.stackexchange.com/questions/19411",
"https://3dprinting.stackexchange.com",
"https://3dprinting.stackexchange.com/users/34216/"
] | Ender 3 Pro, PLA, temps 200 °C and 60 °C.
I want to not heat the nozzle until after Auto Bed Leveling (CR Touch) is complete. I can do that in the start G-code, but by then, Cura has already heated the nozzle to the temp specified under material and filament starts oozing out during bed leveling. I'd rather set a vari... | I've sorted this out. *IF* I include my own heating commands in my start G-Code, Cura knows to NOT add its own heating commands at the start of the G-Code file.
The variables I was referring to have dedicated names.
`material_print_temperature_layer_0` is the printing (extruder/nozzle) temp set under Material in Cura.... |
4 | <p>I want to assign the decimal variable "trans" to the double variable "this.Opacity".</p>
<pre class="lang-cs prettyprint-override"><code>decimal trans = trackBar1.Value / 5000;
this.Opacity = trans;
</code></pre>
<p>When I build the app it gives the following error:</p>
<blockquote>
<p>Cannot imp... | [
{
"answer_id": 7,
"author": "Kevin Dente",
"author_id": 9,
"author_profile": "https://Stackoverflow.com/users/9",
"pm_score": 10,
"selected": true,
"text": "<p>An explicit cast to <code>double</code> like this isn't necessary:</p>\n\n<pre><code>double trans = (double) trackBar1.Value / 5... | 2008/07/31 | [
"https://Stackoverflow.com/questions/4",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8/"
] | I want to assign the decimal variable "trans" to the double variable "this.Opacity".
```cs
decimal trans = trackBar1.Value / 5000;
this.Opacity = trans;
```
When I build the app it gives the following error:
>
> Cannot implicitly convert type decimal to double
>
>
> | An explicit cast to `double` like this isn't necessary:
```
double trans = (double) trackBar1.Value / 5000.0;
```
Identifying the constant as `5000.0` (or as `5000d`) is sufficient:
```
double trans = trackBar1.Value / 5000.0;
double trans = trackBar1.Value / 5000d;
``` |
9 | <p>Given a <code>DateTime</code> representing a person's birthday, how do I calculate their age in years?</p>
| [
{
"answer_id": 22,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 6,
"selected": false,
"text": "<p>The best way that I know of because of leap years and everything is:</p>\n\n<pre class=\"lang-cs prettyprint-override\"><cod... | 2008/07/31 | [
"https://Stackoverflow.com/questions/9",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1/"
] | Given a `DateTime` representing a person's birthday, how do I calculate their age in years? | An easy to understand and simple solution.
```cs
// Save today's date.
var today = DateTime.Today;
// Calculate the age.
var age = today.Year - birthdate.Year;
// Go back to the year in which the person was born in case of a leap year
if (birthdate.Date > today.AddYears(-age)) age--;
```
However, this assumes you ... |
11 | <p>Given a specific <code>DateTime</code> value, how do I display relative time, like:</p>
<ul>
<li><code>2 hours ago</code></li>
<li><code>3 days ago</code></li>
<li><code>a month ago</code></li>
</ul>
| [
{
"answer_id": 12,
"author": "Jeff Atwood",
"author_id": 1,
"author_profile": "https://Stackoverflow.com/users/1",
"pm_score": 8,
"selected": false,
"text": "<p>Here's how I do it</p>\n\n<pre class=\"lang-csharp prettyprint-override\"><code>var ts = new TimeSpan(DateTime.UtcNow.Ticks - d... | 2008/07/31 | [
"https://Stackoverflow.com/questions/11",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1/"
] | Given a specific `DateTime` value, how do I display relative time, like:
* `2 hours ago`
* `3 days ago`
* `a month ago` | Jeff, [your code](https://stackoverflow.com/questions/11/how-do-i-calculate-relative-time/12#12) is nice but could be clearer with constants (as suggested in Code Complete).
```csharp
const int SECOND = 1;
const int MINUTE = 60 * SECOND;
const int HOUR = 60 * MINUTE;
const int DAY = 24 * HOUR;
const int MONTH = 30 * D... |
16 | <p>How do you expose a LINQ query as an ASMX web service?
<br>
Usually, from the business tier, I can return a typed <code>DataSet</code> or a <code>DataTable</code> which can be serialized for transport over ASMX.</p>
<p>How can I do the same for a LINQ query? <br>
Is there a way to populate a typed <code>DataSet</cod... | [
{
"answer_id": 84,
"author": "Dave Ward",
"author_id": 60,
"author_profile": "https://Stackoverflow.com/users/60",
"pm_score": 4,
"selected": false,
"text": "<p>If you use a return type of <code>IEnumerable</code>, you can return your <strong>query</strong> variable directly.</p>\n"
},... | 2008/08/01 | [
"https://Stackoverflow.com/questions/16",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2/"
] | How do you expose a LINQ query as an ASMX web service?
Usually, from the business tier, I can return a typed `DataSet` or a `DataTable` which can be serialized for transport over ASMX.
How can I do the same for a LINQ query?
Is there a way to populate a typed `DataSet` or a `DataTable` via a LINQ query?
```
publ... | As mentioned in the question, `IEnumerable` has a `CopyToDataTable` method:
```
IEnumerable<DataRow> query =
from order in orders.AsEnumerable()
where order.Field<DateTime>("OrderDate") > new DateTime(2001, 8, 1)
select order;
// Create a table from the query.
DataTable boundTable = query.CopyToDataTable<... |
19 | <p>I'm looking for the fastest way to obtain the value of π, as a personal challenge. More specifically, I'm using ways that don't involve using <code>#define</code> constants like <code>M_PI</code>, or hard-coding the number in.</p>
<p>The program below tests the various ways I know of. The inline assembly version is... | [
{
"answer_id": 71,
"author": "Leon Bambrick",
"author_id": 49,
"author_profile": "https://Stackoverflow.com/users/49",
"pm_score": 6,
"selected": false,
"text": "<p>Here's a general description of a technique for calculating pi that I learnt in high school.</p>\n\n<p>I only share this be... | 2008/08/01 | [
"https://Stackoverflow.com/questions/19",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13/"
] | I'm looking for the fastest way to obtain the value of π, as a personal challenge. More specifically, I'm using ways that don't involve using `#define` constants like `M_PI`, or hard-coding the number in.
The program below tests the various ways I know of. The inline assembly version is, in theory, the fastest option,... | The [Monte Carlo method](http://en.wikipedia.org/wiki/Monte_Carlo_method), as mentioned, applies some great concepts but it is, clearly, not the fastest, not by a long shot, not by any reasonable measure. Also, it all depends on what kind of accuracy you are looking for. The fastest π I know of is the one with the digi... |
25 | <p>I'm having issues getting the C sockets API to work properly in C++ on z/OS.</p>
<p>Although I am including <code>sys/socket.h</code>, I still get compile time errors telling me that <code>AF_INET</code> is not defined.</p>
<p>Am I missing something obvious, or is this related to the fact that being on z/OS makes my... | [
{
"answer_id": 30,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 5,
"selected": false,
"text": "<p>I've had no trouble using the BSD sockets API in C++, in GNU/Linux. Here's the sample program I used:</p>\n\n<pre><code>#incl... | 2008/08/01 | [
"https://Stackoverflow.com/questions/25",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23/"
] | I'm having issues getting the C sockets API to work properly in C++ on z/OS.
Although I am including `sys/socket.h`, I still get compile time errors telling me that `AF_INET` is not defined.
Am I missing something obvious, or is this related to the fact that being on z/OS makes my problems much more complicated?
I d... | Keep a copy of the IBM manuals handy:
* [z/OS V1R11.0 XL C/C++ Programming Guide](http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CBCPG1A0/CCONTENTS?DT=20090606065305)
* [z/OS V1R11.0 XL C/C++ Run-Time Library Reference](http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/EDCLB1A0/CCONTENTS?DT=200906... |
34 | <p>How do I forcefully unload a <code>ByteArray</code> from memory using ActionScript 3?</p>
<p>I have tried the following:</p>
<pre><code>// First non-working solution
byteArray.length = 0;
byteArray = new ByteArray();
// Second non-working solution
for ( var i:int=0; i < byteArray.length; i++ ) {
byteArray[... | [
{
"answer_id": 52,
"author": "Jax",
"author_id": 23,
"author_profile": "https://Stackoverflow.com/users/23",
"pm_score": 4,
"selected": false,
"text": "<p>Have a look at this article</p>\n\n<p><a href=\"http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html\" rel=\"noreferrer... | 2008/08/01 | [
"https://Stackoverflow.com/questions/34",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I forcefully unload a `ByteArray` from memory using ActionScript 3?
I have tried the following:
```
// First non-working solution
byteArray.length = 0;
byteArray = new ByteArray();
// Second non-working solution
for ( var i:int=0; i < byteArray.length; i++ ) {
byteArray[i] = null;
}
``` | (I'm not positive about this, but...)
AS3 uses a non-deterministic garbage collection which means that dereferenced memory will be freed up whenever the runtime feels like it (typically not unless there's a reason to run, since it's an expensive operation to execute). This is the same approach used by most modern garb... |
36 | <p>How can I monitor an SQL Server database for changes to a table without using triggers or modifying the structure of the database in any way? My preferred programming environment is <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="noreferrer">.NET</a> and C#.</p>
<p>I'd like to be able to support any <a h... | [
{
"answer_id": 51,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 5,
"selected": false,
"text": "<p>Why don't you want to use triggers? They are a good thing if you use them correctly. If you use them as a way to enforce r... | 2008/08/01 | [
"https://Stackoverflow.com/questions/36",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32/"
] | How can I monitor an SQL Server database for changes to a table without using triggers or modifying the structure of the database in any way? My preferred programming environment is [.NET](http://en.wikipedia.org/wiki/.NET_Framework) and C#.
I'd like to be able to support any [SQL Server 2000](http://en.wikipedia.org/... | Take a look at the CHECKSUM command:
```
SELECT CHECKSUM_AGG(BINARY_CHECKSUM(*)) FROM sample_table WITH (NOLOCK);
```
That will return the same number each time it's run as long as the table contents haven't changed. See my post on this for more information:
[CHECKSUM](http://msdn.microsoft.com/en-us/library/aa2582... |
42 | <p>I am starting a new web application in PHP and this time around I want to create something that people can extend by using a plugin interface. </p>
<p>How does one go about writing 'hooks' into their code so that plugins can attach to specific events?</p>
| [
{
"answer_id": 76,
"author": "helloandre",
"author_id": 50,
"author_profile": "https://Stackoverflow.com/users/50",
"pm_score": 4,
"selected": false,
"text": "<p>I believe the easiest way would be to follow Jeff's own advice and have a look around the existing code. Try looking at WordPr... | 2008/08/01 | [
"https://Stackoverflow.com/questions/42",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37/"
] | I am starting a new web application in PHP and this time around I want to create something that people can extend by using a plugin interface.
How does one go about writing 'hooks' into their code so that plugins can attach to specific events? | You could use an Observer pattern. A simple functional way to accomplish this:
```
<?php
/** Plugin system **/
$listeners = array();
/* Create an entry point for plugins */
function hook() {
global $listeners;
$num_args = func_num_args();
$args = func_get_args();
if($num_args < 2)
trigger_... |
48 | <p>Let's say you create a wizard in an HTML form. One button goes back, and one goes forward. Since the <em>back</em> button appears first in the markup when you press <kbd>Enter</kbd>, it will use that button to submit the form.</p>
<p>Example:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-consol... | [
{
"answer_id": 56,
"author": "huseyint",
"author_id": 39,
"author_profile": "https://Stackoverflow.com/users/39",
"pm_score": 6,
"selected": false,
"text": "<p>Give your submit buttons the same name like this:</p>\n\n<pre><code><input type=\"submit\" name=\"submitButton\" value=\"Prev... | 2008/08/01 | [
"https://Stackoverflow.com/questions/48",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40/"
] | Let's say you create a wizard in an HTML form. One button goes back, and one goes forward. Since the *back* button appears first in the markup when you press `Enter`, it will use that button to submit the form.
Example:
```html
<form>
<!-- Put your cursor in this field and press Enter -->
<input type="text" nam... | I'm just doing the trick of `float`ing the buttons to the right.
This way the `Prev` button is left of the `Next` button, but the `Next` comes first in the HTML structure:
```css
.f {
float: right;
}
.clr {
clear: both;
}
```
```html
<form action="action" method="get">
<input type="text" name="abc">
<div id=... |
59 | <p>I have a <code>DataTable</code> with a <code>Name</code> column. I want to generate a collection of the unique names ordered alphabetically. The following query ignores the <em>order by</em> clause.</p>
<pre><code>var names =
(from DataRow dr in dataTable.Rows
orderby (string)dr["Name"]
select (string)d... | [
{
"answer_id": 62,
"author": "Bob",
"author_id": 45,
"author_profile": "https://Stackoverflow.com/users/45",
"pm_score": 6,
"selected": false,
"text": "<p><strong>The problem is that the Distinct\n operator does not grant that it will\n maintain the original order of\n values.</strong></... | 2008/08/01 | [
"https://Stackoverflow.com/questions/59",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45/"
] | I have a `DataTable` with a `Name` column. I want to generate a collection of the unique names ordered alphabetically. The following query ignores the *order by* clause.
```
var names =
(from DataRow dr in dataTable.Rows
orderby (string)dr["Name"]
select (string)dr["Name"]).Distinct();
```
Why does the `... | To make it more readable and maintainable, you can also split it up into multiple LINQ statements.
1. First, select your data into a new list, let's call it `x1`, do a projection if desired
2. Next, create a distinct list, from `x1` into `x2`, using whatever distinction you require
3. Finally, create an ordered list, ... |
66 | <p>How do you page through a collection in LINQ given that you have a <code>startIndex</code> and a <code>count</code>?</p>
| [
{
"answer_id": 68,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 6,
"selected": false,
"text": "<p>It is very simple with the <code>Skip</code> and <code>Take</code> extension methods.</p>\n\n<pre><code>var query = from i i... | 2008/08/01 | [
"https://Stackoverflow.com/questions/66",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17/"
] | How do you page through a collection in LINQ given that you have a `startIndex` and a `count`? | A few months back I wrote a blog post about Fluent Interfaces and LINQ which used an Extension Method on `IQueryable<T>` and another class to provide the following natural way of paginating a LINQ collection.
```
var query = from i in ideas
select i;
var pagedCollection = query.InPagesOf(10);
var pageOfIde... |
80 | <p>I've written a database generation script in <a href="http://en.wikipedia.org/wiki/SQL" rel="noreferrer">SQL</a> and want to execute it in my <a href="http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime" rel="noreferrer">Adobe AIR</a> application:</p>
<pre><code>Create Table tRole (
roleID integer Primary Key... | [
{
"answer_id": 124,
"author": "Shawn",
"author_id": 26,
"author_profile": "https://Stackoverflow.com/users/26",
"pm_score": 5,
"selected": true,
"text": "<p>I wound up using this. It is a kind of a hack, but it actually works pretty well. </p>\n\n<p>The only thing is you have to be very ... | 2008/08/01 | [
"https://Stackoverflow.com/questions/80",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | I've written a database generation script in [SQL](http://en.wikipedia.org/wiki/SQL) and want to execute it in my [Adobe AIR](http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime) application:
```
Create Table tRole (
roleID integer Primary Key
,roleName varchar(40)
);
Create Table tFile (
fileID integer ... | I wound up using this. It is a kind of a hack, but it actually works pretty well.
The only thing is you have to be very careful with your semicolons. : D
```
var strSql:String = stream.readUTFBytes(stream.bytesAvailable);
var i:Number = 0;
var strSqlSplit:Array = strSql.split(";");
for (i = 0; i < strSqlSplit.... |
85 | <p>What are the best practices around creating flat file database structures in PHP?</p>
<p>A lot of more matured PHP flat file frameworks out there which I attempt to implement SQL-like query syntax which is over the top for my purposes in most cases. (I would just use a database at that point).</p>
<p>Are there any... | [
{
"answer_id": 87,
"author": "saint_groceon",
"author_id": 59,
"author_profile": "https://Stackoverflow.com/users/59",
"pm_score": 4,
"selected": false,
"text": "<p>One framework I'm considering would be for a blogging platform. Since just about any possible view of data you would want w... | 2008/08/01 | [
"https://Stackoverflow.com/questions/85",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59/"
] | What are the best practices around creating flat file database structures in PHP?
A lot of more matured PHP flat file frameworks out there which I attempt to implement SQL-like query syntax which is over the top for my purposes in most cases. (I would just use a database at that point).
Are there any elegant tricks o... | Well, what is the nature of the flat databases. Are they large or small. Is it simple arrays with arrays in them? if its something simple say userprofiles built as such:
```
$user = array("name" => "bob",
"age" => 20,
"websites" => array("example.com","bob.example.com","bob2.example.com"),... |
88 | <p>I am porting a game, that was originally written for the Win32 API, to Linux (well, porting the OS X port of the Win32 port to Linux).</p>
<p>I have implemented <code>QueryPerformanceCounter</code> by giving the uSeconds since the process start up: </p>
<pre><code>BOOL QueryPerformanceCounter(LARGE_INTEGER* pe... | [
{
"answer_id": 93,
"author": "CodingWithoutComments",
"author_id": 25,
"author_profile": "https://Stackoverflow.com/users/25",
"pm_score": 2,
"selected": false,
"text": "<p>From my experience, and from what I've read across the internet, the answer is \"No,\" it is not guaranteed. It de... | 2008/08/01 | [
"https://Stackoverflow.com/questions/88",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61/"
] | I am porting a game, that was originally written for the Win32 API, to Linux (well, porting the OS X port of the Win32 port to Linux).
I have implemented `QueryPerformanceCounter` by giving the uSeconds since the process start up:
```
BOOL QueryPerformanceCounter(LARGE_INTEGER* performanceCount)
{
gettimeofday(&... | Maybe. But you have bigger problems. `gettimeofday()` can result in incorrect timings if there are processes on your system that change the timer (ie, ntpd). On a "normal" linux, though, I believe the resolution of `gettimeofday()` is 10us. It can jump forward and backward and time, consequently, based on the processes... |
109 | <p>Recently our site has been deluged with the resurgence of the <a href="https://en.wikipedia.org/wiki/Asprox_botnet" rel="noreferrer">Asprox botnet</a> <a href="http://en.wikipedia.org/wiki/SQL_injection" rel="noreferrer">SQL injection</a> attack. Without going into details, the attack attempts to execute SQL code by... | [
{
"answer_id": 304,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 3,
"selected": false,
"text": "<p>Try removing the <code>0x</code> first and then call <code>Encoding.UTF8.GetString</code>. I think that may work.</p>\n\n<p... | 2008/08/01 | [
"https://Stackoverflow.com/questions/109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71/"
] | Recently our site has been deluged with the resurgence of the [Asprox botnet](https://en.wikipedia.org/wiki/Asprox_botnet) [SQL injection](http://en.wikipedia.org/wiki/SQL_injection) attack. Without going into details, the attack attempts to execute SQL code by encoding the [T-SQL](http://en.wikipedia.org/wiki/Transact... | I went back to Michael's post, did some more poking and realized that I did need to do a double conversion, and eventually worked out this little nugget:
```
Convert.ToString(Convert.ToChar(Int32.Parse(EncodedString.Substring(intParseIndex, 2), System.Globalization.NumberStyles.HexNumber)));
```
From there I simply ... |
126 | <p>What is the "purist" or "correct" way to access an object's properties from within an object method that is not a getter/setter method?</p>
<p>I know that from outside of the object you should use a getter/setter, but from within would you just do:</p>
<p>Java:</p>
<pre><code>String property = this.property;
</co... | [
{
"answer_id": 127,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 7,
"selected": true,
"text": "<p>This has religious war potential, but it seems to me that if you're using a getter/setter, you should use it internally as w... | 2008/08/01 | [
"https://Stackoverflow.com/questions/126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58/"
] | What is the "purist" or "correct" way to access an object's properties from within an object method that is not a getter/setter method?
I know that from outside of the object you should use a getter/setter, but from within would you just do:
Java:
```
String property = this.property;
```
PHP:
```
$property = $thi... | This has religious war potential, but it seems to me that if you're using a getter/setter, you should use it internally as well - using both will lead to maintenance problems down the road (e.g. somebody adds code to a setter that *needs* to run every time that property is set, and the property is being set internally ... |
146 | <p>I have a website that plays mp3s in a flash player. If a user clicks 'play' the flash player automatically downloads an mp3 and starts playing it. </p>
<p>Is there an easy way to track how many times a particular song clip (or any binary file) has been downloaded?</p>
<hr>
<blockquote>
<p>Is the play link a lin... | [
{
"answer_id": 148,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 3,
"selected": false,
"text": "<p>Is the play link a link to the actual mp3 file or to some javascript code that pops up a player? </p>\n\n<p>If the latter, you ... | 2008/08/01 | [
"https://Stackoverflow.com/questions/146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30/"
] | I have a website that plays mp3s in a flash player. If a user clicks 'play' the flash player automatically downloads an mp3 and starts playing it.
Is there an easy way to track how many times a particular song clip (or any binary file) has been downloaded?
---
>
> Is the play link a link to the actual
> mp3 file ... | The funny thing is I wrote a php media gallery for all my musics 2 days ago. I had a similar problem. I'm using <http://musicplayer.sourceforge.net/> for the player. And the playlist is built via php. All music requests go to a script called xfer.php?file=WHATEVER
```
$filename = base64_url_decode($_REQUEST['file']);
... |
164 | <p><strong>Edit:</strong> This question was written in 2008, which was like 3 internet ages ago. If this question is still relevant to your environment, please accept my condolences. Everyone else should convert into a format <a href="https://videojs.com/html5-video-support/" rel="noreferrer">supported by your browsers... | [
{
"answer_id": 167,
"author": "Grant",
"author_id": 30,
"author_profile": "https://Stackoverflow.com/users/30",
"pm_score": 3,
"selected": false,
"text": "<p>You could use conditional comments to get IE and Firefox to do different things</p>\n\n<pre><code><![if !IE]>\n<p> Fir... | 2008/08/01 | [
"https://Stackoverflow.com/questions/164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | **Edit:** This question was written in 2008, which was like 3 internet ages ago. If this question is still relevant to your environment, please accept my condolences. Everyone else should convert into a format [supported by your browsers](https://videojs.com/html5-video-support/) (That would be H.264 if Internet Explor... | The following works for me in Firefox and Internet Explorer:
```html
<object id="mediaplayer" classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52,701" standby="loading microsoft windows media player components..." type="app... |
173 | <p>I want to get my databases under version control.</p>
<p>I'll always want to have at least <em>some</em> data in there (as <a href="https://stackoverflow.com/users/80/alumb">alumb</a> mentions: user types and administrators). I'll also often want a large collection of generated test data for performance measurements... | [
{
"answer_id": 195,
"author": "alumb",
"author_id": 80,
"author_profile": "https://Stackoverflow.com/users/80",
"pm_score": 5,
"selected": false,
"text": "<p>This is one of the \"hard problems\" surrounding development. As far as I know there are no perfect solutions. </p>\n\n<p>If you o... | 2008/08/01 | [
"https://Stackoverflow.com/questions/173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | I want to get my databases under version control.
I'll always want to have at least *some* data in there (as [alumb](https://stackoverflow.com/users/80/alumb) mentions: user types and administrators). I'll also often want a large collection of generated test data for performance measurements.
How would I apply versio... | Martin Fowler wrote my favorite article on the subject, <http://martinfowler.com/articles/evodb.html>. I choose not to put schema dumps in under version control as *alumb* and others suggest because I want an easy way to upgrade my production database.
For a web application where I'll have a single production database... |
174 | <p>I want to print HTML from a C# web service. The web browser control is overkill, and does not function well in a service environment, nor does it function well on a system with very tight security constraints. Is there any sort of free <code>.NET</code> library that will support the printing of a basic HTML page? ... | [
{
"answer_id": 290,
"author": "EndangeredMassa",
"author_id": 106,
"author_profile": "https://Stackoverflow.com/users/106",
"pm_score": 3,
"selected": false,
"text": "<p>I know that Visual Studio itself (at least in 2003 version) references the IE dll directly to render the \"Design View... | 2008/08/01 | [
"https://Stackoverflow.com/questions/174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96/"
] | I want to print HTML from a C# web service. The web browser control is overkill, and does not function well in a service environment, nor does it function well on a system with very tight security constraints. Is there any sort of free `.NET` library that will support the printing of a basic HTML page? Here is the code... | You can print from the command line using the following:
>
> rundll32.exe
> %WINDIR%\System32\mshtml.dll,PrintHTML
> "%1"
>
>
>
Where %1 is the file path of the HTML file to be printed.
If you don't need to print from memory (or can afford to write to the disk in a temp file) you can use:
```
using (Process p... |
175 | <p>I want to be able to display a normal YouTube video with overlaid annotations, consisting of coloured rectangles for each frame. The only requirement is that this should be done programmatically. </p>
<p>YouTube has annotations now, but require you to use their front end to create them by hand. I want to be able to... | [
{
"answer_id": 7157,
"author": "grapefrukt",
"author_id": 914,
"author_profile": "https://Stackoverflow.com/users/914",
"pm_score": 3,
"selected": false,
"text": "<p>The player itself has a <a href=\"http://code.google.com/apis/youtube/js_api_reference.html\" rel=\"noreferrer\">Javascrip... | 2008/08/01 | [
"https://Stackoverflow.com/questions/175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2089740/"
] | I want to be able to display a normal YouTube video with overlaid annotations, consisting of coloured rectangles for each frame. The only requirement is that this should be done programmatically.
YouTube has annotations now, but require you to use their front end to create them by hand. I want to be able to generate ... | YouTube provides an [ActionScript API](http://code.google.com/apis/youtube/flash_api_reference.html).
Using this, you could load the videos into Flash using their API and then have your Flash app create the annotations on a layer above the video.
Or, alternatively, if you want to stay away from creating something in... |
176 | <p>On one Linux Server running Apache and PHP 5, we have multiple Virtual Hosts with separate log files. We cannot seem to separate the php <code>error_log</code> between virtual hosts.</p>
<p>Overriding this setting in the <code><Location></code> of the <code>httpd.conf</code> does not seem to do anything.</p>
... | [
{
"answer_id": 207,
"author": "helloandre",
"author_id": 50,
"author_profile": "https://Stackoverflow.com/users/50",
"pm_score": 7,
"selected": true,
"text": "<p>To set the <em>Apache</em> (<em>not the PHP</em>) log, the easiest way to do this would be to do:</p>\n\n<pre><code><Virtua... | 2008/08/01 | [
"https://Stackoverflow.com/questions/176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | On one Linux Server running Apache and PHP 5, we have multiple Virtual Hosts with separate log files. We cannot seem to separate the php `error_log` between virtual hosts.
Overriding this setting in the `<Location>` of the `httpd.conf` does not seem to do anything.
Is there a way to have separate php `error_logs` for... | To set the *Apache* (*not the PHP*) log, the easiest way to do this would be to do:
```
<VirtualHost IP:Port>
# Stuff,
# More Stuff,
ErrorLog /path/where/you/want/the/error.log
</VirtualHost>
```
If there is no leading "/" it is assumed to be relative.
[Apache Error Log Page](http://httpd.apache.org/docs/1... |
180 | <p>This is something I've pseudo-solved many times and have never quite found a solution for.</p>
<p>The problem is to come up with a way to generate <code>N</code> colors, that are as distinguishable as possible where <code>N</code> is a parameter.</p>
| [
{
"answer_id": 199,
"author": "helloandre",
"author_id": 50,
"author_profile": "https://Stackoverflow.com/users/50",
"pm_score": 2,
"selected": false,
"text": "<p>I've read somewhere the human eye can't distinguish between less than 4 values apart. so This is something to keep in mind. T... | 2008/08/01 | [
"https://Stackoverflow.com/questions/180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2089740/"
] | This is something I've pseudo-solved many times and have never quite found a solution for.
The problem is to come up with a way to generate `N` colors, that are as distinguishable as possible where `N` is a parameter. | My first thought on this is "how to generate N vectors in a space that maximize distance from each other."
You can see that the RGB (or any other scale you use that forms a basis in color space) are just vectors. Take a look at [Random Point Picking](http://mathworld.wolfram.com/topics/RandomPointPicking.html). Once y... |
227 | <p>I have the following arrays:</p>
<pre><code>$artist = array("the roots", "michael jackson", "billy idol", "more", "and more", "and_YET_MORE");
$count = array(5, 3, 9, 1, 1, 3);
</code></pre>
<p>I want to generate a tag cloud that will have artists with a higher number in <code>$count</code> enclosed in <code>h6</c... | [
{
"answer_id": 253,
"author": "Ryan Fox",
"author_id": 55,
"author_profile": "https://Stackoverflow.com/users/55",
"pm_score": 5,
"selected": false,
"text": "<p>Off the top of my head...</p>\n\n<pre><code>$artist = array(\"the roots\",\"michael jackson\",\"billy idol\",\"more\",\"and mor... | 2008/08/01 | [
"https://Stackoverflow.com/questions/227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/146637/"
] | I have the following arrays:
```
$artist = array("the roots", "michael jackson", "billy idol", "more", "and more", "and_YET_MORE");
$count = array(5, 3, 9, 1, 1, 3);
```
I want to generate a tag cloud that will have artists with a higher number in `$count` enclosed in `h6` tags and the lowest enclosed `h1` tags. | You will want to add a logarithmic function to it too. (taken from tagadelic, my Drupal module to create tag clouds <http://drupal.org/project/tagadelic>):
```
db_query('SELECT COUNT(*) AS count, id, name FROM ... ORDER BY count DESC');
$steps = 6;
$tags = array();
$min = 1e9;
$max = -1e9;
while ($tag = db_fetch_obj... |
231 | <p>How do I make it so <code>mailto:</code> links will be registered with my program?</p>
<p>How would I then handle that event in my program?</p>
<p>Most of the solutions I found from a quick Google search are how to do this manually, but I need to do this automatically for users of my program if they click a button, ... | [
{
"answer_id": 233,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 4,
"selected": false,
"text": "<p>From what I've seen, there are a few registry keys that set the default mail client. One of them is:</p>\n<p>System Key: <code>... | 2008/08/01 | [
"https://Stackoverflow.com/questions/231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62/"
] | How do I make it so `mailto:` links will be registered with my program?
How would I then handle that event in my program?
Most of the solutions I found from a quick Google search are how to do this manually, but I need to do this automatically for users of my program if they click a button, such as "set as default em... | *@Dillie-O: Your answer put me in the right direction (I should have expected it to just be a registry change) and I got this working. But I'm going to mark this as the answer because I'm going to put some additional information that I found while working on this.*
The solution to this question really doesn't depend o... |
234 | <p>MySQL has this incredibly useful yet proprietary <code>REPLACE INTO</code> SQL Command. </p>
<p>Can this easily be emulated in SQL Server 2005?</p>
<p>Starting a new Transaction, doing a <code>Select()</code> and then either <code>UPDATE</code> or <code>INSERT</code> and <code>COMMIT</code> is always a little bit ... | [
{
"answer_id": 238,
"author": "Karl Seguin",
"author_id": 34,
"author_profile": "https://Stackoverflow.com/users/34",
"pm_score": 4,
"selected": false,
"text": "<p>The functionality you're looking for is traditionally called an UPSERT. Atleast knowing what it's called might help you find... | 2008/08/01 | [
"https://Stackoverflow.com/questions/234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | MySQL has this incredibly useful yet proprietary `REPLACE INTO` SQL Command.
Can this easily be emulated in SQL Server 2005?
Starting a new Transaction, doing a `Select()` and then either `UPDATE` or `INSERT` and `COMMIT` is always a little bit of a pain, especially when doing it in the application and therefore alw... | This is something that annoys me about MSSQL ([rant on my blog](http://bizvprog.blogspot.com/2008/04/annoying-fundamental-flaw-with-sql.html)). I wish MSSQL supported `upsert`.
@Dillie-O's code is a good way in older SQL versions (+1 vote), but it still is basically two IO operations (the `exists` and then the `updat... |
260 | <p>I have a little game written in C#. It uses a database as back-end. It's
a <a href="http://en.wikipedia.org/wiki/Collectible_card_game" rel="noreferrer">trading card game</a>, and I wanted to implement the function of the cards as a script.</p>
<p>What I mean is that I essentially have an interface, <code>ICard</c... | [
{
"answer_id": 269,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, I thought about that, but I soon figured out that another Domain-Specific-Language (DSL) would be a bit too much.</p>\... | 2008/08/01 | [
"https://Stackoverflow.com/questions/260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | I have a little game written in C#. It uses a database as back-end. It's
a [trading card game](http://en.wikipedia.org/wiki/Collectible_card_game), and I wanted to implement the function of the cards as a script.
What I mean is that I essentially have an interface, `ICard`, which a card class implements (`public clas... | [Oleg Shilo's C# Script solution (at The Code Project](https://www.codeproject.com/Articles/8656/C-Script-The-Missing-Puzzle-Piece)) really is a great introduction to providing script abilities in your application.
A different approach would be to consider a language that is specifically built for scripting, such as [... |
263 | <p>I have been trying to implement Win32's <code>MessageBox</code> using GTK. The app uses SDL/OpenGL, so this isn't a GTK app.</p>
<p>I handle the initialization (<code>gtk_init</code>) sort of stuff inside the <code>MessageBox</code> function as follows:</p>
<pre><code>int MessageBox(HWND hwnd, const char* text, cons... | [
{
"answer_id": 537,
"author": "Joe Shaw",
"author_id": 156,
"author_profile": "https://Stackoverflow.com/users/156",
"pm_score": 3,
"selected": false,
"text": "<p>A few things:</p>\n\n<p>You are creating (and not using) an unnecessary toplevel window, named <code>window</code>. You can ... | 2008/08/01 | [
"https://Stackoverflow.com/questions/263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61/"
] | I have been trying to implement Win32's `MessageBox` using GTK. The app uses SDL/OpenGL, so this isn't a GTK app.
I handle the initialization (`gtk_init`) sort of stuff inside the `MessageBox` function as follows:
```
int MessageBox(HWND hwnd, const char* text, const char* caption, UINT type)
{
GtkWidget *window ... | Hmm, ok. I'd suggest code like this, then:
```c
typedef struct {
int type;
int result;
} DialogData;
static gboolean
display_dialog(gpointer user_data)
{
DialogData *dialog_data = user_data;
GtkWidget *dialog;
if (dialog_data->type & MB_YESNO)
dialog = gtk_message_dialog_new(...);
els... |
265 | <p>What are the best practices for checking in BIN directories in a collaborative development environment using SVN? Should project level references be excluded from checkin? Is it easier to just add all bin directories?</p>
<p>I develop a lot of DotNetNuke sites and it seems that in a multi-developer environment, i... | [
{
"answer_id": 266,
"author": "Karl Seguin",
"author_id": 34,
"author_profile": "https://Stackoverflow.com/users/34",
"pm_score": 5,
"selected": true,
"text": "<p>Any assemblies that are expected to be in the GAC should stay in the GAC. This includes System.web.dll or any other 3rd party... | 2008/08/01 | [
"https://Stackoverflow.com/questions/265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/105/"
] | What are the best practices for checking in BIN directories in a collaborative development environment using SVN? Should project level references be excluded from checkin? Is it easier to just add all bin directories?
I develop a lot of DotNetNuke sites and it seems that in a multi-developer environment, it's always a... | Any assemblies that are expected to be in the GAC should stay in the GAC. This includes System.web.dll or any other 3rd party dll that you'll deploy to the GAC in production. This means a new developer would have to install these assemblies.
All other 3rd party assemblies should be references through a relative path. ... |
289 | <p>I often have to sort a dictionary (consisting of keys & values) by value. For example, I have a hash of words and respective frequencies that I want to order by frequency.</p>
<p>There is a <code>SortedList</code> which is good for a single value (say frequency), that I want to map back to the word.</p>
<p><a hr... | [
{
"answer_id": 291,
"author": "Kalid",
"author_id": 109,
"author_profile": "https://Stackoverflow.com/users/109",
"pm_score": 7,
"selected": false,
"text": "<p>Looking around, and using some C# 3.0 features we can do this:</p>\n\n<pre><code>foreach (KeyValuePair<string,int> item in... | 2008/08/02 | [
"https://Stackoverflow.com/questions/289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/109/"
] | I often have to sort a dictionary (consisting of keys & values) by value. For example, I have a hash of words and respective frequencies that I want to order by frequency.
There is a `SortedList` which is good for a single value (say frequency), that I want to map back to the word.
[SortedDictionary](http://msdn.micr... | Use:
```
using System.Linq.Enumerable;
...
List<KeyValuePair<string, string>> myList = aDictionary.ToList();
myList.Sort(
delegate(KeyValuePair<string, string> pair1,
KeyValuePair<string, string> pair2)
{
return pair1.Value.CompareTo(pair2.Value);
}
);
```
Since you're targeting .NET 2.0 or ... |
336 | <p>When is it appropriate to use an unsigned variable over a signed one? What about in a <code>for</code> loop?</p>
<p>I hear a lot of opinions about this and I wanted to see if there was anything resembling a consensus. </p>
<pre><code>for (unsigned int i = 0; i < someThing.length(); i++) {
SomeThing var = ... | [
{
"answer_id": 339,
"author": "saint_groceon",
"author_id": 59,
"author_profile": "https://Stackoverflow.com/users/59",
"pm_score": 7,
"selected": true,
"text": "<p>I was glad to find <a href=\"https://web.archive.org/web/20170323034837/http://coding.derkeiler.com/Archive/C_CPP/comp.lang... | 2008/08/02 | [
"https://Stackoverflow.com/questions/336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61/"
] | When is it appropriate to use an unsigned variable over a signed one? What about in a `for` loop?
I hear a lot of opinions about this and I wanted to see if there was anything resembling a consensus.
```
for (unsigned int i = 0; i < someThing.length(); i++) {
SomeThing var = someThing.at(i);
// You get t... | I was glad to find [a good conversation](https://web.archive.org/web/20170323034837/http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2004-02/1382.html) on this subject, as I hadn't really given it much thought before.
In summary, signed is a good general choice - even when you're dead sure all the numbers are pos... |
361 | <p>How would I go about generating a list of all possible permutations of a string between x and y characters in length, containing a variable list of characters.</p>
<p>Any language would work, but it should be portable.</p>
| [
{
"answer_id": 362,
"author": "alumb",
"author_id": 80,
"author_profile": "https://Stackoverflow.com/users/80",
"pm_score": 7,
"selected": true,
"text": "<p>There are several ways to do this. Common methods use recursion, memoization, or dynamic programming. The basic idea is that you pr... | 2008/08/02 | [
"https://Stackoverflow.com/questions/361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] | How would I go about generating a list of all possible permutations of a string between x and y characters in length, containing a variable list of characters.
Any language would work, but it should be portable. | There are several ways to do this. Common methods use recursion, memoization, or dynamic programming. The basic idea is that you produce a list of all strings of length 1, then in each iteration, for all strings produced in the last iteration, add that string concatenated with each character in the string individually.... |
402 | <p>Please note that this question is from 2008 and now is of only historic interest.</p>
<hr>
<p>What's the best way to create an iPhone application that runs in landscape mode from the start, regardless of the position of the device?</p>
<p>Both programmatically and using the Interface Builder.</p>
| [
{
"answer_id": 36884,
"author": "Michael Pryor",
"author_id": 245,
"author_profile": "https://Stackoverflow.com/users/245",
"pm_score": 5,
"selected": false,
"text": "<p>From the Apple Dev Site:</p>\n\n<blockquote>\n <p>To start your application in landscape\n mode so that the status b... | 2008/08/02 | [
"https://Stackoverflow.com/questions/402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/136/"
] | Please note that this question is from 2008 and now is of only historic interest.
---
What's the best way to create an iPhone application that runs in landscape mode from the start, regardless of the position of the device?
Both programmatically and using the Interface Builder. | Historic answer only. Spectacularly out of date.
================================================
Please note that this answer is now hugely out of date/
This answer is **only a historical curiosity**.
---
Exciting news! As discovered by Andrew below, this problem has been fixed by Apple in 4.0+.
It would appear i... |
438 | <p>My Rails-app has a sign in box with a "remember me" checkbox. Users who check that box should remain logged in even after closing their browser. I'm keeping track of whether users are logged in by storing their id in the user's session. </p>
<p>But sessions are implemented in Rails as session cookies, which are not... | [
{
"answer_id": 483,
"author": "Gareth Simpson",
"author_id": 147,
"author_profile": "https://Stackoverflow.com/users/147",
"pm_score": 5,
"selected": false,
"text": "<p>You should almost certainly not be extending the session cookie to be long lived.</p>\n\n<p>Although not dealing specif... | 2008/08/02 | [
"https://Stackoverflow.com/questions/438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/136/"
] | My Rails-app has a sign in box with a "remember me" checkbox. Users who check that box should remain logged in even after closing their browser. I'm keeping track of whether users are logged in by storing their id in the user's session.
But sessions are implemented in Rails as session cookies, which are not persisten... | I have spent a while thinking about this and came to some conclusions. Rails session cookies are tamper-proof by default, so you really don't have to worry about a cookie being modified on the client end.
Here is what I've done:
* Session cookie is set to be long-lived (6 months or so)
* Inside the session store
+ A... |
482 | <p>Assume you are doing something like the following</p>
<pre><code>List<string> myitems = new List<string>
{
"Item 1",
"Item 2",
"Item 3"
};
ComboBox box = new ComboBox();
box.DataSource = myitems;
ComboBox box2 = new ComboBox();
box2.DataSource = myitems
</code></pre>
<p>So now we have 2 c... | [
{
"answer_id": 509,
"author": "Robert Höglund",
"author_id": 143,
"author_profile": "https://Stackoverflow.com/users/143",
"pm_score": 6,
"selected": true,
"text": "<p>This has to do with how data bindings are set up in the dotnet framework, especially the <code>BindingContext</code>. On... | 2008/08/02 | [
"https://Stackoverflow.com/questions/482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/77/"
] | Assume you are doing something like the following
```
List<string> myitems = new List<string>
{
"Item 1",
"Item 2",
"Item 3"
};
ComboBox box = new ComboBox();
box.DataSource = myitems;
ComboBox box2 = new ComboBox();
box2.DataSource = myitems
```
So now we have 2 combo boxes bound to that array, and ev... | This has to do with how data bindings are set up in the dotnet framework, especially the `BindingContext`. On a high level it means that if you haven't specified otherwise each form and all the controls of the form share the same `BindingContext`. When you are setting the `DataSource` property the `ComboBox` will use t... |
502 | <p>I have a cross-platform (Python) application which needs to generate a JPEG preview of the first page of a PDF.</p>
<p>On the Mac I am spawning <a href="http://web.archive.org/web/20090309234215/http://developer.apple.com:80/documentation/Darwin/Reference/ManPages/man1/sips.1.html" rel="noreferrer">sips</a>. Is th... | [
{
"answer_id": 536,
"author": "Federico Builes",
"author_id": 161,
"author_profile": "https://Stackoverflow.com/users/161",
"pm_score": 4,
"selected": false,
"text": "<p>You can use ImageMagick's convert utility for this, see some examples in <a href=\"https://web.archive.org/web/2012041... | 2008/08/02 | [
"https://Stackoverflow.com/questions/502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147/"
] | I have a cross-platform (Python) application which needs to generate a JPEG preview of the first page of a PDF.
On the Mac I am spawning [sips](http://web.archive.org/web/20090309234215/http://developer.apple.com:80/documentation/Darwin/Reference/ManPages/man1/sips.1.html). Is there something similarly simple I can do... | ImageMagick delegates the PDF->bitmap conversion to GhostScript anyway, so here's a command you can use (it's based on the actual command listed by the `ps:alpha` delegate in ImageMagick, just adjusted to use JPEG as output):
```
gs -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT \
-dMaxBitmap=500000000 -dLast... |
561 | <p>I would like to test a function with a tuple from a set of fringe cases and normal values. For example, while testing a function which returns <code>true</code> whenever given three lengths that form a valid triangle, I would have specific cases, negative / small / large numbers, values close-to being overflowed, et... | [
{
"answer_id": 589,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 2,
"selected": false,
"text": "<p>Interesting question!</p>\n\n<p>I would do this by picking combinations, something like the following in python. The ha... | 2008/08/02 | [
"https://Stackoverflow.com/questions/561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/157/"
] | I would like to test a function with a tuple from a set of fringe cases and normal values. For example, while testing a function which returns `true` whenever given three lengths that form a valid triangle, I would have specific cases, negative / small / large numbers, values close-to being overflowed, etc.; what is mo... | Absolutely, especially dealing with lots of these permutations/combinations I can definitely see that the first pass would be an issue.
Interesting implementation in python, though I wrote a nice one in C and Ocaml based on "Algorithm 515" (see below). He wrote his in Fortran as it was common back then for all the "Al... |
594 | <p>There are several ways to iterate over a result set. What are the tradeoff of each?</p>
| [
{
"answer_id": 595,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 7,
"selected": true,
"text": "<p>The canonical way is to use the built-in cursor iterator.</p>\n\n<pre><code>curs.execute('select * from people')\nfor row... | 2008/08/03 | [
"https://Stackoverflow.com/questions/594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | There are several ways to iterate over a result set. What are the tradeoff of each? | The canonical way is to use the built-in cursor iterator.
```
curs.execute('select * from people')
for row in curs:
print row
```
---
You can use `fetchall()` to get all rows at once.
```
for row in curs.fetchall():
print row
```
It can be convenient to use this to create a Python list containing the val... |
626 | <p>In Ruby 1.8, there are subtle differences between proc/lambda on the one hand, and <code>Proc.new</code> on the other. </p>
<ul>
<li>What are those differences?</li>
<li>Can you give guidelines on how to decide which one to choose?</li>
<li>In Ruby 1.9, proc and lambda are different. What's the deal?</li>
</ul>
| [
{
"answer_id": 629,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 5,
"selected": false,
"text": "<p>I found <a href=\"http://raulparolari.com/Ruby2/lambda_Proc\" rel=\"noreferrer\">this page</a> which shows what the differe... | 2008/08/03 | [
"https://Stackoverflow.com/questions/626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/136/"
] | In Ruby 1.8, there are subtle differences between proc/lambda on the one hand, and `Proc.new` on the other.
* What are those differences?
* Can you give guidelines on how to decide which one to choose?
* In Ruby 1.9, proc and lambda are different. What's the deal? | Another important but subtle difference between procs created with `lambda` and procs created with `Proc.new` is how they handle the `return` statement:
* In a `lambda`-created proc, the `return` statement returns only from the proc itself
* In a `Proc.new`-created proc, the `return` statement is a little more surpris... |
650 | <p>I would like the version property of my application to be incremented for each build but I'm not sure on how to enable this functionality in Visual Studio (2005/2008). I have tried to specify the AssemblyVersion as 1.0.* but it doesn't get me exactly what I want. </p>
<p>I'm also using a settings file and in earlie... | [
{
"answer_id": 655,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 8,
"selected": true,
"text": "<p>With the \"Built in\" stuff, you can't, as using 1.0.* or 1.0.0.* will replace the revision and build numbers with a coded d... | 2008/08/03 | [
"https://Stackoverflow.com/questions/650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/143/"
] | I would like the version property of my application to be incremented for each build but I'm not sure on how to enable this functionality in Visual Studio (2005/2008). I have tried to specify the AssemblyVersion as 1.0.\* but it doesn't get me exactly what I want.
I'm also using a settings file and in earlier attempt... | With the "Built in" stuff, you can't, as using 1.0.\* or 1.0.0.\* will replace the revision and build numbers with a coded date/timestamp, which is usually also a good way.
For more info, see the [Assembly Linker](http://msdn2.microsoft.com/en-us/library/c405shex(vs.80).aspx) Documentation in the /v tag.
As for auto... |
683 | <p>I don't remember whether I was dreaming or not but I seem to recall there being a function which allowed something like,</p>
<pre><code>foo in iter_attr(array of python objects, attribute name)</code></pre>
<p>I've looked over the docs but this kind of thing doesn't fall under any obvious listed headers</p>
| [
{
"answer_id": 701,
"author": "saalon",
"author_id": 111,
"author_profile": "https://Stackoverflow.com/users/111",
"pm_score": 3,
"selected": false,
"text": "<p>No, you were not dreaming. Python has a pretty excellent list comprehension system that lets you manipulate lists pretty elega... | 2008/08/03 | [
"https://Stackoverflow.com/questions/683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/199/"
] | I don't remember whether I was dreaming or not but I seem to recall there being a function which allowed something like,
```
foo in iter_attr(array of python objects, attribute name)
```
I've looked over the docs but this kind of thing doesn't fall under any obvious listed headers | Using a list comprehension would build a temporary list, which could eat all your memory if the sequence being searched is large. Even if the sequence is not large, building the list means iterating over the whole of the sequence before `in` could start its search.
The temporary list can be avoiding by using a generat... |
746 | <p>How do I format a string to <a href="http://www.grammar-monster.com/lessons/capital_letters_title_case.htm" rel="noreferrer">title case</a>?</p>
| [
{
"answer_id": 747,
"author": "tags2k",
"author_id": 192,
"author_profile": "https://Stackoverflow.com/users/192",
"pm_score": 4,
"selected": false,
"text": "<p>Here is a simple static method to do this in C#:</p>\n\n<pre><code>public static string ToTitleCaseInvariant(string targetStrin... | 2008/08/03 | [
"https://Stackoverflow.com/questions/746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | How do I format a string to [title case](http://www.grammar-monster.com/lessons/capital_letters_title_case.htm)? | Here is a simple static method to do this in C#:
```
public static string ToTitleCaseInvariant(string targetString)
{
return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(targetString);
}
``` |
752 | <p>One may not always know the <code>Type</code> of an object at compile-time, but may need to create an instance of the <code>Type</code>. </p>
<p>How do you get a new object instance from a <code>Type</code>?</p>
| [
{
"answer_id": 755,
"author": "Karl Seguin",
"author_id": 34,
"author_profile": "https://Stackoverflow.com/users/34",
"pm_score": 11,
"selected": true,
"text": "<p>The <code>Activator</code> class within the root <code>System</code> namespace is pretty powerful.</p>\n\n<p>There are a lot... | 2008/08/03 | [
"https://Stackoverflow.com/questions/752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | One may not always know the `Type` of an object at compile-time, but may need to create an instance of the `Type`.
How do you get a new object instance from a `Type`? | The `Activator` class within the root `System` namespace is pretty powerful.
There are a lot of overloads for passing parameters to the constructor and such. Check out the documentation at:
>
> <http://msdn.microsoft.com/en-us/library/system.activator.createinstance.aspx>
>
>
>
or (new path)
>
> <https://lear... |
761 | <p>What is the best way to localise a date format descriptor?</p>
<p>As anyone from a culture which does not use the mm/dd/yyyy format knows, it is annoying to have to enter dates in this format. The .NET framework provides some very good localisation support, so it's trivial to parse dates according to the users cult... | [
{
"answer_id": 762,
"author": "ICR",
"author_id": 214,
"author_profile": "https://Stackoverflow.com/users/214",
"pm_score": 3,
"selected": true,
"text": "<p>Here is my current method. Any suggestions?</p>\n\n<pre><code>Regex singleMToDoubleRegex = new Regex(\"(?<!m)m(?!m)\");\nRegex s... | 2008/08/03 | [
"https://Stackoverflow.com/questions/761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/214/"
] | What is the best way to localise a date format descriptor?
As anyone from a culture which does not use the mm/dd/yyyy format knows, it is annoying to have to enter dates in this format. The .NET framework provides some very good localisation support, so it's trivial to parse dates according to the users culture, but y... | Here is my current method. Any suggestions?
```
Regex singleMToDoubleRegex = new Regex("(?<!m)m(?!m)");
Regex singleDToDoubleRegex = new Regex("(?<!d)d(?!d)");
CultureInfo currentCulture = CultureInfo.CurrentUICulture;
// If the culture is netural there is no date pattern to use, so use the default.
if (currentCultur... |
769 | <p>I need to programmatically solve a system of linear equations in C, Objective C, or (if needed) C++.</p>
<p>Here's an example of the equations:</p>
<pre><code>-44.3940 = a * 50.0 + b * 37.0 + tx
-45.3049 = a * 43.0 + b * 39.0 + tx
-44.9594 = a * 52.0 + b * 41.0 + tx
</code></pre>
<p>From this, I'd like to get the... | [
{
"answer_id": 774,
"author": "nlucaroni",
"author_id": 157,
"author_profile": "https://Stackoverflow.com/users/157",
"pm_score": 2,
"selected": false,
"text": "<p>Are you looking for a software package that'll do the work or actually doing the matrix operations and such and do each step... | 2008/08/03 | [
"https://Stackoverflow.com/questions/769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/79/"
] | I need to programmatically solve a system of linear equations in C, Objective C, or (if needed) C++.
Here's an example of the equations:
```
-44.3940 = a * 50.0 + b * 37.0 + tx
-45.3049 = a * 43.0 + b * 39.0 + tx
-44.9594 = a * 52.0 + b * 41.0 + tx
```
From this, I'd like to get the best approximation for `a`, `b`,... | [Cramer's Rule](http://en.wikipedia.org/wiki/Cramers_rule)
and
[Gaussian Elimination](http://en.wikipedia.org/wiki/Gaussian_elimination)
are two good, general-purpose algorithms (also see [Simultaneous Linear Equations](http://en.wikipedia.org/wiki/Simultaneous_linear_equations)). If you're looking for code, check out ... |
773 | <p>I haven't been able to find an understandable explanation of how to actually use Python's <code>itertools.groupby()</code> function. What I'm trying to do is this:</p>
<ul>
<li>Take a list - in this case, the children of an objectified <code>lxml</code> element</li>
<li>Divide it into groups based on some criteria<... | [
{
"answer_id": 783,
"author": "Seb",
"author_id": 189,
"author_profile": "https://Stackoverflow.com/users/189",
"pm_score": 6,
"selected": false,
"text": "<p>The example on the Python docs is quite straightforward:</p>\n\n<pre><code>groups = []\nuniquekeys = []\nfor k, g in groupby(data,... | 2008/08/03 | [
"https://Stackoverflow.com/questions/773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/207/"
] | I haven't been able to find an understandable explanation of how to actually use Python's `itertools.groupby()` function. What I'm trying to do is this:
* Take a list - in this case, the children of an objectified `lxml` element
* Divide it into groups based on some criteria
* Then later iterate over each of these gro... | **IMPORTANT NOTE:** You have to **sort your data** first.
---
The part I didn't get is that in the example construction
```
groups = []
uniquekeys = []
for k, g in groupby(data, keyfunc):
groups.append(list(g)) # Store group iterator as a list
uniquekeys.append(k)
```
`k` is the current grouping key, and ... |
810 | <p>I'm trying to maintain a Setup Project in <code>Visual Studio 2003</code> (yes, it's a legacy application). The problem we have at the moment is that we need to write registry entries to <code>HKCU</code> for every user on the computer. They need to be in the <code>HKCU</code> rather than <code>HKLM</code> because t... | [
{
"answer_id": 818,
"author": "Ray",
"author_id": 233,
"author_profile": "https://Stackoverflow.com/users/233",
"pm_score": 2,
"selected": false,
"text": "<p>I'm partway to my solution with this entry on MSDN (don't know how I couldn't find it before).</p>\n\n<p>User/Machine Hive<br>\nSu... | 2008/08/03 | [
"https://Stackoverflow.com/questions/810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233/"
] | I'm trying to maintain a Setup Project in `Visual Studio 2003` (yes, it's a legacy application). The problem we have at the moment is that we need to write registry entries to `HKCU` for every user on the computer. They need to be in the `HKCU` rather than `HKLM` because they are the default user settings, and they do ... | First: Yes, this is something that belongs in the Application for the exact reson you specified: What happens after new user profiles are created? Sure, if you're using a domain it's possible to have some stuff put in the registry on creation, but this is not really a use case. The Application should check if there are... |
826 | <p>You have an ascending list of numbers, what is the most efficient algorithm you can think of to get the ascending list of sums of every two numbers in that list. Duplicates in the resulting list are irrelevant, you can remove them or avoid them if you like.</p>
<p>To be clear, I'm interested in the algorithm. Fee... | [
{
"answer_id": 834,
"author": "John Downey",
"author_id": 200,
"author_profile": "https://Stackoverflow.com/users/200",
"pm_score": -1,
"selected": false,
"text": "<p>If you are looking for a truly language agnostic solution then you will be sorely disappointed in my opinion because you'... | 2008/08/03 | [
"https://Stackoverflow.com/questions/826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/101/"
] | You have an ascending list of numbers, what is the most efficient algorithm you can think of to get the ascending list of sums of every two numbers in that list. Duplicates in the resulting list are irrelevant, you can remove them or avoid them if you like.
To be clear, I'm interested in the algorithm. Feel free to po... | Edit as of 2018: You should probably stop reading this. (But I can't delete it as it is accepted.)
If you write out the sums like this:
```
1 4 5 6 8 9
---------------
2 5 6 7 9 10
8 9 10 12 13
10 11 13 14
12 14 15
16 17
18
```
You'll notice that since M[i,j] <= M[i,j+1] ... |
832 | <p>SQL:</p>
<pre><code>SELECT
u.id,
u.name,
isnull(MAX(h.dateCol), '1900-01-01') dateColWithDefault
FROM universe u
LEFT JOIN history h
ON u.id=h.id
AND h.dateCol<GETDATE()-1
GROUP BY u.Id, u.name
</code></pre>
| [
{
"answer_id": 837,
"author": "vzczc",
"author_id": 224,
"author_profile": "https://Stackoverflow.com/users/224",
"pm_score": 4,
"selected": true,
"text": "<p>A solution, albeit one that defers handling of the null value to the code, could be:</p>\n\n<blockquote>\n <p>DateTime yesterday... | 2008/08/03 | [
"https://Stackoverflow.com/questions/832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/224/"
] | SQL:
```
SELECT
u.id,
u.name,
isnull(MAX(h.dateCol), '1900-01-01') dateColWithDefault
FROM universe u
LEFT JOIN history h
ON u.id=h.id
AND h.dateCol<GETDATE()-1
GROUP BY u.Id, u.name
``` | A solution, albeit one that defers handling of the null value to the code, could be:
>
> DateTime yesterday = DateTime.Now.Date.AddDays(-1);
>
>
>
```
var collection=
from u in db.Universe
select new
{
u.id,
u.name,
MaxDate =(DateTime?)
(
from h in db.History
... |
835 | <p>I'm trying to setup CruiseControl.net at the moment. So far it works nice, but I have a Problem with the MSBuild Task.</p>
<p>According to the <a href="http://confluence.public.thoughtworks.org/display/CCNET/MsBuild+Task" rel="noreferrer">Documentation</a>, it passes CCNetArtifactDirectory to MSBuild. But how do I ... | [
{
"answer_id": 1023,
"author": "FryHard",
"author_id": 231,
"author_profile": "https://Stackoverflow.com/users/231",
"pm_score": 4,
"selected": true,
"text": "<p>The CCNetArtifactDirectory is passed to the MSBuild by default, so you dont need to worry about it. MSBuild will place the bui... | 2008/08/03 | [
"https://Stackoverflow.com/questions/835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | I'm trying to setup CruiseControl.net at the moment. So far it works nice, but I have a Problem with the MSBuild Task.
According to the [Documentation](http://confluence.public.thoughtworks.org/display/CCNET/MsBuild+Task), it passes CCNetArtifactDirectory to MSBuild. But how do I use it?
I tried this:
```
<buildArgs... | The CCNetArtifactDirectory is passed to the MSBuild by default, so you dont need to worry about it. MSBuild will place the build output in the "bin location" relevant to the working directory that you have specified.
```
<executable>c:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>C:\... |
845 | <p>Suppose I have the following CSS rule in my page:</p>
<pre class="lang-css prettyprint-override"><code>body {
font-family: Calibri, Trebuchet MS, Helvetica, sans-serif;
}
</code></pre>
<p>How could I detect which one of the defined fonts were used in the user's browser?</p>
<p>For people wondering why I want to ... | [
{
"answer_id": 849,
"author": "MojoFilter",
"author_id": 93,
"author_profile": "https://Stackoverflow.com/users/93",
"pm_score": 7,
"selected": true,
"text": "<p>I've seen it done in a kind of iffy, but pretty reliable way. Basically, an element is set to use a specific font and a string... | 2008/08/03 | [
"https://Stackoverflow.com/questions/845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/238/"
] | Suppose I have the following CSS rule in my page:
```css
body {
font-family: Calibri, Trebuchet MS, Helvetica, sans-serif;
}
```
How could I detect which one of the defined fonts were used in the user's browser?
For people wondering why I want to do this is because the font I'm detecting contains glyphs that ar... | I've seen it done in a kind of iffy, but pretty reliable way. Basically, an element is set to use a specific font and a string is set to that element. If the font set for the element does not exist, it takes the font of the parent element. So, what they do is measure the width of the rendered string. If it matches what... |
879 | <p>Are PHP variables passed by value or by reference?</p>
| [
{
"answer_id": 880,
"author": "Karl Seguin",
"author_id": 34,
"author_profile": "https://Stackoverflow.com/users/34",
"pm_score": -1,
"selected": false,
"text": "<p>Depends on the version, 4 is by value, 5 is by reference.</p>\n"
},
{
"answer_id": 881,
"author": "cmcculloh",
... | 2008/08/03 | [
"https://Stackoverflow.com/questions/879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58/"
] | Are PHP variables passed by value or by reference? | It's by value according to the [PHP Documentation](http://php.net/manual/en/functions.arguments.php).
>
> By default, function arguments are passed by value (so that if the value of the argument within the function is changed, it does not get changed outside of the function). To allow a function to modify its argumen... |
904 | <p>Given a relatively simple CSS:</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-css lang-css prettyprint-override"><code>div {
width: 150px;
}</code></pre>
<pre class="snippet-code-html lang-html prettypri... | [
{
"answer_id": 911,
"author": "Ryan Fox",
"author_id": 55,
"author_profile": "https://Stackoverflow.com/users/55",
"pm_score": 7,
"selected": true,
"text": "<p>Replace your hyphens with this:</p>\n\n<pre><code>&shy;\n</code></pre>\n\n<p>It's called a \"soft\" hyphen.</p>\n\n<p><div c... | 2008/08/04 | [
"https://Stackoverflow.com/questions/904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34/"
] | Given a relatively simple CSS:
```css
div {
width: 150px;
}
```
```html
<div>
12333-2333-233-23339392-332332323
</div>
```
>
> How do I make it so that the string stays constrained to the `width`
> of **150**, and wraps to a new line on the *hyphen*?
>
>
> | Replace your hyphens with this:
```
­
```
It's called a "soft" hyphen.
```css
div {
width: 150px;
}
```
```html
<div>
12333­2333­233­23339392­332332323
</div>
``` |
930 | <p>What's the simplest way to connect and query a database for a set of records in C#?</p>
| [
{
"answer_id": 940,
"author": "Goyuix",
"author_id": 243,
"author_profile": "https://Stackoverflow.com/users/243",
"pm_score": 4,
"selected": false,
"text": "<p>Very roughly and from memory since I don't have code on this laptop:</p>\n\n<pre><code>using (OleDBConnection conn = new OleDbC... | 2008/08/04 | [
"https://Stackoverflow.com/questions/930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/245/"
] | What's the simplest way to connect and query a database for a set of records in C#? | @Goyuix -- that's excellent for something written from memory.
tested it here -- found the connection wasn't opened. Otherwise very nice.
```
using System.Data.OleDb;
...
using (OleDbConnection conn = new OleDbConnection())
{
conn.ConnectionString = "Provider=sqloledb;Data Source=yourServername\\yourInstance;Init... |
935 | <p>Attempting to insert an escape character into a table results in a warning. </p>
<p>For example:</p>
<pre><code>create table EscapeTest (text varchar(50));
insert into EscapeTest (text) values ('This is the first part \n And this is the second');
</code></pre>
<p>Produces the warning:</p>
<pre><code>WARNING: n... | [
{
"answer_id": 938,
"author": "rjohnston",
"author_id": 246,
"author_profile": "https://Stackoverflow.com/users/246",
"pm_score": 8,
"selected": true,
"text": "<p>Partially. The text is inserted, but the warning is still generated.</p>\n\n<p>I found a discussion that indicated the text n... | 2008/08/04 | [
"https://Stackoverflow.com/questions/935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/246/"
] | Attempting to insert an escape character into a table results in a warning.
For example:
```
create table EscapeTest (text varchar(50));
insert into EscapeTest (text) values ('This is the first part \n And this is the second');
```
Produces the warning:
```
WARNING: nonstandard use of escape in a string literal... | Partially. The text is inserted, but the warning is still generated.
I found a discussion that indicated the text needed to be preceded with 'E', as such:
```
insert into EscapeTest (text) values (E'This is the first part \n And this is the second');
```
This suppressed the warning, but the text was still not being... |
947 | <p>I have imported the <code>kernel32</code> library. So, I have the <code>createMutex</code> function available but I am not quite sure of the various parameters and return values.</p>
<p>This is classic Visual Basic, not Visual Basic.NET but I can probably work with either language in the form of an answer.</p>
| [
{
"answer_id": 1025,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 1,
"selected": false,
"text": "<p>Well, based on the <a href=\"http://msdn.microsoft.com/en-us/library/ms682411(VS.85).aspx\" rel=\"nofollow noreferrer\">doc... | 2008/08/04 | [
"https://Stackoverflow.com/questions/947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/243/"
] | I have imported the `kernel32` library. So, I have the `createMutex` function available but I am not quite sure of the various parameters and return values.
This is classic Visual Basic, not Visual Basic.NET but I can probably work with either language in the form of an answer. | The VB code looks something like this:
```
hMutex = CreateMutex(ByVal 0&, 1, ByVal 0&)
```
The first parameter is a pointer to an `SECURITY_ATTRIBUTES` structure. If you don't know what it is, you don't need it. Pass NULL (0).
The second parameter is `TRUE` (non-zero, or 1) if the calling thread should take ownersh... |
972 | <p>I've read that it is possible to add a method to an existing object (i.e., not in the class definition) in Python. </p>
<p>I understand that it's not always good to do so. But how might one do this?</p>
| [
{
"answer_id": 982,
"author": "John Downey",
"author_id": 200,
"author_profile": "https://Stackoverflow.com/users/200",
"pm_score": 5,
"selected": false,
"text": "<p>In Python monkeypatching generally works by overwriting a class or function's signature with your own. Below is an example... | 2008/08/04 | [
"https://Stackoverflow.com/questions/972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145/"
] | I've read that it is possible to add a method to an existing object (i.e., not in the class definition) in Python.
I understand that it's not always good to do so. But how might one do this? | In Python, there is a difference between functions and bound methods.
```
>>> def foo():
... print "foo"
...
>>> class A:
... def bar( self ):
... print "bar"
...
>>> a = A()
>>> foo
<function foo at 0x00A98D70>
>>> a.bar
<bound method A.bar of <__main__.A instance at 0x00A9BC88>>
>>>
```
Bound metho... |
1,005 | <p>Often while editing config files, I'll open one with vi and then when I go to save it realize that I didn't type</p>
<pre><code>sudo vi filename
</code></pre>
<p>Is there any way to give vi sudo privileges to save the file? I seem to recall seeing something about this while looking up some stuff about vi a while a... | [
{
"answer_id": 1006,
"author": "Ryan Fox",
"author_id": 55,
"author_profile": "https://Stackoverflow.com/users/55",
"pm_score": 1,
"selected": false,
"text": "<p>A quick Google seems to give this advice:</p>\n\n<ol>\n<li>Don't try to edit if it's read-only.</li>\n<li>You might be able to... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] | Often while editing config files, I'll open one with vi and then when I go to save it realize that I didn't type
```
sudo vi filename
```
Is there any way to give vi sudo privileges to save the file? I seem to recall seeing something about this while looking up some stuff about vi a while ago, but now I can't find i... | `%` is replaced with the current file name, thus you can use:
```
:w !sudo tee %
```
(`vim` will detect that the file has been changed and ask whether you want to it to be reloaded. Say yes by choosing `[L]` rather than OK.)
As a shortcut, you can define your own command. Put the following in your `.vimrc`:
```
co... |
1,010 | <p>I need to grab the <code>base64-encoded</code> representation of the <code>ViewState</code>. Obviously, this would not be available until fairly late in the request lifecycle, which is OK.</p>
<p>For example, if the output of the page includes:</p>
<pre><code><input type="hidden" name="__VIEWSTATE"
id="__VIE... | [
{
"answer_id": 1074,
"author": "Jeff Atwood",
"author_id": 1,
"author_profile": "https://Stackoverflow.com/users/1",
"pm_score": 5,
"selected": true,
"text": "<p>Rex, I suspect a good place to start looking is solutions that <strong>compress the ViewState</strong> -- they're grabbing Vie... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67/"
] | I need to grab the `base64-encoded` representation of the `ViewState`. Obviously, this would not be available until fairly late in the request lifecycle, which is OK.
For example, if the output of the page includes:
```
<input type="hidden" name="__VIEWSTATE"
id="__VIEWSTATE" value="/wEPDwUJODU0Njc5MD...==" />
``... | Rex, I suspect a good place to start looking is solutions that **compress the ViewState** -- they're grabbing ViewState on the server before it's sent down to the client and gzipping it. That's exactly where you want to be.
* [Scott Hanselman on ViewState Compression](http://www.hanselman.com/blog/CommentView,guid,feb... |
1,042 | <p>For instance, my query is like the following using SQL Server 2005:</p>
<pre><code>SELECT * FROM Table WHERE FREETEXT(SearchField, 'c#')
</code></pre>
<p>I have a full text index defined to use the column SearchField which returns results when using:</p>
<pre><code>SELECT * FROM Table WHERE SearchField LIKE '%c#... | [
{
"answer_id": 1047,
"author": "Ishmaeel",
"author_id": 227,
"author_profile": "https://Stackoverflow.com/users/227",
"pm_score": 1,
"selected": false,
"text": "<p>Quoting a much-replicated help page about Indexing Service query language:</p>\n\n<blockquote>\n <p>To use specially treate... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2/"
] | For instance, my query is like the following using SQL Server 2005:
```
SELECT * FROM Table WHERE FREETEXT(SearchField, 'c#')
```
I have a full text index defined to use the column SearchField which returns results when using:
```
SELECT * FROM Table WHERE SearchField LIKE '%c#%'
```
I believe # is a special let... | The # char is indexed as punctuation and therefore ignored, so it looks like we'll remove the letter C from our word indexing ignore lists.
Tested it locally after doing that and rebuilding the indexes and I get results!
Looking at using a different word breaker language on the indexed column, so that those special c... |
1,064 | <p>I'd like to display 100 floating cubes using <code>DirectX</code> or <code>OpenGL</code>.</p>
<p>I'm looking for either some sample source code, or a description of the technique. I have trouble getting more one cube to display correctly.</p>
<p>I've combed the net for a good series of tutorials and although they... | [
{
"answer_id": 1092,
"author": "Bernard",
"author_id": 61,
"author_profile": "https://Stackoverflow.com/users/61",
"pm_score": 3,
"selected": false,
"text": "<p>Just use glTranslatef (or the DirectX equivalent) to draw a cube using the same code, but moving the relative point where you d... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to display 100 floating cubes using `DirectX` or `OpenGL`.
I'm looking for either some sample source code, or a description of the technique. I have trouble getting more one cube to display correctly.
I've combed the net for a good series of tutorials and although they talk about how to do `3D` primitives, w... | You say you have enough trouble getting one cube to display... so I am not sure if you have got one to display or not.
Basically... put your code for writing a cube in one function, then just call that function 100 times.
```
void DrawCube()
{
//code to draw the cube
}
void DisplayCubes()
{
for(int i = 0; i ... |
1,108 | <p>Given that indexing is so important as your data set increases in size, can someone explain how indexing works at a database-agnostic level?</p>
<p>For information on queries to index a field, check out <a href="https://stackoverflow.com/questions/1156/">How do I index a database column</a>.</p>
| [
{
"answer_id": 1130,
"author": "Xenph Yan",
"author_id": 264,
"author_profile": "https://Stackoverflow.com/users/264",
"pm_score": 13,
"selected": true,
"text": "<p><strong>Why is it needed?</strong></p>\n<p>When data is stored on disk-based storage devices, it is stored as blocks of dat... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264/"
] | Given that indexing is so important as your data set increases in size, can someone explain how indexing works at a database-agnostic level?
For information on queries to index a field, check out [How do I index a database column](https://stackoverflow.com/questions/1156/). | **Why is it needed?**
When data is stored on disk-based storage devices, it is stored as blocks of data. These blocks are accessed in their entirety, making them the atomic disk access operation. Disk blocks are structured in much the same way as linked lists; both contain a section for data, a pointer to the location... |
1,145 | <p>I've tried to write a string replace function in C, which works on a <code>char *</code>, which has been allocated using <code>malloc()</code>. It's a little different in that it will find and replace strings, rather than characters in the starting string.</p>
<p>It's trivial to do if the search and replace string... | [
{
"answer_id": 1149,
"author": "John Downey",
"author_id": 200,
"author_profile": "https://Stackoverflow.com/users/200",
"pm_score": 3,
"selected": false,
"text": "<p>Just a shot in the dark because I haven't tried it yet but when you realloc it returns the pointer much like malloc. Beca... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188/"
] | I've tried to write a string replace function in C, which works on a `char *`, which has been allocated using `malloc()`. It's a little different in that it will find and replace strings, rather than characters in the starting string.
It's trivial to do if the search and replace strings are the same length (or the rep... | As a general rule, you should **never** do a free or realloc on a user provided buffer. You don't know where the user allocated the space (in your module, in another DLL) so you cannot use any of the allocation functions on a user buffer.
Provided that you now cannot do any reallocation within your function, you shoul... |
1,156 | <p>Hopefully, I can get answers for each database server.</p>
<p>For an outline of how indexing works check out: <a href="https://stackoverflow.com/questions/1108/how-does-database-indexing-work">How does database indexing work?</a></p>
| [
{
"answer_id": 1157,
"author": "John Downey",
"author_id": 200,
"author_profile": "https://Stackoverflow.com/users/200",
"pm_score": 7,
"selected": true,
"text": "<p>The following is SQL92 standard so should be supported by the majority of RDMBS that use SQL:</p>\n\n<pre><code>CREATE IND... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264/"
] | Hopefully, I can get answers for each database server.
For an outline of how indexing works check out: [How does database indexing work?](https://stackoverflow.com/questions/1108/how-does-database-indexing-work) | The following is SQL92 standard so should be supported by the majority of RDMBS that use SQL:
```
CREATE INDEX [index name] ON [table name] ( [column name] )
``` |
1,160 | <p>I am using CCNET on a sample project with SVN as my source control. CCNET is configured to create a build on every check in. CCNET uses MSBuild to build the source code.</p>
<p>I would like to use the latest revision number to generate <code>AssemblyInfo.cs</code> while compiling.
How can I retrieve the latest revi... | [
{
"answer_id": 1164,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 2,
"selected": false,
"text": "<p>I am currently \"manually\" doing it through a prebuild-exec Task, using my <a href=\"http://www.stum.de/various-tools/cmd... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/120/"
] | I am using CCNET on a sample project with SVN as my source control. CCNET is configured to create a build on every check in. CCNET uses MSBuild to build the source code.
I would like to use the latest revision number to generate `AssemblyInfo.cs` while compiling.
How can I retrieve the latest revision from subversion ... | CruiseControl.Net 1.4.4 has now an [Assembly Version Labeller](http://confluence.public.thoughtworks.org/display/CCNET/Assembly+Version+Labeller), which generates version numbers compatible with .Net assembly properties.
In my project I have it configured as:
```
<labeller type="assemblyVersionLabeller" incrementOnFa... |
1,171 | <p>I need to be able to manipulate a large (10^7 nodes) graph in python. The data corresponding to each node/edge is minimal, say, a small number of strings. What is the most efficient, in terms of <strong><em>memory and speed</em></strong>, way of doing this? </p>
<p>A dict of dicts is more flexible and simpler to im... | [
{
"answer_id": 1174,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "<p>A dictionary may also contain overhead, depending on the actual implementation. A hashtable usually contain some pri... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/280/"
] | I need to be able to manipulate a large (10^7 nodes) graph in python. The data corresponding to each node/edge is minimal, say, a small number of strings. What is the most efficient, in terms of ***memory and speed***, way of doing this?
A dict of dicts is more flexible and simpler to implement, but I intuitively exp... | I would strongly advocate you look at [NetworkX](http://networkx.github.com/). It's a battle-tested war horse and the first tool most 'research' types reach for when they need to do analysis of network based data. I have manipulated graphs with 100s of thousands of edges without problem on a notebook. Its feature rich ... |
1,180 | <p>I am looking to allow users to control of subdomain of an app I am toying with, much like Basecamp where it is <code>customusername.seework.com</code>.</p>
<p>What is required on the <code>DNS</code> end to allow these to be created dynamically and be available instantly. </p>
<p>And how do you recommend dealing w... | [
{
"answer_id": 1185,
"author": "Dave Ward",
"author_id": 60,
"author_profile": "https://Stackoverflow.com/users/60",
"pm_score": 2,
"selected": false,
"text": "<p>The trick to that is to use URL rewriting so that <strong>name.domain.com</strong> transparently maps to something like <stro... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/281/"
] | I am looking to allow users to control of subdomain of an app I am toying with, much like Basecamp where it is `customusername.seework.com`.
What is required on the `DNS` end to allow these to be created dynamically and be available instantly.
And how do you recommend dealing with this in the logic of the site? `Hta... | The way we do this is to have a 'catch all' for our domain name registered in DNS so that anything.ourdomain.com will point to our server.
With Apache you can set up a similar catch-all for your vhosts. The ServerName must be a single static name but the ServerAlias directive can contain a pattern.
```
Servername www... |
1,237 | <p>I have a file in the following format:</p>
<pre>
Data Data
Data
[Start]
Data I want
[End]
Data
</pre>
<p>I'd like to grab the <code>Data I want</code> from between the <code>[Start]</code> and <code>[End]</code> tags using a Regex. Can anyone show me how this might be done?</p>
| [
{
"answer_id": 1240,
"author": "Karl Seguin",
"author_id": 34,
"author_profile": "https://Stackoverflow.com/users/34",
"pm_score": 6,
"selected": false,
"text": "<pre><code>\\[start\\](.*?)\\[end\\]\n</code></pre>\n\n<p>Zhich'll put the text in the middle within a capture.</p>\n"
},
... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/230/"
] | I have a file in the following format:
```
Data Data
Data
[Start]
Data I want
[End]
Data
```
I'd like to grab the `Data I want` from between the `[Start]` and `[End]` tags using a Regex. Can anyone show me how this might be done? | ```
\[start\]\s*(((?!\[start\]|\[end\]).)+)\s*\[end\]
```
This should hopefully drop the `[start]` and `[end]` markers as well. |
1,292 | <p>I have a Queue<T> object that I have initialised to a capacity of 2, but obviously that is just the capacity and it keeps expanding as I add items. Is there already an object that automatically dequeues an item when the limit is reached, or is the best solution to create my own inherited class?</p>
| [
{
"answer_id": 1297,
"author": "CodingWithoutComments",
"author_id": 25,
"author_profile": "https://Stackoverflow.com/users/25",
"pm_score": 2,
"selected": false,
"text": "<p>Why wouldn't you just use an array with a size of 2? A Queue is supposed to be able to dynamically grow and shri... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | I have a Queue<T> object that I have initialised to a capacity of 2, but obviously that is just the capacity and it keeps expanding as I add items. Is there already an object that automatically dequeues an item when the limit is reached, or is the best solution to create my own inherited class? | I've knocked up a basic version of what I'm looking for, it's not perfect but it'll do the job until something better comes along.
```
public class LimitedQueue<T> : Queue<T>
{
public int Limit { get; set; }
public LimitedQueue(int limit) : base(limit)
{
Limit = limit;
}
public new void E... |
1,304 | <p>Is there any way to check whether a file is locked without using a try/catch block? </p>
<p>Right now, the only way I know of is to just open the file and catch any <code>System.IO.IOException</code>.</p>
| [
{
"answer_id": 1309,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 8,
"selected": true,
"text": "<p>No, unfortunately, and if you think about it, that information would be worthless anyway since the file could become ... | 2008/08/04 | [
"https://Stackoverflow.com/questions/1304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/121/"
] | Is there any way to check whether a file is locked without using a try/catch block?
Right now, the only way I know of is to just open the file and catch any `System.IO.IOException`. | No, unfortunately, and if you think about it, that information would be worthless anyway since the file could become locked the very next second (read: short timespan).
Why specifically do you need to know if the file is locked anyway? Knowing that might give us some other way of giving you good advice.
If your code ... |