instruction
stringlengths
0
30k
Java: Date.getTime() not including time?
[FFmpeg](http://en.wikipedia.org/wiki/Ffmpeg) provides AAC encoding facilities: ffmpeg -i source.mp3 -acodec aac -ab 128 dest.aac I'm not sure how you would call this from ruby. Also, be sure to set the bitrate appropriately
[FFmpeg](http://en.wikipedia.org/wiki/Ffmpeg) provides AAC encoding facilities if you've compiled them in. If you are using Windows you can grab full binaries from [here](http://arrozcru.no-ip.org/ffmpeg_builds/) ffmpeg -i source.mp3 -acodec libfaac -ab 128k dest.aac I'm not sure how you would call this from ...
For complex splitting you could use a regex creating a match collection.
How do I convert mp3 to aac programmatically?
|ruby-on-rails|mp3|aac|
I've been looking for a way to convert an mp3 to aac programmatically or via the command line with no luck. Ideally, I'd have a snippet of code that I could call from my rails app that converts an mp3 to an aac. Thanks!
How do I programmatically convert mp3 to an itunes-playable aac/m4a file?
|ruby-on-rails|mp3|aac|m4a|
I've been looking for a way to convert an mp3 to aac programmatically or via the command line with no luck. Ideally, I'd have a snippet of code that I could call from my rails app that converts an mp3 to an aac. I installed ffmpeg and libfaac and was able to create an aac file with the following command: ffmpeg -i...
If you problem is synchronization related dumping log in the file might be problematic. In this case i usually will use some big array of string and dump this to screen/file after the problem was reproduces. This is of course depend on your memory restriction, sometime i use just few symbols and numbers to store ...
I'd like to add that of the three algoritms mentioned so far (mergesort, quicksort and heap sort) only mergesort is stable. That is, the order does not change for those values which have the same key. In some cases this is desirable. But, truth be told, in practical situations most people need only good average perf...
Cross-server SQL
|sql|sql-server|t-sql|cross-server|
I want to port data from one server's database to another server's database. The databases are both on a different mssql 2005 server. Replication is probably not an option since the destination database is generated from scratch on a [time interval] basis. Preferebly I would do something like insert * ...
How are people unit testing code that uses Linq to SQL
|unit-testing|linq-to-sql|
How are people unit testing code that uses Linq to SQL?
|unittesting|linq-to-sql|
|linq|linq-to-sql|unittesting|
|unit-testing|linq|linq-to-sql|
I use DbUnit, but also I work very hard to not to have to test against the DB. Tests that go against the database should only exist for the purpose of testing the database interface. So I have Mock Db Connections that I can set the data for use in all the rest of my tests.
While Alex provides the correct and proximal answer to your question, I prefer to use TryParse: int value; int? EmployeeNumber = int.TryParse(employeeNumberTextBox.Text, out value) ? (int?)value : null; It's safer and takes care of cases of invalid input as well as your empty string sce...
You can not make kernel-mode device drivers in C# as the runtime can't be safely loaded into ring0 and operate as expected. Additionally, C# doesn't create binaries suitable for loading as device drivers, particularly regarding entry points that drivers need to expose. The dependency on the runtime to jump in and an...
The best method would probably be to identify and eval the contents of the script block directly via the DOM. I would be careful though.. if you are implementing this to overcome a limitation of some off site call you are opening up a security hole. Whatever you implement could be exploited for XSS.
You are correct an array is great for look ups. However modifications to the size of the array are costly. You should use a container that supports incremental size adjustments in the scenario where you're modifying the size of the array. You could use an ArrayList which allows you to set the initial size, and you c...
The FIGNORE environment variable is nice when you want TAB completion to ignore files or folders with certain suffixes, e.g.: export FIGNORE="CVS:.svn:~" Use the IFS environment variable when you want to define an item separator other than space, e.g.: export IFS=" " This will make you able to lo...
in my opinion you should use this technique only if failure is a "normal part of operation" of your method / function, e.g. its as probable that a call suceeds as that it fails. If failure is a exceptional event, then you should use exception handling so your program can terminate as early and gracefully as possible.
in my opinion you should use this technique only if failure is a "normal part of operation" of your method / function, e.g. its as probable that a call suceeds as that it fails. If failure is a exceptional event, then you should use exception handling so your program can terminate as early and gracefully as possible. ...
It's the most well though out language you'll find -- it's almost intuitive. Want an element's width? $('#something').width(); Want to grab an element, hide it, change it's background color and fade it back in? $('#something').hide().css('background', 'red').fadeIn(); How about table striping for...
I'd lean towards only including your constant in the code once. There might be a performance advantage one way or the other, but it's probably so small the maintenance advantage of only one parameter trumps it.
Thinking in Java (Patterns) , Bruce Eckel
You can load a .NET assembly from a byte array using an overload of [Assembly.Load][1]. However, there are implications for the security model that need to be considered which make things more complex. See the discussion [here][2], and also this [thread][3]. If your embedded executable is not .NET then I think y...
The correct answer probably depends on your SQL engine. For MS SQL Server, the first approach is clearly the better because the statistical optimizer is given an additional clue which may help it find a better (more optimal) resolution path.
1. you must use it to implement spinlocks as well as some lock-free data structures 2. use it with atomic operations/instructions 3. helped me once to overcome compiler's bug (wrongly generated code during optimization)
1. you must use it to implement spinlocks as well as some (all?) lock-free data structures 2. use it with atomic operations/instructions 3. helped me once to overcome compiler's bug (wrongly generated code during optimization)
The .NET control supports the [SuspendLayout][1] and [ResumeLayout][2] methods. Pick the appropriate parent control (i.e. the control that hosts the controls you want to populate) and do something like the following: this.SuspendLayout(); // Do something interesting. this.ResumeLayout(); ...
I like the [W3C Link Checker][1]. [1]: http://validator.w3.org/checklink
YUI uses three tests to do this: for Firefox and recent WebKit there's a DOMContentLoaded event that is fired. For older Safari the document.readyState watched until it becomes "loaded" or "complete". For IE an HTML <P> tag is created and the "doScroll()" method called which should error out if the DOM is not rea...
Is there a tool for finding unreferenced functions (dead, obsolete code) in a C# app?
|c#|.net|code-analysis|
I want to delete foo() if foo() isn't called from anywhere.
Look at Oracle JDeveloper (freeware). It is pure Java, so it will run on any platform. It will work against any database that you can connect to via JDBC. It builds database diagrams (and lots of other diagrams - it happens to be a complete Java IDE). It works with a concept of "offline database objects" stored in X...
See [linkcheker][1] tool [1]: http://linkchecker.sourceforge.net/
You need to put "here" into a div or span with style="float: right".
marks would be the simplest **mb** where u want to begin and **me** where u want to end once this is done you can do pretty much anything you want :'b,'ed deletes from marker **b** to marker **e** commenting out 40 lines you can do in the visual mode V40j:s/^/#/ will comment out 40 lines from where...
You may be able to use absolute positioning. The container box should be set to position: relative. The top-right text should be set to position: absolute, top: 0, and right: 0. The bottom-right text should be set to position: absolute, bottom: 0, and right: 0. You'll need to experiment with padding to stop t...
If all else fails, use [Sphinx](http://www.sphinxsearch.com/)
|java|date|gettime|unix|timestamp|
Can't understand why the following takes place: String date = "06-04-2007 07:05"; SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm"); Date myDate = fmt.parse(date); System.out.println(myDate); //Mon Jun 04 07:05:00 EDT 2007 long timestamp = myDate.getTime(); System.out.p...
|java|date|timestamp|gettime|
$$ is your PID. It doesn't really generate a unique filename, unless you are careful and no one else does it exactly the same way. Typically you'd create something like /tmp/myprogramname$$ There're so many ways to break this, and if you're writing to locations other folks can write to it's not too difficult on ...
In general, only the data in Java objects is stored on the Java heap, all other memory required by the Java VM is allocated from the "native" or "C" heap (in fact, the Java heap itself is just one contiguous chunk allocated from the C heap). Since the JVM requires the Java heap (or heaps if generational garbage coll...
Cloning objects in C#
|c#|.net|clone|
I want to do something like... myObject myObj = GetmyObj()//create and fill a new object myObject newObj = myObj.Clone(); ...and then make changes to the new object that are not reflected in the original object. I don't often need this functionality so when it's been necessary I've resorted to creatin...
Doing away with Globals?
|c#|java|oop|
I have a set of tree objects with a depth somewhere in the 20s. Each of the nodes in this tree needs access to its tree's root. A couple of solutions: 1. Each node can store a reference to the root directly (wastes memory) - I can compute the root at runtime by "going up" (wastes cycles) - I can use stat...
|c#|java|oop|
I have a set of tree objects with a depth somewhere in the 20s. Each of the nodes in this tree needs access to its tree's root. A couple of solutions: 1. Each node can store a reference to the root directly (wastes memory) - I can compute the root at runtime by "going up" (wastes cycles) - <s>I can use s...
The X server should never compress client messages that I'm aware of, but perhaps some X toolkits (Motif, Xaw, etc.) do compress them. That's the first thing I would look for - perhaps the GUI app receiving the message is compressing somewhere inside the toolkit, before the application code sees it. Then again, both...
This usually means that the class information was not included in the SWF. Make sure that you are importing the class, and that there is a reference to it somewhere (so the compiler will included it in the SWF). btw, here are the runtime error codes: <http://livedocs.adobe.com/flex/201/langref/runtimeErrors.h...
[TagLib Sharp][1] has support for reading ID3 tags. [1]: http://developer.novell.com/wiki/index.php/TagLib_Sharp
You could do what they suggest, or use this Eclipse plugin, which makes it easier to configure Tomcat to begin with: [Eclipse Tomcat Plugin][1] [1]: http://www.eclipsetotale.com/tomcatPlugin.html When launching tomcat via this plugin, it starts in debug mode by default, you must explicitly disable debugging m...
Using indentation in a language doesn't necessarily mean that the language's grammar can not be context free. I.e. the indentation will determine in which scope a statement exists. A statement will still be a statement no matter which scope it is defined within (scope can often be handled by a different part of the c...
You could use [String.Split method][1]. class ExampleClass { public ExampleClass() { string exampleString = "there is a cat"; // Split string on spaces. This will separate all the words in a string string[] words = exampleString.Split(' '); ...
You could use [String.Split method][1]. class ExampleClass { public ExampleClass() { string exampleString = "there is a cat"; // Split string on spaces. This will separate all the words in a string string[] words = exampleString.Split(' '); ...
You can use the `composed_of` relationship in ActiveRecord. You make a regular class with all the attributes that you manage through AWS and specify that your Product-class is composed_of this class. ActiveRecord will handle the delegation of the mapped attributes to and from this class. See [the documentation of co...
This really depends on what you're trying to do, but one of the features of the new <a href="http://search.cpan.org/dist/Test-Harness/">Test::Harness</a> (disclaimer: I'm the original author and still a core developer) is that if your tests output TAP (the Test Anything Protocol), you can use Test::Harness to run test ...
Can we achieve 100% decoupling?
|language-agnostic|
Can we achieve 100% decoupling between components of a system or different systems that communicate with each other? I don't think its possible. If two systems communicate with each other then there should be some degree of coupling between them. Am I right?
In Internet Explorer, FileReference.upload (flash upload) *will* send cookies along as well. This behavior breaks only when running in other browsers.
The FIGNORE environment variable is nice when you want TAB completion to ignore files or folders with certain suffixes, e.g.: export FIGNORE="CVS:.svn:~" Use the IFS environment variable when you want to define an item separator other than space, e.g.: export IFS=" " This will make you able to lo...
> One example out of many: template > metaprogramming. Nobody in the > standards committee intended there to > be a Turing-complete sublanguage that > gets executed at compile-time. Template metaprogramming is hardly a hidden feature. It's even in the boost library. See [MPL][1]. But if "almost hidden" is good e...
This really depends on what you mean by "add." If you mean: T[] array; int i; T value; ... if (i >= 0 && i <= array.Length) array[i] = value; Then, no, this does not create a new array, and is in-fact the fastest way to alter any kind of IList in .NET. If, however, you're us...
Render frames with RenderTargetBitmap, then encode with codec of your choice. Not very fast, but 24 fps are achievable on regular PC. We use similar technique to feed video stream from new WPF indicators to legacy bitmap system. There might be a better solution, but it works. _I also heard of a solution with pulling...
Render frames with RenderTargetBitmap, then encode with codec of your choice. Not very fast, but 24 fps are achievable on regular PC. We use similar technique to feed video stream from new WPF indicators to legacy bitmap system. There might be a better solution, but it works. _I also heard of a solution with pulling...
$$ in Bash.
|bash|shell|sripts|
I once read that one way to obtain a unique filename in bash for temp files was to use a double dollar sign ($$). This does produce a number that varies from time to time... but if you call it repeatedly, it returns the same number. (The solution is to just use the time.) I am curious to know what $$ actually is,...
|bash|shell|scripting|
This may help: [OpenID][1] [1]: http://openid.net/foundation/intellectual-property/
Oooh, I can come up with a list of pet hates: - Destructors need to be virtual if you intend use polymorphically - Sometimes members are initialized by default, sometimes they aren't - Local clases can't be used as template parameters (makes them less useful) - exception specifiers: look useful, but a...
Oooh, I can come up with a list of pet hates instead: - Destructors need to be virtual if you intend use polymorphically - Sometimes members are initialized by default, sometimes they aren't - Local clases can't be used as template parameters (makes them less useful) - exception specifiers: look usefu...
Oooh, I can come up with a list of pet hates instead: - Destructors need to be virtual if you intend use polymorphically - Sometimes members are initialized by default, sometimes they aren't - Local clases can't be used as template parameters (makes them less useful) - exception specifiers: look usefu...
I think it depends on the library and database engine. Each one will execute the SQL differently, and there's no telling which one will be optimized.
If you ever wish to make the query more general, perhaps substituting a parameter for the target country, then I'd go with your first example, as it requires only a single change. That's less to worry about getting wrong in the future.
you don't mention what product, but SQL Server 2008 and postgresql (and others i'm sure) allow you to create filtered indexes, so you could create a covering index where is_deleted=0, mitigating some of the negatives of this particular approach.
I have seen this to be done by converting the resource file to a C source file with only one char array defined containing the content of resource file in a hexadecimal format (to avoid problems with malicious characters). This automatically generated source file is then simply compiled and linked to the project. I...
Consider Regex.Replace(your_string, regex, "") - that's what I use.
The best article I've found is [Jsf Component Writing][1], as for 2 where do I read the value for a value binding in your component you have a getter that looks like this <pre><code> public String getBar() { if (null != this.bar) { return this.bar ; } ValueBinding _vb = getValueB...
I suspect this is going to depend on the tables, the data and the meta-data. I expect I could work up examples that would show results both ways - benchmark!
I wanted to do this so that I can easially hit it with a web browser, as I'm am deployng to managed servers, which I do not have shell access onto (for increased security). So this is what I did <pre>class DiagnosticsController < ApplicationController require 'RMagick' def rmagick images_path = "publi...
I wanted to do this so that I can easially hit it with a web browser, as I'm am deployng to managed servers, which I do not have shell access onto (for increased security). So this is what I did class DiagnosticsController < ApplicationController require 'RMagick' def rmagick images_path = "pu...
Launching an app without a form means you're going to have to manage the application startup/shutdown yourself. Starting the form off invisible is a better option.
If you are using C# 3.5 you could write an extension method to System.String that does the splitting you need. You then can then use syntax: string.SplitByMyTokens(); More info and a useful example from MS here [http://msdn.microsoft.com/en-us/library/bb383977.aspx][1] [1]: http://msdn.microsoft.com/en...
Which Scripting language is best?
|scripting|language|