on-internet

How to delete all databases on Postgres?

I take daily backs of our postgres development box using: pg_dumpall -h 127.0.0.1 -U user -w | gzip blah.gz Since 9.0 is now a release candidate I would like to restore this daily backup on a daily basis to a postgres9.0rc1 box for testing, however I'm not sure how to script it repeatedly. Is there some directory I can nuke to do this?

Join the discussion →

What is the fastest bzip2 decompressor?

Which implementation of bzip2 have the biggest decompression speed? There is a http://bitbucket.org/james_taylor/seek-bzip2/src/tip/micro-bunzip.c which claims Size and speed optimizations by Manuel Novoa III ([email protected]). More efficient reading of huffman codes, a streamlined read_bunzip() function, and various other tweaks. In (limited) tests, approximately 20% faster than bzcat on x86 and about 10% faster on arm. Note that about 2/3 of the time is spent in read_unzip() reversing the Burrows-Wheeler transformation. Much of that time is delay resulting from cache misses. A lot of cache

Join the discussion →

Filtering out auto-generated methods (getter/setter/add/remove/.etc) returned by Type.GetMethods()

I use Type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) to retrieve an array of methods for a given type. The problem is the returned MethodInfo could include methods that are generated by the compiler which I don't want. For example: property bool Enabled { get; } will get bool get_Enabled() event SomethingChanged will get add_SomethingChanged(EventHandler) and remove_SomethingChanged(EventHandler) I can probably add some filter logic to get rid of them which could potentially get very complicated. I want to know if there is something

Join the discussion →

Perform commands over ssh with Python

I'm writing a script to automate some command line commands in Python. At the moment, I'm doing calls like this: cmd = "some unix command" retcode = subprocess.call(cmd,shell=True) However, I need to run some commands on a remote machine. Manually, I would log in using ssh and then run the commands. How would I automate this in Python? I need to log in with a (known) password to the remote machine, so I can't just use cmd = ssh user@remotehost, I'm wondering if there's a module I should be using?

Join the discussion →

iPhone iOS4 low-level camera control?

Is there a way to manually set low-level still-camera settings like shutter speed, aperture, or ISO in iOS4 on the iPhone 4? I don't think it exists in the official SDK but perhaps someone has found some private APIs to allow this? I find my iPhone 4 camera to be unusable because even in fairly decent lighting, it always insists on shooting at the slowest 1/15th a second shutter speed causing motion blur if the subject is moving at all.

Join the discussion →

Why are there so many different calling conventions?

Historically, why does it seem like just about everyone and their kid brother defined their own calling conventions? You've got C, C++, Windows, Pascal, Fortran, Fastcall and probably a zillion others I didn't think to mention. Shouldn't one convention be the most efficient for the vast majority of use cases? Is there ever any good reason to prefer one over the other?

Join the discussion →

What is the most efficient way to get first and last line of a text file?

I have a text file which contains a time stamp on each line. My goal is to find the time range. All the times are in order so the first line will be the earliest time and the last line will be the latest time. I only need the very first and very last line. What would be the most efficient way to get these lines in python? Note: These files are relatively large in length, about 1-2 million lines each and I have to do this for several hundred files.

Join the discussion →

Using Joda Date & Time API to parse multiple formats

I'm parsing third party log files containing date/time using Joda. The date/time is in one of two different formats, depending on the age of the log files I'm parsing. Currently I have code like this: try { return DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss").parseDateTime(datePart); } catch (IllegalArgumentException e) { return DateTimeFormat.forPattern("E, MMM dd, yyyy HH:mm").parseDateTime(datePart); } This works but contravenes Joshua Bloch's advice from Effective Java 2nd Edition (Item 57: Use exceptions only for exceptional conditions). It also makes it hard to determine if an Illegal

Join the discussion →

Recover postgreSQL databases from raw physical files

I have the following problem and I need to know if there´s a way to fix it. I have a client who was cheap enough to decline buying a backup plan for his postgreSQL databases on the main system that runs his company and as I thought it would happen some day, some OS files crashed during a blackout and the OS needs to be reinstalled. This client didn't have any backups of the databases but I managed to save the PostgreSQL main directory. I read that the databases are stored somehow inside the data directory of the postgres main folder. My question is: Is there any way to recover the databases fr

Join the discussion →

How do I encode a complete http url string correctly?

I get a url string from a user and would like to transform it to a legal http url: http://one.two/three?four five should turn into http://one.two/three?four%20five However, URLEncoder does not help, as it encodes the entire string (including the legal ://). Help?

Join the discussion →

If the RAM contents are unpredictable at power-on, how can BIOS start executing from memory address 0xFFFF0?

When a pc first boots up, it starts executing at physical address 0xffff0. This address contains a jmp instruction to the BIOS. Now for my question, I always assume the physical addresses are mapped to RAM. If RAM initially contains garbage values, what exactly puts the jmp instruction in 0xffff0? Is the jmp instruction always the same or is it different for different BIOS's? Does 0xffff0 map from RAM to BIOS then (meaning it's "hard mapped")?

Join the discussion →

What's the point of cache coherency?

On CPUs like x86, which provide cache coherency, how is this useful from a practical perspective? I understand that the idea is to make memory updates done on one core immediately visible on all other cores. This is a useful property. However, one can't rely too heavily on it if not writing in assembly language, because the compiler can store variable assignments in registers and never write them to memory. This means that one must still take explicit steps to make sure that stuff done in other threads is visible in the current thread. Therefore, from a practical perspective, what has cache co

