Should be something like that:
SELECT dateadd(day, datediff(day, 0, getdate()), 0)
Should be something like that:
SELECT dateadd(day, datediff(day, 0, getdate()), 0)
2 good tutorials:
Updated: And 1 more article about c++ unit test frameworks.
I got too accustomed to multiple desktops on my home Ubuntu computer, that working under Windows with many open programs without ability to share them among several desktops made me too uncomfortable. VirtuaWin - The Virtual Desktop Manager was the solution :). Now I am happy again.
One can add list and not only a list to App.Config file of the .Net project. That can be done by declaring your own configuration element, say a ProductElement
class ProductElement : ConfigurationElement
{
[ConfigurationProperty("name", IsKey=true, IsRequired=true)]
public string Name
{
get { return this["name"]; }
}
[ConfigurationProperty("price")]
public int Price
{
get { return Convert.ToInt32(this["price"]); }
}
}
class ProductElementCollection : ConfigurationElementCollection
{
protected override ConfigurationElement CreateNewElement()
{
return new ProductElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((ProductElement)element).Name;
}
}
class ProductConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("products")]
public ProductElementCollection Products
{
get { return (ProductElementCollection)this["products"]; }
}
}
Use it in your app.config like that:
<configuration>
<configSections>
<section name="productConfigurationSection"
type="MyNamespace.ProductConfigurationSection, MyAssembly"
requirePermission="false" />
</configSections>
<productConfigurationSection>
<products>
<add name="car" price="750000" />
<add name="milk" price="13" />
</products>
</productConfigurationSection>
</configuration>
Note that Name is used as a key, so you cannot create 2 Products with the same name. But you can add more fields to the Product, just mark them accordingly. And from code you can access this section with:
ProductConfigurationSection section = (ProductConfigurationSection) ConfigurationManager.GetSection("productConfigurationSection");
Hardly anyone will argue, that IntelliJ IDEA is one of the best IDE for Java and Ruby(Rails). And now it is going to be free! Yes, this title is taken from IntelliJ Site. Next version of the product will be free, and it can already be downloaded from the coerced link.
Converting different audio formats in Ubuntu is quite an easy task. Just start Soundconverter, or first install it, if you don't have.
sudo apt-get install soundconverter
But I needed to do it in command line. Soundconverter can do it either. (What a good boy!) But you just need to know the mime-type of the output file (simply adding the desired suffix doesn't work). For example, to convert "my_favourite mp3" to wav you can use:
soundconverter -b -m audio/x-wav -s .wav my_favourite.mp3
See the full list of mime types.
For the available options see
soundconverter -h
or
man soundconverter
I wanted to try ruby Shoes already long ago, but just didn't know what to start with. Until I found a quiteuseful article about making a game on ruby shoes. I tried it and it was unexpectedly easy. Here are some my subjective thoughts about it.
Good things:
Shoes.app { button("Click me!") { alert("Good job.") } }
You also can draw with provided rect, oval or even arrow methods or import an image as a background. Motion ability is also provided:
Shoes.app do #A star that moves after the mouse pointer.
@shape = star :points => 5
motion do |left, top|
@shape.move left, top
end
end
class RedRect
def initialize( app )
app.fill red
app.rect :left => 10, :top => 10, :width => 40
end
end
Shoes.app do
RedRect.new( self )
end
In conclusion the authors' words about Shoes are right:"Shoes is a tiny graphics toolkit, designed for beginners". It can be used to create quickly a small application, where speed is not essential.
Suppose we have a html page with frame or iframe in it and we need to get an element in it. Simple
document.getElementById("myElement");
will not find it, as it is searched only in the main page, where the frame is set. What we should do, is to find the frame first and then look for needed element in the right frame.
frame = document.getElementById("myFrame");
frame.contentWindow.getElementById("myElement");
CREATE TABLE MyTable (id int, name varchar, value int);
INSERT INTO MyTable (id,name,value) VALUES (1, 'Hello', 4);
INSERT INTO MyTable (id,name,value) VALUES (1, 'World', 8);
INSERT INTO MyTable (id,name,value) VALUES (5, 'Great!', 9);
The result we would like to acquire is:| id | name_values | +----+------------------+ | 1 | Hello:4; World:8 | | 5 | Great!:9 |Names and values are concatenated into strings and grouped by id. We need an aggregate function, that concatenates strings for that. Here are some solutions for different sql databases.
SELECT id, GROUP_CONCAT(name + ':' + value SEPARATOR '; ') AS name_values FROM MyTable GROUP BY id;
CREATE AGGREGATE aggr_textcat(
basetype = text,
sfunc = textcat,
stype = text,
initcond = ''
);
SELECT id, substring(aggr_textcat(', ' || name || ':' || value) from 2) AS name_values FROM MyTable GROUP BY id;
Here we used already existing function to concatenate text fields textcat, but we could write our own.
SELECT id, SUBSTRING((SELECT '; ' + name + ':' + CAST(value AS varchar(MAX))
FROM MyTable WHERE (id = Results.id) FOR XML PATH ('')),3,9999) AS name_values
FROM MyTable Results
GROUP BY id