baavgai's Profile User Rating: *****

Reputation: 6300 Overlord
Group:
Mentors
Active Posts:
13,496 (4.69 per day)
Joined:
16-October 07
Profile Views:
136,802
Last Active:
User is online 3 minutes ago
Currently:
Viewing Board Index

Previous Fields

Country:
US
OS Preference:
Linux
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
725
Expert In:
C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua, Cheese

Latest Visitors

Icon   baavgai has not set their status

Posts I've Made

  1. In Topic: Difference between two types of array declaration

    Posted 4 Sep 2015

    While in C you can't get away with it, in java arrays are just objects. The problem is that for the assigned version you basically have to create an anonymous object to assign. And when you do that, you need to be explicit about type.

    e.g. this should work:
    int[] array;
    array = new int[]{1,3,4,5};
    
    
  2. In Topic: object creation hints

    Posted 3 Sep 2015

    This looked amusing. I thought I'd play around with how I might do it:
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
      <meta charset="utf-8">
      <title>Some Title</title>
      <style>
        span {
          color: blue;
        }
      </style>
    </head>
    
    <body>
      <h1 id="theH">Some Heading</h1>
      <h2>Some Heading 2</h2>
    
      <p id="sample">Lorem ipsum dolor sit amet, <span>spanning it</span> consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    
      <!-- <input type="text" id="prop"> -->
      <select id="prop"></select>
      <input type="text" id="propValue" size="30">
    
      <script>
        var TheElement = function(el) {
          this.elem = el;
          this.props = {};
        };
    
        TheElement.prototype.setProps = function(prop, val) {
          this.props[prop] = val;
          var settings = '';
          for (var key in this.props) {
            if (this.props.hasOwnProperty(key)) {
              settings += key + ' : ' + this.props[key] + '; ';
            }
          }
          if (!settings) return;
          this.elem.setAttribute('style', settings);
        };
        
        
        function loadDropDown(ddId, txtId, sampleId, targets) {
          var theElements = [];
          var ddEle = document.getElementById(ddId);
          var txtEle = document.getElementById(txtId);
          
          var values = (function() {
            var sampleEle = document.getElementById(sampleId);
            var name = sampleEle.nodeName;
            var css = window.getComputedStyle(sampleEle);
            var d = { };
            for (var i = 0; i < css.length; i++) {
              var item = css[i];
              if (item.indexOf('-') != 0 && item != 'display') {
                d[item] = css.getPropertyValue(item)  + ' (default for ' + name + ')';  
              }
            }
            return d;
          })();
    
          var ddChange = function() {
            if (txtEle.value == '') {
              txtEle.value = values[ddEle.value];  
            }
          };
          
          var isTarget = function(target) {
            return (target && targets.indexOf(target.nodeName) > -1);
          };
          
          var setElement = function(x) {
            x.setProps(ddEle.value, txtEle.value);
            return x;
          };
          
          var addElement = function(target) {
            theElements.push(setElement(new TheElement(target)));
          };
          
          var updateElement = function(target) {
            for (var i = 0; i < theElements.length; i++) {
              if (theElements[i].elem == target) {
                setElement(theElements[i]);
                return true;
              }
            }
            return false;
          };
          
          var bodyClick = function(e) {
            if (ddEle.value) {
              var target = e.target;
              if (isTarget(target)) {
                if (!updateElement(target)) {
                  addElement(target);
                }
              }
            }
          };
    
          for (var k in values) {
            ddEle.appendChild(new Option(k, k));
          }
          ddEle.addEventListener('change', ddChange, false);
          document.body.addEventListener('click', bodyClick, false);
        }
        
        loadDropDown('prop', 'propValue', 'sample', ['H1', 'H2', 'P', 'SPAN']);
      </script>
    </body>
    
    </html>
    
    


    Note, I'd consider moving TheElement inside. Or, ditching it entirely, as it might be easier to just call the prototype code.
  3. In Topic: Copying a file in Powershell

    Posted 2 Sep 2015

    That doesn't make any sense.

    I just tried this:
    $client = New-Object Net.WebClient
    $data = $client.DownloadString("http://google.com")
    
    


    Google is still there!

    Look to your server and your $web_file_name. A web client can't make any changes to a server unless the server exposes an API that allows for changes.
  4. In Topic: Confused with java inheritance

    Posted 2 Sep 2015

    This has a whole lot to do either one word or one placement. First, the way you're probably doing it:
    import java.util.*;
    
    public class scratch {
        class MyStack {
            // use a constuctor for this init
            // Mostly because good practice
            // private ArrayList<Object> list = new ArrayList<>();
            private final List<Object> list;
            public MyStack() { this.list = new ArrayList<>(); }
            public boolean isEmpty(){ return list.isEmpty(); }
            public int getSize(){ return list.size(); }
            public Object peek(){ return list.get(getSize() - 1); }
            public void push(Object o){ list.add(o); }
            public Object pop(){
                Object o = list.get(getSize() - 1);
                list.remove(getSize() - 1);
                return o;
            }
            @Override
            public String toString(){ return "stack: " + list.toString(); }
        }
        public static void main(String[] args) {
            // where the hell are you initializing list?
            // we'll do it here
            MyStack list = new MyStack();
            list.add("string 1");
        }
    }
    
    


    Result:
    scratch.java:25: error: non-static variable this cannot be referenced from a static context
            MyStack list = new MyStack();
                           ^
    scratch.java:26: error: cannot find symbol
            list.add("string 1");
                ^
      symbol:   method add(String)
      location: variable list of type scratch.MyStack
    2 errors
    
    


    One fix is:
    public class scratch {
        static class MyStack {
        // ...
        }
    
        public static void main(String[] args) {
            MyStack list = new MyStack();
            // dude!  You didn't have an add method!
            // list.add("string 1");
            list.push("string 1");
        }
    }
    
    


    Note the static word on the inner class.

    Alternately:
    class MyStack {
        // ...
    }
    
    public class scratch {
        public static void main(String[] args) {
            MyStack list = new MyStack();
            list.push("string 1");
        }
    }
    
    


    Here, we have a normal class but it's outside the main class. Note the lack of public in the declaration. I prefer the second version, as it's flatter.

    Hope this helps.
  5. In Topic: Array's, Why So Confusing?

    Posted 1 Sep 2015

    I suppose we all kind of assumed that you were skipping the first and last positions on purpose. I mean, you were so explicit about it.

    So, now, it is seems reasonable to ask, why the hell are you skipping/ignoring the first an last positions?

    The sane way to get your total would be:
    uint getArrayTotal(uint [] xs) {
        uint x = 0;
        foreach(var y in xs) {
            x += y;
        }
        return x;
    }
    // ... 
    Console.WriteLine("x = {0}", getArrayTotal(valueArray));
    
    


    You have positited an rather inexplicable way that does something like:
    uint getArrayTotal(uint [] xs, uint startPos, uint endPos) {
        uint x = 0;
        for (uint i = startPos; i <= endPos; i++) {
            x += xs[i];
        }
        return x;
    }
    // ...
    Console.WriteLine("x = {0}", getArrayTotal(valueArray, 1, valueArray.Length - 2));
    
    


    If you're really set on the second option, then it doesn't much matter what data you have in your ignored spaces. However, you should be aware that "blank" isn't an option. Neither, as a prior poster seemed to assert, is null. If you had an array of object instances, you could go null. However, value types cannot be null, so must be some default value instead. In this case 0.