Join the discussion →

jQuery: Difference between position() and offset()

What is the difference between position() and offset()? I tried to do the following in a click event: console.info($(this).position(), $(this).offset()); And they seem to return exactly the same... (The clicked element is within a table cell in a table)

Join the discussion →

How to get selected row of detail grid in Master-Detail GridView?

I'm having a problem on getting the selected rows values of a detail grid. I have master-detail grid in a popup control and it works fine. I also enabled the enable selection to have checkboxes but when i try to run GetSelectedFieldValues on ClientSideEvents of a button it always returns "0". What do i do wrong, i couldn't find it? Here is the detail grid: AutoGenerateColumns="False" CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" OnBeforePerformDataSelect="gv_ParameterTempD_BeforePerformDataSelect" ClientInstanceName="gvC_ParameterTempD"> <dxwgv:GridViewCommandColumn ShowSele

Join the discussion →

How to change the default schemalocation in wsdl file of WCf Service?

Following is the wsdl file of my service: <wsdl:types> <xsd:schema targetNamespace="http://tempuri.org/Imports"> <xsd:import schemaLocation="http://localhost:3789/VideoUpload.svc?xsd=xsd0" namespace="http://tempuri.org/" /> <xsd:import schemaLocation="http://localhost:3789/VideoUpload.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" /> <xsd:import schemaLocation="http://localhost:3789/VideoUpload.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/UploadVideoProtocol" /> </xsd:schema> </wsdl:types> ----- <wsdl:definitions> <wsdl:service name="VideoUplo

Join the discussion →

Robocopy file transfer backup using SQL server

I have a job running robocopy to copy files from the SQL server to a backup drive. The job runs a CmdExec type job to call a batch file that runs robocopy. My issue is that although the files copy over fine, the error reports do not get registered. I tested this by changing the source file to a bogus drive. It still reports job success. I have narrowed it down to run only robocopy. When the job runs the batch file, the job reports success. The job still reports success even if I only type robocopy in the batch file and nothing else. Here is the code I am running to try out the error handling:

Join the discussion →

Getting changes from another branch

I have a project which uses git and I'd like to start a new branch to add a major new feature. Under the main branch, I'll continue to add bug fixes and minor features. At regular intervals I'd like to pull the changes from the main branch into my "major new feature" branch. What's the best way to do this? Eventually, I'll merge the "major new feature" branch into the main branch.

Join the discussion →

Alternate names for a surrogate key/sequence number/ID column

I have a legacy table that has as a part of its natural key a column named <table_name>_IDENTIFIER and it seems like it would be confusing to create a surrogate key named <table_name>_ID or ID so I'm leaning towards naming it SURROGATE_KEY. All my other tables use the <table_name>_ID syntax. Any better suggestions?

Join the discussion →

Quoting long strings without newlines in Python

I am trying to write a long string in Python that gets displayed as the help item of an OptParser option. In my source code .py file, I'd like to place newlines so that my code doesn't spend new lines. However, I don't want those newlines to affect how that string is displayed when the code is run. For example, I want to write: parser.add_option("--my-option", dest="my_option", nargs=2, default=None, help='''Here is a long description of my option. It does many things but I want the shell to decide how to display this explanation. However, I want newlines in this string.''') the above way of d

Join the discussion →

What is the difference between the .*? and .* regular expressions?

I'm trying to split up a string into two parts using a regular expression. The string is formatted as follows: text to extract<number> I've been using (.*?)< and <(.*?)> which work fine, but after reading into regular expressions a little, I've just started to wonder why I need the ? in the expressions. I've only done it like that after finding them through this site. What is the difference?

Join the discussion →

Why does javascript's "in" operator return true when testing if 0 exists in an array that doesn't contain 0?

Why does the "in" operator in Javascript return true when testing if "0" exists in array, even when the array doesn't appear to contain "0"? For example, this returns true, and makes sense: var x = [1,2]; 1 in x; // true This returns false, and makes sense: var x = [1,2]; 3 in x; // false However this returns true, and I don't understand why: var x = [1,2]; 0 in x;

Join the discussion →

JQuery JQGrid local data loading issue

I've got a problem with the following code <script type="text/javascript"> var mydata = [ {id:"1",name:"foo"},{id:"2",name:"bar"} ]; jQuery(document).ready(function() { jQuery("#lgrid").jqGrid({ data: mydata, datatype: "local", height: 150, width:600, rowNum: 10, rowList: [10,20,30], colNames:['id','name'], colModel:[ {name:'id',index:'id', width:60, sorttype:"int"}, {name:'name',index:'name', width:60}], pager: "#pgrid", viewrecords: true, caption: "Contacts" }); }); </script> And In the body .... <table id="lgrid"></table> <div id="pgrid"></div> With this code, I never display the data into

Join the discussion →

Is there a tool to auto-format R code for me?

Is there any tool (editor, script, whatever...) available that can automatically reformat R code? It does not need to be customizable but it must be able to recognize statements separated by either semicolons or newlines since this code has both. If it can put all statements on a separate line, consistently indent code blocks and consistently place braces I will be very happy.

Join the discussion →
Older stories