Search Results

Search found 57 results on 3 pages for 'ruben'.

Page 1/3 | 1 2 3  | Next Page >

  • Pyro Jam Can Is a DIY Mini Ruben’s Tube

    - by Jason Fitzpatrick
    Earlier this year we showed you how to make a full-size Ruben’s Tube; now make a tiny single-column fire speaker with the Pyro Jam Can. Instructables’ user Patrick needed a simple device to enter into an Instuctables contest centered on fire-themed projects. His contribution, seen in the video above, is a single-column Ruben’s Tube (for the unfamiliar, a Ruben’s Tube is a device through which sound and flammable gas are passed; the resulting flame is modulated by the frequency of the sound). If your next party wouldn’t be the same without a sound system that pumps bass beats and fire, you know where to get started. The Pyro Jam Can [via Hack A Day] Use Amazon’s Barcode Scanner to Easily Buy Anything from Your Phone How To Migrate Windows 7 to a Solid State Drive Follow How-To Geek on Google+

    Read the article

  • Failed to load Cairo

    - by Ruben
    We're running a Ubuntu Server VM with OpenCPU (that's an API for R). Unfortunately we're unable to get the Cairo R package to play, the error message (from within R) is as follows: unable to load shared object '/usr/lib/R/library/grDevices/libs//cairo.so': /usr/local/lib/libgmodule-2.0.so.0: undefined symbol: g_rec_mutex_lock 2: In png() : failed to load cairo DLL We've tried purging and reinstalling cairo and libcairo and we both tried building the Cairo R package from source as well as using a precompiled version from Michael Rutter's ppas (all seems to work without errors). Unfortunately none of us are real Ubuntu natives and thus we probably did some pretty amateur debugging. Any push in the right direction would be very appreciated. For example, we couldn't figure out how to reinstall whatever libgmodule refers to.

    Read the article

  • SO-overflow induced passivity - how to cope?

    - by Ruben
    After not really working on my pet project for a while, I discovered Stackoverflow and upon perusing it more intensely I was quite amazed. I'm a bit of a perfectionist, so when I found eye-openers here highlighting many of the mistakes I made, I first wanted to fix everything. However, it's a pet project for a reason: I'm self-taught and I'm studying psychology, so programming skills can never become priority one (though it often helps, even in this field). Issues that stuck out were numerous security issues (e.g. CSRF-prevention and bcrypt eluded me) not object-oriented (at least the PHP part, the JS-part mostly is) no PHP framework used, so many of my DIY takes on commonly-tackled components (auth, ...) are either bad or inefficient really poor MySQL usage (no prepared statements, mysql extension, heard about setting proper indices two days ago) using mootools even though JQuery seems to be fashionable, so there's more probably always going to be better integration with services I'd like to use (like google visualization) So, my SO-induced frenzy turned into passivity. I can't do it all (soon) in the rather small amount of spare time I can spend on working on my project. I can leave some of the issues be in good conscience (speed stuff: an unfinished & unpublished project will never become popular, right?). No clear conscience without good security though and if I don't use a framework for auth and other complex stuff I'll regret having to do it myself. One obvious answer would probably be going open-source, but I think the project would need to become more impressive before others would commit to it. I can't afford to employ someone either. I do think the project deserves being worked on, though. How should I tackle it anyway? What's the best practice for little-practice people?

    Read the article

  • How can I install wireless drivers without internet?

    - by Ruben
    [Ubuntu 12.04 LTS] I have a HP Pavilion dv6 and I need a Broadcom driver (closed source) to access the internet. However, I need to download that, which I am unable to do because I do not have internet access. My ethernet port has always been broken and I have not been able to access the internet since I installed Ubuntu. I need to find a way for me to install those drivers desperately. I still have Ubuntu on my USB, which for some reason, did have the ability to install that driver (I think it's due to the fact that it already has it somewhere in the files). On my USB Ubuntu, I have that particular driver installed. I was thinking that if one of you knows where drivers are installed, I could locate those files on the USB Ubuntu, then plug in an additional USB to copy them; restart my computer to the harddrive Ubuntu and then install the files from the (additional) USB. I would really appreciate help since to me a computer without internet is useless.

    Read the article

  • Libre Office Impress opens in 11.10, but not in the launcher

    - by Ruben
    I double click my presentation to open it w/Impress and it opens, but there is no icon in the launcher (or alt-tab switcher) to indicate that its open. I tried keeping the Impress icon in the launcher, then opening my presentation, but the same thing happened. Then I tried opening Impress from the launcher and opening my file from inside impress...no luck either. What's up with that? btw, im using 11.10 and the file was made with office 2010 and saved as a .ppt if that has anything to do with it. Any help is appreciated

    Read the article

  • Can a version update (from 12.04 to 12.10) give driver problems?

    - by Ruben
    I'm new here. I recently installed Ubuntu 12.04 even though I'm not completely new to the Linux World, but I wanted to ask a thing: I had a problem in video drivers, and I fixed it by a complete reinstallation of the whole operating system. If I install the new version using the update manager (so without a complete reinstallation), will my drivers be the same as they are? And what about my data? Thanks, and sorry for my very bad english .<

    Read the article

  • Switch gettext translated language with original language

    - by Ruben
    Hi everyone, I started my PHP application with all text in German, then used gettext to extract all strings and translate them to English. So, now I have a .po file with all msgids in German and msgstrs in English. I want to switch them, so that my source code contains the English as msgids. There are numerous reasons for this: More translators will know English, so it is only appropriate to serve them up a file with msgids in English. I could always switch the file before I give it out and after I receive it It would help me to write English object & function names and comments if the content text was also English. I'd like to do that, so the project is more open to other Open Source collaborators (more likely to know English than German). I could do this manually and this is the sort of task where I anticipate it will take me more time to write an automated routine for it (because I'm very bad with shell scripts) than do it by hand. But I also anticipate despising every minute of manual computer labour (feels like a oxymoron, right?) like I always do. Has someone done this before? I figured this would be a common problem, but couldn't find anything. Many thanks ahead. Sample Problem: <title><?=_('Routinen')?></title> #: /users/ruben/sites/v/routinen.php:43 msgid "Routinen" msgstr "Routines"

    Read the article

  • Better solution for boolean mixing?

    - by Ruben Nunez
    Sorry if this question has been asked in the past, but searching Google and here didn't yield relevant results, so here goes. I'm working on a fragment shader that implements both conditional/boolean diffuse and bump mapping (that is to say, you don't need a diffuse texture or a normals texture, and if they're not present, they're simply changed to default values). My current solution is to use a uniform float to say "mix amount". For example, computing the diffuse texel works as: // Compute diffuse amount scaled by vCol // If no texture is present (mDif = 0.0), then DiffuseTexel = vCol // kT[0] is the diffuse texture // vTex is the texture co-ordinates // mDif is the uniform float containing the mix amount (either 0.0 or 1.0) vec4 DiffuseTexel = vCol*mix(vec4(1.0), texture2D(kT[0], vTex), mDif); While that works great and all, I was wondering if there's a better way of doing this, as I will never have any use for in-between values for funky effects. I know that perhaps the best solution is to simply write separate shaders for mDif=0.0 and mDif=1.0, but I'd like a more elegant solution than splicing shaders before compiling or writing multiple shader files and keeping each one updated. Any ideas are greatly appreciated. =)

    Read the article

  • I can't click on some things and other problems

    - by Ruben
    I have some issues with my Ubuntu 12.04 . When I open Ubuntu Software Center, the program opens and than just disappears just when it is opened. My Ubuntu 12.04 won't install any updates because of this error in the picture. Worst of all: I can't click on anything except for programs that from Ubuntu: for example I can't browse the internet via Firefox or Chromium... I can't click on folders. I can't click on things in my Thunderbird mail program. But I can click on Update manager for example... It is just clicking that doesn't work, when I try 'clicking' something with using the tab-button and enter I can click on something - in every case. But that's just too annoying to do. Oh sorry guys I had some screenshots that illustrate the problems, but I can't get them off the 'problem pc ubuntu 12.04' about which I am talking... it's so sad

    Read the article

  • Problem with apache + ssl: length mismatch error and ocasional bad request

    - by Ruben Garat
    we migrated a server from slicehost to linode recently, we copied the config from one server to the other. Everything works perfectly except that we get: Occasional errors with "Bad Request", this error is not common, you can use it all day and not see it, and the next day it will happen a lot. apart from that, a lot of the time, event though the request works fine we get some errors. using ssldump we get: New TCP connection #1: myip(39831) <-> develserk(443) 1 1 0.2316 (0.2316) C>S SSLv2 compatible client hello Version 3.1 cipher suites Unknown value 0x39 Unknown value 0x38 Unknown value 0x35 TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA TLS_RSA_WITH_3DES_EDE_CBC_SHA SSL2_CK_3DES Unknown value 0x33 Unknown value 0x32 Unknown value 0x2f SSL2_CK_RC2 TLS_RSA_WITH_RC4_128_SHA TLS_RSA_WITH_RC4_128_MD5 SSL2_CK_RC4 TLS_DHE_RSA_WITH_DES_CBC_SHA TLS_DHE_DSS_WITH_DES_CBC_SHA TLS_RSA_WITH_DES_CBC_SHA SSL2_CK_DES TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA TLS_RSA_EXPORT_WITH_DES40_CBC_SHA TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 SSL2_CK_RC2_EXPORT40 TLS_RSA_EXPORT_WITH_RC4_40_MD5 SSL2_CK_RC4_EXPORT40 1 2 0.2429 (0.0112) S>C Handshake ServerHello Version 3.1 session_id[32]= 9a 1e ae c4 5f df 99 47 97 40 42 71 97 eb b9 14 96 2d 11 ac c0 00 15 67 4e f3 7d 65 4e c4 30 e9 cipherSuite Unknown value 0x39 compressionMethod NULL 1 3 0.2429 (0.0000) S>C Handshake Certificate 1 4 0.2429 (0.0000) S>C Handshake ServerKeyExchange 1 5 0.2429 (0.0000) S>C Handshake ServerHelloDone 1 6 0.4965 (0.2536) C>S Handshake ClientKeyExchange 1 7 0.4965 (0.0000) C>S ChangeCipherSpec 1 8 0.4965 (0.0000) C>S Handshake 1 9 0.5040 (0.0075) S>C ChangeCipherSpec 1 10 0.5040 (0.0000) S>C Handshake ERROR: Length mismatch from the apache error.log [Fri Aug 27 14:50:05 2010] [debug] ssl_engine_io.c(1892): OpenSSL: I/O error, 5 bytes expected to read on BIO#b80c1e70 [mem: b8100918] the server is ubuntu 10.04.1 the apache version is 2.2.14-5ubuntu8 the openssl version is 0.9.8k-7ubuntu8

    Read the article

  • Protect video with password

    - by Ruben
    Are they any method to protect video files with password, so player will ask for the pasword before playback? Currently I am protecting private video files using zip compression with password but it is very inconvenient. I am forced to uncompress huge files each time before watching, and than erase it using special utilities (to avoid further restoring). Please advice.

    Read the article

  • Slow SSD Read on Server 2008 SP2

    - by Ruben L.
    Im using a Intel X25-M 80G with the latest firmware. on XP /w using IDE and WIN7 using AHCI I get read speeds up to 250MB/S. But when running it with Server 2008 SP1 or SP2 on AHCI, I get read speeds around 180MB/S. Ive updated drivers for 2008, tested with writecache on/off. Any input would be appreciated. thanks!

    Read the article

  • Will I be abled to access 2nd HDD from dual-boot

    - by Ruben
    I'm planning to have a dual-boot on my computer. I have 2 physical hard drives, one 500GB and one 2TB. What I want to do, is have a dual-boot setup (2 partitions, both 50 GB) for Windows 8 and Windows 7. But will I be able to access the 3rd partition on the disk, or the other disk from both OSs? In this case, it would be really useful to access files and install programs, because I could use them on both OSs, as long as I have the same registry keys.

    Read the article

  • KnpLabs / DoctrineBehaviors Translatable - currentLocale = null

    - by Ruben
    Using the trait \Knp\DoctrineBehaviors\Model\Translatable\Translation inside an Entity, I see that the property currentLocale is never setted , so we always obtain the default locale ('en') in all the calls to $this->translate(). If I change this getDefaultLocale, all the translations are made correctly, so I think that is no problem with the fallback. I tried debug the currentLocaleCallable. I see that if I put a "var_dump ($this-container-get('request'));" in the contructor of currentLocaleCallable, the request have a locale to null. And outside the request has the correct locale.It seems that container is not in the scope: request , i don't know how can I get it to work I post an issue in github https://github.com/KnpLabs/DoctrineBehaviors/issues/71 EDITED This service is defined in vendor/knplabs/doctrine-behaviors/config/orm-services.yml and is: knp.doctrine_behaviors.reflection.class_analyzer: class: "%knp.doctrine_behaviors.reflection.class_analyzer.class%" public: false knp.doctrine_behaviors.translatable_listener: class: "%knp.doctrine_behaviors.translatable_listener.class%" public: false arguments: - "@knp.doctrine_behaviors.reflection.class_analyzer" - "%knp.doctrine_behaviors.reflection.is_recursive%" - "@knp.doctrine_behaviors.translatable_listener.current_locale_callable" tags: - { name: doctrine.event_subscriber } knp.doctrine_behaviors.translatable_listener.current_locale_callable: class: "%knp.doctrine_behaviors.translatable_listener.current_locale_callable.class%" arguments: - "@service_container" # lazy request resolution public: false EDIT 2: My composer.json "php": ">=5.3.3", "symfony/symfony": "2.3.*", "doctrine/orm": ">=2.2.3,<2.4-dev", "doctrine/doctrine-bundle": "1.2.*", "twig/extensions": "1.0.*", "symfony/assetic-bundle": "2.3.*", "symfony/swiftmailer-bundle": "2.3.*", "symfony/monolog-bundle": "2.3.*", "sensio/distribution-bundle": "2.3.*", "sensio/framework-extra-bundle": "2.3.*", "sensio/generator-bundle": "2.3.*", "incenteev/composer-parameter-handler": "~2.0", "friendsofsymfony/user-bundle": "1.3.*", "avalanche123/imagine-bundle": "v2.1", "raulfraile/ladybug-bundle": "~1.0", "genemu/form-bundle": "2.2.*", "friendsofsymfony/rest-bundle": "0.12.0", "stof/doctrine-extensions-bundle": "dev-master", "sonata-project/admin-bundle": "dev-master", "a2lix/translation-form-bundle": "1.*@dev", "sonata-project/user-bundle": "dev-master", "psliwa/pdf-bundle": "dev-master", "jms/serializer-bundle": "dev-master", "jms/di-extra-bundle": "dev-master", "knplabs/doctrine-behaviors": "dev-master", "sonata-project/doctrine-orm-admin-bundle": "dev-master", "knplabs/knp-paginator-bundle": "dev-master", "friendsofsymfony/jsrouting-bundle": "~1.1", "zendframework/zend-validator": ">=2.0.0-rc2", "zendframework/zend-barcode": ">=2.0.0-rc2"

    Read the article

  • Backup and Restore a SQLCE .sdf database

    - by Ruben Trancoso
    My application needs to backup and restore .sdf files. There is a single dataSet the the whole application and some bindngSource and table adapters on forms using this same dataset. Just for a sake of test I tryied to copy the .sdf in runtime for a backup folder and back to restore it and I got my application not finding the file like it was not there anymore. How should I manage connections to open and close the database since the dataSet do it automaticaly at begin and end of my application?

    Read the article

  • C# serial port driver wrapper class code and concept quality

    - by Ruben Trancoso
    Hi folks, Would like to know from all you guys what you think about my Serial Wrapper class. Had be a while I've beem working with serial port but never shared the code what somekind make closed to my very own vision. Would like to know if it's a good/bad approach, if the interface is enough and what more you see on it. I know that Stackoverflow is for question but at the same time there's a lot of very good skilled people here and share code and opinion can also bennefit everybody, it's why I decided to post it anyway. thanks! using System.Text; using System.IO; using System.IO.Ports; using System; namespace Driver { class SerialSingleton { // The singleton instance reference private static SerialSingleton instance = null; // System's serial port interface private SerialPort serial; // Current com port identifier private string comPort = null; // Configuration parameters private int confBaudRate; private int confDataBits; private StopBits confStopBits; private Parity confParityControl; ASCIIEncoding encoding = new ASCIIEncoding(); // ================================================================================== // Constructors public static SerialSingleton getInstance() { if (instance == null) { instance = new SerialSingleton(); } return instance; } private SerialSingleton() { serial = new SerialPort(); } // =================================================================================== // Setup Methods public string ComPort { get { return comPort; } set { if (value == null) { throw new SerialException("Serial port name canot be null."); } if (nameIsComm(value)) { close(); comPort = value; } else { throw new SerialException("Serial Port '" + value + "' is not a valid com port."); } } } public void setSerial(string baudRate, int dataBits, StopBits stopBits, Parity parityControl) { if (baudRate == null) { throw new SerialException("Baud rate cannot be null"); } string[] baudRateRef = { "300", "600", "1200", "1800", "2400", "3600", "4800", "7200", "9600", "14400", "19200", "28800", "38400", "57600", "115200" }; int confBaudRate; if (findString(baudRateRef, baudRate) != -1) { confBaudRate = System.Convert.ToInt32(baudRate); } else { throw new SerialException("Baurate parameter invalid."); } int confDataBits; switch (dataBits) { case 5: confDataBits = 5; break; case 6: confDataBits = 6; break; case 7: confDataBits = 7; break; case 8: confDataBits = 8; break; default: throw new SerialException("Databits parameter invalid"); } if (stopBits == StopBits.None) { throw new SerialException("StopBits parameter cannot be NONE"); } this.confBaudRate = confBaudRate; this.confDataBits = confDataBits; this.confStopBits = stopBits; this.confParityControl = parityControl; } // ================================================================================== public string[] PortList { get { return SerialPort.GetPortNames(); } } public int PortCount { get { return SerialPort.GetPortNames().Length; } } // ================================================================================== // Open/Close Methods public void open() { open(comPort); } private void open(string comPort) { if (isOpen()) { throw new SerialException("Serial Port is Already open"); } else { if (comPort == null) { throw new SerialException("Serial Port not defined. Cannot open"); } bool found = false; if (nameIsComm(comPort)) { string portId; string[] portList = SerialPort.GetPortNames(); for (int i = 0; i < portList.Length; i++) { portId = (portList[i]); if (portId.Equals(comPort)) { found = true; break; } } } else { throw new SerialException("The com port identifier '" + comPort + "' is not a valid serial port identifier"); } if (!found) { throw new SerialException("Serial port '" + comPort + "' not found"); } serial.PortName = comPort; try { serial.Open(); } catch (UnauthorizedAccessException uaex) { throw new SerialException("Cannot open a serial port in use by another application", uaex); } try { serial.BaudRate = confBaudRate; serial.DataBits = confDataBits; serial.Parity = confParityControl; serial.StopBits = confStopBits; } catch (Exception e) { throw new SerialException("Serial port parameter invalid for '" + comPort + "'.\n" + e.Message, e); } } } public void close() { if (serial.IsOpen) { serial.Close(); } } // =================================================================================== // Auxiliary private Methods private int findString(string[] set, string search) { if (set != null) { for (int i = 0; i < set.Length; i++) { if (set[i].Equals(search)) { return i; } } } return -1; } private bool nameIsComm(string name) { int comNumber; int.TryParse(name.Substring(3), out comNumber); if (name.Substring(0, 3).Equals("COM")) { if (comNumber > -1 && comNumber < 256) { return true; } } return false; } // ================================================================================= // Device state Methods public bool isOpen() { return serial.IsOpen; } public bool hasData() { int amount = serial.BytesToRead; if (amount > 0) { return true; } else { return false; } } // ================================================================================== // Input Methods public char getChar() { int data = serial.ReadByte(); return (char)data; } public int getBytes(ref byte[] b) { int size = b.Length; char c; int counter = 0; for (counter = 0; counter < size; counter++) { if (tryGetChar(out c)) { b[counter] = (byte)c; } else { break; } } return counter; } public string getStringUntil(char x) { char c; string response = ""; while (tryGetChar(out c)) { response = response + c; if (c == x) { break; } } return response; } public bool tryGetChar(out char c) { c = (char)0x00; byte[] b = new byte[1]; long to = 10; long ft = System.Environment.TickCount + to; while (System.Environment.TickCount < ft) { if (hasData()) { int data = serial.ReadByte(); c = (char)data; return true; } } return false; } // ================================================================================ // Output Methods public void sendString(string data) { byte[] bytes = encoding.GetBytes(data); serial.Write(bytes, 0, bytes.Length); } public void sendChar(char c) { char[] data = new char[1]; data[0] = c; serial.Write(data, 0, 1); } public void sendBytes(byte[] data) { serial.Write(data, 0, data.Length); } public void clearBuffer() { if (serial.IsOpen) { serial.DiscardInBuffer(); serial.DiscardOutBuffer(); } } } }

    Read the article

  • Trapping Error Status in MSBuild

    - by Ruben Bartelink
    As part of some build automation of running xUnit.net tests with MSBuild, I'm running into a case where I need to loop over a batch of items. Inside the loop, I need to detect whether an iteration failed, but I want to continue executing regardless. Then after the batched bit, I need to know whether one or more errors have occurred in order to report the outcome to TeamBuild. IOW, in pseudocode: Task Name=RunTests CreateItems ForEach item CallTarget Target=RunTest ContinueOnError=true CombineNUnitResults Report success/failure Task Name=RunTest XUnit item I'm hoping this can be achieved without a custom task (or hacking the xunit.net MSBuild task as Jonne did). (But willing to use MSBuild Community or Sdc tasks) And @BradWilson: I this is isnt possible to do cleanly, I'll be looking for Jonne's change a la the NUnit task to also make it into the xunit task See also: http://stackoverflow.com/questions/517560/how-do-i-get-team-build-to-show-test-results-and-coverage-for-xunit-net-test-suit

    Read the article

  • Change type of control by type

    - by Ruben
    Hi, I'm having following problem. I should convert a control to a certain type, this can be multiple types (for example a custom button or a custom label, ....) Here's an example of what i would like to do: private void ConvertToTypeAndUseCustomProperty(Control c) { Type type = c.getType(); ((type) c).CustomPropertieOfControl = 234567; } Thanks in advance.

    Read the article

  • What parts of .NET require administrative priviliges to be executed?

    - by Ruben Steins
    Which parts of the framework require a user to be more than a Standard User? The reason I'm asking is because I'm trying to compile a list of possible issues with our existing applications when migrating to Windows 7. Now, I can think of a few things myself: Writing to Eventlog Writing to Registry Keys outside of Current_User scope Getting an Environment variable etc... I really would like a more complete list and so far I've not come across a decent resource in which all this stuff is listed. Note that I'm not looking for ways of elevating the priviliges for the exsiting apps (which can be done by using a manifes), I'm simply idenitifying actions in code that might cause issues.

    Read the article

  • SQL CE unspecified error

    - by Ruben Trancoso
    Hello, I did a project with MS SQL Server CE that when installed in the 'costumer' machine just raises an unspecified excpetion. Did some research and looks like I did everything mentioned. The dev env has sql compact 3.5 installed and sql tools for vs 2005. Using dotNet 3.5. But to make it run in de dev machine I need to add the sqlcese30, sqlceqp30, sqlceme and sqlcecompact30 dlls and its works fine. The setup project put dotNet 2.0 as dependecy and I also added the dlls but it raises the exception and I cannot see where or what it is. Its just a single 'unspecified error' message. please help :)

    Read the article

  • Using SqlBulkCopy in a multithread scenario with ThreadPool issue

    - by Ruben F.
    Hi. I'm facing a dilemma (!). In a first scenario, i implemented a solution that replicates data from one data base to another using SQLBulkCopy synchronously and i had no problem at all. Now, using ThreadPool, i implemented the same in a assynchronously scenario, a thread per table, and all works fine, but past some time (usualy 1hour because the operations of copy takes about the same time), the operations sended to the ThreadPool stop being executed. There are one diferent SQLBulkCopy using one diferent SQLConnection per thread. I already see the number of free threads, and they are all free at the begining of the invocation...I have one AutoResetEvent to wait that the threads finish their job before launching again, and a Semaphore FIFO that hold the counter of active threads. There are some issue that I have forgotten or that I should avaliate when using SqlBulkCopy? I apreciate some help, because my ideas are over;) Thanks

    Read the article

  • Overriding LINQ extension methods

    - by Ruben Vermeersch
    Is there a way to override extension methods (provide a better implementation), without explicitly having to cast to them? I'm implementing a data type that is able to handle certain operations more efficiently than the default extension methods, but I'd like to keep the generality of IEnumerable. That way any IEnumerable can be passed, but when my class is passed in, it should be more efficient. As a toy example, consider the following: // Compile: dmcs -out:test.exe test.cs using System; namespace Test { public interface IBoat { void Float (); } public class NiceBoat : IBoat { public void Float () { Console.WriteLine ("NiceBoat floating!"); } } public class NicerBoat : IBoat { public void Float () { Console.WriteLine ("NicerBoat floating!"); } public void BlowHorn () { Console.WriteLine ("NicerBoat: TOOOOOT!"); } } public static class BoatExtensions { public static void BlowHorn (this IBoat boat) { Console.WriteLine ("Patched on horn for {0}: TWEET", boat.GetType().Name); } } public class TestApp { static void Main (string [] args) { IBoat niceboat = new NiceBoat (); IBoat nicerboat = new NicerBoat (); Console.WriteLine ("## Both should float:"); niceboat.Float (); nicerboat.Float (); // Output: // NiceBoat floating! // NicerBoat floating! Console.WriteLine (); Console.WriteLine ("## One has an awesome horn:"); niceboat.BlowHorn (); nicerboat.BlowHorn (); // Output: // Patched on horn for NiceBoat: TWEET // Patched on horn for NicerBoat: TWEET Console.WriteLine (); Console.WriteLine ("## That didn't work, but it does when we cast:"); (niceboat as NiceBoat).BlowHorn (); (nicerboat as NicerBoat).BlowHorn (); // Output: // Patched on horn for NiceBoat: TWEET // NicerBoat: TOOOOOT! Console.WriteLine (); Console.WriteLine ("## Problem is: I don't always know the type of the objects."); Console.WriteLine ("## How can I make it use the class objects when the are"); Console.WriteLine ("## implemented and extension methods when they are not,"); Console.WriteLine ("## without having to explicitely cast?"); } } } Is there a way to get the behavior from the second case, without explict casting? Can this problem be avoided?

    Read the article

  • Format date from SQLCE to display in DataGridView

    - by Ruben Trancoso
    hi folks, I have a DataGridView bound to a table from a .sdf database through a BindSource. The date column display dates like "d/M/yyyy HH:mm:ss". e.: "27/2/1971 00:00:00". I want to make it display just "27/02/1971" in its place. I tried to apply DataGridViewCellStyle {format=dd/MM/yyyy} but nothing happens, event with other pre-built formats. On the the other side, there's a Form with a MasketTextBox with a "dd/MM/yyyy" mask to its input that is bound to the same column and uses a Parse and a Format event handler before display and send it to the db. Binding dataNascimentoBinding = new Binding("Text", this.source, "Nascimento", true); dataNascimentoBinding.Format += new ConvertEventHandler(Util.formatDateConvertEventHandler); dataNascimentoBinding.Parse += new ConvertEventHandler(Util.parseDateConvertEventHandler); this.dataNascimentoTxt.DataBindings.Add(dataNascimentoBinding); public static string convertDateString2DateString(string dateString, string inputFormat, string outputFormat ) { DateTime date = DateTime.ParseExact(dateString, inputFormat, DateTimeFormatInfo.InvariantInfo); return String.Format("{0:" + outputFormat + "}", date); } public static void formatDateConvertEventHandler(object sender, ConvertEventArgs e) { if (e.DesiredType != typeof(string)) return; if (e.Value.GetType() != typeof(string)) return; String dateString = (string)e.Value; e.Value = convertDateString2DateString(dateString, "d/M/yyyy HH:mm:ss", "dd/MM/yyyy"); } public static void parseDateConvertEventHandler(object sender, ConvertEventArgs e) { if (e.DesiredType != typeof(string)) return; if (e.Value.GetType() != typeof(string)) return; string value = (string)e.Value; try { e.Value = DateTime.ParseExact(value, "dd/MM/yyyy", DateTimeFormatInfo.InvariantInfo); } catch { return; } } Like you can see by the code it was expexted that Date coming from SQL would be a DateTime value as is its column, but my eventHandler is receiving a string instead. Likewise, the result date for parse should be a datetime but its a string also. I'm puzzled dealing with this datetime column.

    Read the article

1 2 3  | Next Page >