My Information

Member Title:
Dreaming Coder
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
Jersey, be afraid.
Years Programming:
25
Programming Languages:
Most.

Contact Information

E-mail:
Click here to e-mail me
Website URL:
Website URL  http://

Comments

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  1. Photo

    mireille4U Icon

    30 Apr 2015 - 05:26
    Greeting from mireille i saw your profile today and i became interested in you and i will like to know more about you and if you can mail an email to my mail address (mireille4u@live.com) i will give you my picture.here is my mail address i hope we can move from here.above. Mireille
  2. Photo

    ImChicago Icon

    17 Mar 2015 - 17:34
    Hey, im new to coding, how do you recommend starting? What should I master first? Should I use a website to help me?
  3. Photo

    8byte Icon

    10 Jan 2014 - 11:08
    Awesome, thanks for all the help!
  4. Photo

    codiddle Icon

    07 Mar 2013 - 18:59
    GENIUS GUY HERE MAN. Write a book!
  5. Photo

    mamelove25 Icon

    19 Feb 2013 - 10:53
    Hello My Dear, My Name is Mame. i saw your profile today and became interested in you,i will also like to know you more,and if you can send an email to my email address,i will give you my pictures here is my email address (mame25live@yahoo.co.uk) I believe we can move from here! Am waiting for your mail to my email address above because i have much to tell you,
    love Miss Mame.
  6. Photo

    bilbil0629 Icon

    24 Oct 2012 - 05:39
    hey! you mongolian?
  7. Photo

    Ticon Icon

    20 Aug 2012 - 13:23
    I just noticed your an expert in cheese. I lol'd
  8. Photo

    mostyfriedman Icon

    18 Aug 2012 - 23:13
    Hello there Brett
  9. Photo

    MehrdadSecret Icon

    26 Jul 2012 - 05:51
    hello, can i have a contact email or Yahoo or something? Need ur help badly
  10. Photo

    Jeet.in Icon

    18 Apr 2012 - 23:17
    Thanks ! Solved My problem !
    http://www.dreamincode.net/forums/topic/275578-simple-whitespace-remover/page__gopid__1603556&#entry1603556
  11. Photo

    RetardedGenius Icon

    25 Oct 2011 - 14:29
    I agree so much with your opinion of incompetent CS teachers. So true!
    http://www.dreamincode.net/forums/topic/252848-venting-a-frustration/page__view__findpost__p__1469659
  12. Photo

    WabiSabi Icon

    21 Oct 2011 - 11:00
    I agree with assert(C). However, I'd rather not specify what you are "the best" at.
  13. Photo

    assert(C) Icon

    20 Oct 2011 - 08:38
    You are the best
  14. Photo

    macosxnerd101 Icon

    30 Sep 2011 - 09:33
    Congrats on hitting the big 3k!
  15. Photo

    sjin Icon

    16 Aug 2011 - 18:41
    This guy is AWESOME! Cheers bro!
  • (3 Pages)
  • +
  • 1
  • 2
  • 3