Search Results

Search found 25343 results on 1014 pages for 'write protect'.

Page 83/1014 | < Previous Page | 79 80 81 82 83 84 85 86 87 88 89 90  | Next Page >

  • How do I write a writer method for a class variable in Ruby?

    - by tepidsam
    I'm studying Ruby and my brain just froze. In the following code, how would I write the class writer method for 'self.total_people'? I'm trying to 'count' the number of instances of the class 'Person'. class Person attr_accessor :name, :age @@nationalities = ['French', 'American', 'Colombian', 'Japanese', 'Russian', 'Peruvian'] @@current_people = [] @@total_people = 0 def self.nationalities #reader @@nationalities end def self.nationalities=(array=[]) #writer @@nationalities = array end def self.current_people #reader @@current_people end def self.total_people #reader @@total_people end def self.total_people #writer #-----????? end def self.create_with_attributes(name, age) person = self.new(name) person.age = age person.name = name return person end def initialize(name="Bob", age=0) @name = name @age = age puts "A new person has been instantiated." @@total_people =+ 1 @@current_people << self end

    Read the article

  • C++ Boost ASIO: how to read/write with a timeout?

    - by Stéphane
    From reading other Stackoverflow entries and the boost::asio documentation, I've confirmed that there is no synchronous asio read/write calls that also provide an easy-to-use timeout as a parameter to the call. I'm in the middle of converting an old-school linux socket app with select(2) calls that employs timeouts, and I need to do more-or-less the same. So what is the best way to do this in boost::asio? Looking at the asio documentation, there are many confusing examples of various things to do with timers, but I'm quite confused. I'd love to see a simple-to-read example of this: Read from a socket, but wait for a maximum of X seconds after which the function either returns with nothing, or returns with whatever it was able to read from the socket before the timeout expired.

    Read the article

  • How can I write to the previous line in a log file using Python's Logging module?

    - by turvyc
    Hi all, long-time lurker here, finally emerging from the woodwork. Essentially, what I'm trying to do is have my logger write data like this to the logfile: Connecting to database . . . Done. I'd like the 'Connecting to database . . . ' to be written when the function is called, and the 'Done' written after the function has successfully executed. I'm using Python 2.6 and the logging module. Also, I'd really like to avoid using decorators for this. Any help would be most appreciated!

    Read the article

  • Freelancer - client agreement. What things are worth to write explicitely?

    - by Dzida
    Hi guys, This is not technical question, though I think it is quite important for software developers who work as a freelancers. There is some general good advice to make paper contracts before starting new jobs. When I started my work as a freelancer I hadn't got any clue how such contract should looks like. Now I have some ideas but I believe many of freelancers gathered on SO can add some interesting advices for less-experienced colleagues (like me). So the question is: what clauses freelancers should put on agreements with their clients to make their projects less stressful and better secured. What are your experiences here? PS: Please write your country on the bottom of your post - I guess some stuff might be country specific. Probably there are differences in form of agreements depending on country where business is made.

    Read the article

  • How would you write this Clojure snippet in Ruby and/or Haskell?

    - by dnolen
    I was working on a Rails template and was trying to write a bit of code that allows me to populate a table or multiple columns of ul tags "top-to-bottom" and "left-to-right" across however many columns I specify. I'm just getting the hang of Ruby so I couldn't figure this out. I'm also curious about an idiomatic Haskell version for this useful snippet. Improvements to Clojure version appreciated: (defn table [xs & {:keys [cols direction] :or {cols 1 direction 'right}}] (into [] (condp = direction 'down (let [c (count xs) q (int (/ c cols)) n (if (> (mod c q) 0) (inc q) q)] (apply map vector (partition n n (repeat nil) xs))) 'right (map vec (partition cols cols (repeat nil) xs))))) With this bit of code I can then do the following: (table (range 10) :cols 3) Printed out this would look like so: 0 1 2 3 4 5 6 7 8 9 And the trickier one: (table (range 10) :cols 3 :direction 'down) Looks like so: 0 4 8 1 5 9 2 6 3 7

    Read the article

  • Java sockets: can I write a TCP server with one thread?

    - by hmp
    From what I read about Java NIO and non-blocking [Server]SocketChannels, it should be possible to write a TCP server that sustains several connections using only one thread - I'd make a Selector that waits for all relevant channels in the server's loop. Is that right, or am I missing some important detail? What problems can I encounter? (Background: The TCP communication would be for a small multiplayer game, so max. 10-20 simultaneous connections. Messages will be sent about every few seconds.)

    Read the article

  • Why I am forced to write the (Data Constructor) name with first letter in small case?

    - by Optimight
    Why I am forced to write "liOfLi" in place of "LiOfLi"? Please guide. code in baby.hs LiOfLi = [ [1,3,4,5,6,8], [ 12, 13, 15, 16, 19, 20], [23, 24, 25, 45, 56] ] ghci response: ghci :l baby [1 of 1] Compiling Main ( baby.hs, interpreted ) Failed, modules loaded: none. ghci baby.hs:29:1: Not in scope: data constructor `LiOfLi' When changing the initial letter to smaller case code in baby.hs liOfLi = [ [1,3,4,5,6,8], [ 12, 13, 15, 16, 19, 20], [23, 24, 25, 45, 56] ] ghci response: ghci :l baby [1 of 1] Compiling Main ( baby.hs, interpreted ) Ok, modules loaded: Main. Following are the SO questions I refered but I failed to understand the rules/ logic and get the answer for (my) abovementioned question. Why does Haskell force data constructor's first letter to be upper case? the variable names need to be lowercase. The official documentation related to this is at haskell.org/onlinereport/intro.html#namespaces – (the SO comment by) Chris Kuklewicz

    Read the article

  • GAE JCache NumberFormatException, will I need to write Java to avoid?

    - by Jasper
    This code below produces a NumberFormatException in this line: val cache = cf.createCache(Collections.emptyMap()) Do you see any errors? Will I need to write a Java version to avoid this, or is there a Scala way? ... import java.util.Collections import net.sf.jsr107cache._ object QueryGenerator extends ServerResource { private val log = Logger.getLogger(classOf[QueryGenerator].getName) } class QueryGenerator extends ServerResource { def getCounter(cache:Cache):long = { if (cache.containsKey("counter")) { cache.get("counter").asInstanceOf[long] } else { 0l } } @Get("html") def getHtml(): Representation = { val cf = CacheManager.getInstance().getCacheFactory() val cache = cf.createCache(Collections.emptyMap()) val counter = getCounter(cache) cache.put("counter", counter + 1) val q = QueueFactory.getQueue("query-generator") q.add(TaskOptions.Builder.url("/tasks/query-generator").method(Method.GET).countdownMillis(1000L)) QueryGenerator.log.warning(counter.toString) new StringRepresentation("QueryGenerator started!", MediaType.TEXT_HTML) } } Thanks!

    Read the article

  • Should I write small CGI scripts or a big, monolithic script?

    - by Space
    I am working on to create a web site to display some information about my system. This includes some graphs and some text information. For now I am creating different CGI scripts and calling them by creating links. A few days back one of my friends told me that instead of writting different CGI scripts, it's better to write single CGI script and create functions to call the part of code. I am confused. What do you prefer while creating a web site?

    Read the article

  • What is the fastest way to write hundreds of files to disk using C#?

    - by Ehsan
    My program should write hundreds of files to disk, received by external resources (network) each file is a simple document that I'm currently store it with the name of GUID in a specific folder but creating hundred files, writing, closing is a lengthy process. Is there any better way to store these amount of files to disk? I've come to a solution, but I don't know if it is the best. First, I create 2 files, one of them is like allocation table and the second one is a huge file storing all the content of my documents. But reading from this file would be a nightmare; maybe a memory-mapped file technique could help. Could working with 30GB or more create a problem?

    Read the article

  • In web project can we write core services layer without knowledge of UI ?

    - by Silent Warrior
    I am working on web project. We are using flex as UI layer. My question is often we are writing core service layer separately from web/UI layer so we can reuse same services for different UI layer/technology. So practically is it possible to reuse same core layer services without any changes/addition in API with different kind of UI technologies/layers. For e.g. same core service layer with UI technology which supports synchronized request response (e.g. jsp etc.) and non synchronize or event driven UI technology (e.g Ajax, Flex, GWT etc.) or with multiple devices like (computers, mobiles, pdas etc.). Personally I feel its very tough to write core service layer without any knowledge of UI. Looking for thoughts from other people.

    Read the article

  • When I write a post on the board, with the posts and tried to put the image into

    - by bismute
    When I write a post on the board, with the posts and tried to put the image into. When I add an image, the text in the image are about to enter. <?php $reg_date = time(); $member_idx = $_POST['member_idx']; $q = "INSERT INTO ap_bbs (member_idx, subject,content,reg_date) VALUES('$member_idx', '$subject', '$content', '$reg_date')"; $result = $mysqli->query($q); if ($result==false) { $_SESSION['writing_status'] = 'NO'; } else { $_SESSION['writing_status'] = 'YES'; } $mysqli->close(); ?> Writing, I think the logic is as follows, where the images in the attachment content and I'm wondering if there is any way to put.

    Read the article

  • is it a good idea to write tests for environments other than development?

    - by jcollum
    Let's say I have a (fairly typical) set of environments: PROD, UAT, QA, DEV. Is it a good idea to run your tests across all environments? Here's what I'm thinking of. I have a proc in SQL that my code depends on, I'll call it proc_getActiveCustomers. If that proc isn't present my app will go south real fast. So I write a test that checks for the existence of this proc in the database. Nothing new here. But when I then deploy my app to the QA environment, would I also want to have a test that checks that environment for the existence of proc_getActiveCustomers? I think this is a good idea but I've never heard much about testing in environments outside of development. Makes me wonder if there's some downside I'm not aware of. The direction that I'm going is to have a list of environments in code and then passing that environment into my unit test.

    Read the article

  • How to handle this "session failed to write file" error in PHP?

    - by alex
    I am using the Kohana 3 framework, and am using the native session driver. For some reason, occasionally the sessions fail to write to their file. Warning: session_start() [function.session-start]: open(/tmp/sess_*****, O_RDWR) failed: Permission denied (13) in /home/site/public_html/system/classes/kohana/session/native.php on line 27 I am pretty sure Kohana has its own in built error handler, but it is not triggered with this error (i.e. it shows up like a normal PHP error, not the Kohana error). Anyone that has ever used Kohana will notice this seems to have bypassed Kohana's error handling (perhaps set with set_error_handler()). Is there anyway to stop this error from appearing without switching from the native session (i.e. file based) driver? Should I just give good practice the boot and append an @ error suppressor to session_start() in the core code of Kohana? Should I relax the error_reporting()? Thanks

    Read the article

  • Is it Possible to Write in a DropdownList or listbox?

    - by user280048
    work on Asp.Net C# vs08. I was wondering if it is possible to write in a dropdownlist or listbox such that if somebody does not want to select from the dropdownlist or listbox, he/she can type the value and if the value exist in the dropdownlist/listbox, it autofills. The person may then select it. If this is not possible in ASP.NET, would anybody know of another control that can be used for the same purpose and how? what I really need is how to allow the writting on the DropDownList, please someone help me!. Thank you very much.

    Read the article

  • How do I write a Guice Provider that doesn't explicitly create objects?

    - by ripper234
    Say I have a ClassWithManyDependencies. I want to write a Guice Provider for this class, in order to create a fresh instance of the class several times in my program (another class will depend on this Provider and use it at several points to create new instances). One way to achieve this is by having the Provider depend on all the dependencies of ClassWithManyDependencies. This is quite ugly. Is there a better way to achieve this? Note - I certainly don't want the Provider to depend on the injector. Another option I considered is having ClassWithManyDependencies and ClassWithManyDependenciesProvider extend the same base class, but it's butt ugly.

    Read the article

  • Can JQuery/JavaScript be used to write a substantial client side application?

    - by Ian
    I have an unusual situation - I have an embedded video streaming device with a complicated UI, and I need to use an embedded web server to reproduce that UI through a web browser. I'm thinking of using JavaScript/JQuery on a C++ backend (I am NOT coding all this myself, I need to hire people for the grunt work). The embedded web server is much less powerful than a PC, so I want to write an application that runs the entire UI in the browser, and only communicates with the server to pass new program settings back and forth, get status updates from the device, and control video playback. In other words, the client gets one big page or a small number of big pages (effectively downloading the application), the application maintains significant local memory storage, and once the pages are first loaded the server never sends anything layout-related. The application has two rows of tabs to navigate ~40 menu pages, drag-and-select controls to pick cells in a grid, sorted lists, lots of standard data entry options, and it should be able to control up to 16 embedded video players at once (preferably VLC). Is this possible in JavaScript/JQuery with a C++ backend?

    Read the article

  • Can you write to a file (on a disk) in JavaScript?

    - by asdfqwer
    I don't wanna come across as a troll, so please excuse my question's demeanor, but I am a novice-intermediate programmer taking a stab at AJAX. While reading up on JavaScript I found it curious that most of the examples I've been drawing on use PHP for such an operation. I know many of you may argue that 'I'm doing it wrong' or 'JavaScript is a client-side language' etc. but the question stands. . .can you write a file in only JavaScript? EDIT: Sorry, just read faq, failed to mention this my first post on Stackoverflow while I hope I'm not sounding argumentative, pompous, or subjective.

    Read the article

  • Need help with this question: Write Java code which reads numbers from the keyboard.....

    - by Chris
    Write Java code which reads numbers from the keyboard until zero is entered. Only the positive numbers entered are to be added to a variable-sized collection. This is what I have so far: import java.lang.*; import java.util.*; import java.io.*; import java.net.*; public class Demo1App extends Object { public static void main(String[] argStrings) throws Exception { ArrayList myArrayList = new ArrayList(); Scanner input = new Scanner(System.in); System.out.println ("NUMBERS:"); while (int input > 0) { myArrayList.add(input); } while (int input < 0) { System.out.println ("ENTER NUMBERS GREATER THAN 0!"); } } } This code doesn't work, I'm not sure why but any help with it would be appreciated.

    Read the article

  • How to write an unit test for WCF behaviors?

    - by katie77
    I am new to unit testing. How do I write a unit test for a method when I am extending a WCF behavior. Since I am not sure of when the class is being instantiated, or I can not change the method signature. In the behavior implementation, I am getting the header and looking up a value in the config. public class IncomingValidator : IDispatchMessageInspector { public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) { // Grab the header and see if one of the particular values(read from config) is there. } public void BeforeSendReply(ref Message reply, object correlationState) { } }

    Read the article

  • How can I write my code to attempt a database action but continue executing code on failure?

    - by Chris
    Simple question I guess, I want to use PHP to write an update to an existing row in my database, if it doesn't happen I want to log the failure but continue executing the code. While it would be nice to have records of failures to track down issues, that the update failed isn't that important to my user, nor will it affect the running of any other code; the query is simply for a 'cosmetic' but entirely unnecessary piece of information. My database class's query function is set to die on failure, could I modify that or is there another way of doing it without altering my standard query code?

    Read the article

  • JQuery: how to write a selector to find elements with a class ending with a given substring?

    - by curious1
    I use JQuery for my web application. I don't know how to write a selector for this situation. <a class="abc def xyz-delete-confirm efg">text</a> <a class="abc def delete-confirm">text</a> I need to find all links that has a class ending with "-delete-confirm" or has a class called "delete-confirm". I know how to handle the situation of having a class called "delete-confirm". How about the "-delete-confirm situation"? Can I have a single selector covering two situations? Thanks for any input! Regards.

    Read the article

  • What language should I write my 2D game in? [closed]

    - by jmgrosen
    I'm thinking of writing a game. It's inspired by Minecraft/Terraria (but don't worry it will be different). My main question is what language I should write it in -- it'll be relatively simple graphics, more like Terraria than Minecraft. I know Java relatively well and Minecraft is written in it, but C++ seems like the industry standard for game development. However, I know next to no C++. I'm willing to learn but am worried how it will turn out for my first real project in the language. In addition to that, I'd also like suggestions on a good game engine for the language that you suggest. I'd like it to run on: Windows for sure Linux for sure Mac for sure Android would be really nice iOS is optional Thank you in advance!

    Read the article

  • Why don't I have write permission to my vmware virtual network device?

    - by Robert Martin
    I want to allow my VMWare machine to force the virtual network it's on into promiscuous mode so I can play around with honeyd. I received an error message that told me to go to http://vmware.com/info?id=161 to allow this behavior. Based on their advice, I did: $ groupadd promiscuous $ cat /etc/group | grep promiscuous promiscuous:x:1002:robert $ usermod -a -G promiscuous robert $ id robert uid=1000(robert) gid=1000(robert) groups=1000(robert),....,1002(promiscuous) $ chgrp newgroup /dev/vmnet8 $ chmod g+rw /dev/vmnet8 $ ls -l /dev/vmnet8 crw-rw---- 1 root promiscuous 119, 8 2012-03-29 10:29 /dev/vmnet8 Looks like I gave RW permission to the promiscuous group, and added myself. Except that VMWare still gives me an error message that says I cannot enter promiscuous mode. To try out the group thing, I tried: $ echo "1" >/dev/vmnet8 bash: /dev/vmnet8: Permission denied That really surprised me: It makes me think that I still haven't properly given myself the correct permissions... What am I missing?

    Read the article

  • How do I tell sudo to write files with a umask of 0022?

    - by mipadi
    I recently upgrading to Snow Leopard. I have noticed that some files written by MacPorts are installed with the wrong permission -- they are written with a umask of 0077. I think I have narrowed down the problem: The port command is invoked via sudo. My .bashrc file specifies a umask of 0077. On older versions of OS X (10.5 and below), sudo used the umask of the root user (which was 0022); however, now it uses my umask of 0077. Is there anyway to have sudo use the old behavior? Right now, it's kind of annoying because I have to use sudo to run simple commands like port installed, port outdated, etc. (The problem is described in more detail in this MacPorts ticket.) Edit I discovered the umask option for sudo, and in /etc/sudoers I added the following line: Defaults umask=0022 However, this did not function as desired, because the real umask used by sudo is the union of the user mask with this default mask.

    Read the article

< Previous Page | 79 80 81 82 83 84 85 86 87 88 89 90  | Next Page >