1. There is awhile that I wrote something blog text like. Times have changed and I have also changed. I now have kids and I also work in much different environment than before. 

    Today I am afraid to write english because still I have trouble using a and the in all correct places. Still the truth is that I speak and write much better english than I did 3 years ago. This is of topic but I still like to state that if you are not native an english speaker, it really is ok to have some mistakes in a written text. I think it is kind of a cancer of the chat forums that non-native english writing people have to always apolotize their language although they speak and write english really well. By writing and speaking anyone can master the skill of speaking foreign language. So please let them. Main thing is to be understood and if there are some mistakes, a constructing feedback is better than saying something that is almost offensive or negative. I am willing to learn more and I asure you that my english will never meet the requirements to call my english skills as ”native proficiency”. 

    Learning is a funny thing. When you are young you have other things to do than just studying. Some like me have had a problem to be that A+ student because other things were more exciting. I did not even have that much things to do. Certain topics in the school just were not that interesting. Or on the other hand those were interesting but when I had to read to exams, lot of things were more interesting than the idea of forcing myself to remember all the presidents of Finland for example.

    I am not saying that now when I am older, I am now more interested to learn history. Some of the topics that were hard topics have now become exciting and easy. I just feel like it is much easier to learn. Ow when I have time and even motivation that I lacked when I was younger. Currently there are two skills on top that I want to learn. Playing the piano and learning the Russian language (русский язьик, да?). 

    Duolingo is a good tool to learn basics of some language. Or atleast I think so. I do not know if I have learned anything real and are those things that I have learned any good in real life. Certainly I do not yet understand much from Youtube-videos that are in Russian. Still I have 150 days streak in Duolingo, so should I understand more than some just words there and there. Well still it has been fun and I think I have pretty solid ground and basics of Russian language to start from when I go to my first language course that is called Russia 1. 

    As mentioned I also started to ”play” piano. I have now been in two sessions I am even doing my home work. When I was a child I never did those home work that my piano teacher gave me. I hated those. Now I am willing to play from notes by my own to learn more. Times like after lunch and kids playing with Legos is a great time to practice. 

    At the same time my profession requires constant learning. There is always some new things to learn and some new clones of React or Vue popup constantly. I have to learn those new things to compete with the younger generation, or ok, not to compete but stay up-to-date on those things. Good that I still have so much nerdy passion for these things, otherwise it would be really hard to keep up to the constantly changing technology. 

    The topic was about the brain’s capacity. As said there are three things to me that are now on my learning list. One are those web frameworks, Unity and getting better in C#… tech stuff you know. Two is the Russian language. I did not even mention why I started to study it, it just happened. I could have continued my Swedish studies also but … lot more people speak Russian than Swedish so thats why Russian. And then the third is piano. 

    What I have noticed at the old age (37 is young for some) is that it is lot easier to study because I can study beacuse I want to and not because I have to. But there seems to be limitations in my brain’s capacity. When I started these piano classes Duolingo and its daily Russian studies were not that interesting any more.   Maybe the piano studies ate that one brain slot or at least 3/4 brain slots and that is why now it is much harder me to concentrate on those two things fully. 

    Only two things. That is nothing and I am already struggling. When I was a ”real” student there were at least 6 topics simultaneously to learn. How those then fitted in to these brain slots I cannot understand. Maybe age eats those slots.

    What do you think? Is it easier to learn stuff when you are little older or is it just me?

    -Peter


    0

    Lisää kommentti

  2. Just testing this awesome feature that UE4 has.

    I myself don't have Maya so I have to try to do everything with Blender.

    To test Vector Fields I didn't want to waste anytime so I pulled ready to user .fga files from here https://forums.unrealengine.com/showthread.php?63147-TOOL-Blender-Vector-Field-Editor. Thanks to Isathar.

    There is tutorial how to do .fga import.
    https://wiki.unrealengine.com/Creating_Vector_Fields_(Tutorial)

    I myself find this tutorial as not very informative so I made a GIF-series how to do this by the tutorial.

    Setting up a particle system with a Local Vector Field

    1. Create a new particle system in the content browser. Once it is created, the Cascade window will appear.
    So import .fga file to UE4. Then create Particle system in to the same folder and open it. These steps should be pretty straight forward so I didn't do "how to" gifs for those.

    2. Right-click on the black space above the emitter's module and convert the particle system dataType to GPU Sprites.




    3. Next, add a Cylinder location module with its Height axis set to Y. 





    Increase the Spawn module Rate property to around 50. Then delete the Initial Velocity as the particle motion will come from the local vector field. You should have something similar to this:



    4. Right-click below the existing modules and add a local vector field module to the emitter.




















    5. Assign the vector field asset to the Vector field slot in the Local vector field cascade module. You may want to visualize the vector field velocities in the viewport by selecting the **View > Vector Fields** inside Cascade's main menu.




















    6. In its parameters, scale the Vector Fields's relative scale to 2 2 2 and translate the grid using the vector fields gizmo which appears in the Cascade preview window when the Local vector Field module is selected.

    In version below I used (X=0.040000,Y=0.040000,Z=0.200000)













    Locate vector field to desired location. Notice that if vector field is too big for particle systems particles won't "fly" as vector field guides them.


    Selecting Particle


    Remember to set bounds, otherwise particle system disappears when the camera turns away from the particle system.



    Drag and drop Particle System to scene

    Final system

    Sorry for bad English or spelling mistakes. This tutorial was made quickly.
    0

    Lisää kommentti

  3. This one took me some time to get it functioning. Easy looking things may be many times real pain in the ass. Well pain is now gone and I'll show the solution, that you don't have to suffer.

    I presume that you are somewhat familiar with Drupal 8 REST. Well there isn't lot of new info here if you aren't stuck in same thing that I was.

    I got REST working. REST it self isn't so hard to get function. After all its built in in Drupal 8. My challenges were that I call Drupal REST api from other domain. I had to configure CORS, authentication and other stuff that allow me to make node content with ajax-call.
    Well I didn't want to tell about my project. It's nothing special. This quickie is about date in JSON formatted ajax-call.

    Date is little bit different than other REST values.
    Normal part of JSON goes like this:
    "field_timeestimation" : [
      {
         "value" : "90min"
      }
    ],

    Date doesn't work like this:
    "field_test_date" : [
      {
         "value" : "2016-12-01"
      }
    ],

    System answers 422 (Unprocessable Entity). What the hell 422 even is? Full JSON response goes:
    error:"Unprocessable Entity: validation failed.↵field_test_date.0.value: This value should be of the correct primitive type.↵"

    Same answer comes from this(doesn't work):
    "field_test_date" : [
      {
         "value": {"date":"31-12-2016"},
      }

    ],

    And lot of same kind of tries later. Finally understood the problem. I have to have format attached to a date. System doesn't understand my 2016-12-01 because there isn't format info with it. I think that is why this primitive value error comes although I have a date in "correct" format.
    So go to /admin/config/regional/date-time. I use short format so go and press Edit button after it. Page will show that formats machine name is short. Great!
    Machine name: short

    So lets attach this to JSON and voila!(does work):
    "field_test_date" : [
      {
         "value" : "2016-12-01"
         "format" : "short",
      }


    ],

    This thing "How to store date via ajax in Drupal 8 REST api" is one thing that I couldn't find anywhere. Believe me I tried to Google really hard. Hopefully this helps some in someones elses project. I'm glad that I can just move on with my own project.

    1

    Katso kommentit


  4. Ok I have gotten little bit more familiar with my NodeMCU, I'll show and tell little bit more about my latest experiments.

    I have order lots of stuff from Ebay recently.
    One was this http://goo.gl/O8TeTx. Long name Rain Sensor Module Sensitivity Weather Humidity Detect Module for Arduino. So it's Arduino module but it works fine with NodeMCU. Also there isn't many NodeMCU modules outhere so you have to be creative.

    Attaching module to NodeMcu was pretty easy. I used NodeMCU it self as a power source. Just put VCC and GND in from available GND and VCC pin. Notice that Ebays description says that nominal voltage for this module is 5v. Yes it worked well with 5v but I also tried 3.3v pin. It works as well.

    Then the part where a data cable is attached to NodeMCU, There is DC and AC pins in module. Those are Digital pin and Analog pin. First I used digital pin.
    I tried to connected it to available GPIO pin. I got something out but nothing readable. It also crashed my NodeMCU repeatedly.
    Then I searched little bit and found out that there is analog pin in NodeMCU. Nice! ADC pin is first pin from right in NodeMCU right under NodeMCU logo cloud.

    I attached AC pin to ADC and voila I got something. Value 1024. Testing works well with wet cloth or paper.

    Here is little bit of lua code that I used.
    print('Humidity v0.1')
    dly = 500

    function getAnalog()
    id = 0
    print("Reading value " .. adc.read(id))
    end

    tmr.alarm(0,dly,1,getAnalog) 

    And it prints when something wet is on the sensor.  
    Reading value 376
    Reading value 373
    Reading value 370
    Reading value 369
    Reading value 368
    Reading value 370

    Reading value 1024

    Next I'll make little script that connects to server and send data there. Why? Dunno. It is just nerdishly fun to collect data.

    More stories coming....





    1

    Katso kommentit


  5. It has been a long time since i wrote anything. Well new nerdy thing interest me and I bought this Node MCU. What I'll do with it, I don't have a glue.

    Getting started wasn't plug &play for me. So I gathered few things here that you need to even get this piece to work.

    Step 1.
    First if you are using Win7 you may need this driver.
    From my Copy
    https://copy.com/nxuVgqtckjVRCHtP
    Or from here
    http://www.wch.cn/download/CH341SER_EXE.html
    (Both seem fishy but both are legit links without any virus or malware.)

    If you wonder where I got my Node MCU it was from here:
    http://www.banggood.com/NodeMcu-Lua-WIFI-Development-Board-For-ESP8266-Module-p-976440.html

    Step 2.
    Now plug in your Node MCU.
    Instantly you should see that it worked. Before the driver install there was only COM1 port on a Device Manager list.






    Step 3.
    Does it really work? Well you can test it with this little program.
    From my Copy
    https://copy.com/do3Xd3GAvafod7zL
    Or from here
    http://benlo.com/esp8266/

    Step 4.
    Run LuaLoader program. Go to Settings -> Comm Port Settings.
    Change the Port if needed to correspond port that you see in Device Manager. In this case I had to change it to COM4. Click ok and go to Settings again and click Open COM4.
    Program will write to console:
    Connected to COM4 at 9600 baud

    Step 5.
    Set up that WIFI there as well. Input SSID and password click image on right hand side of Get IP button.
    Program will write to console:
    ¶Eü|vñ¤l, xÉE¬tð4C4èðØdà•lb8XìÁH``$:IdprüÿÏ}ŸÏþžÏþþÜ?½

    Tadaa! It works.

    For more info go to http://benlo.com/esp8266/esp8266QuickStart.html

    Moment ago I downloaded this
    https://github.com/nodemcu/nodemcu-flasher
    It seems to say connect.world() so I think that everything as it should be.

    This was guide for total dummys like my self. Now I'm going to investigate more this little device. Lets see if it leads to anything.

    -------
    Little bit later after some disc golfing.
    -------

    I found out that I did it little wrong. I should have run Nodemcu firmfire programmer first. So disconnect LuaLoader(it's important otherwise COM4 port is occupied and doesn't work). You dont have to shutdown LuaLoader though. Then press Flash(F) button on Nodemcu firmfire programmer.













    Wait for a bar to complete and voila.
    Now if you check Wifi connection on LuaLoader it doesn't print out nonsense anymore.

    -Peter


    0

    Lisää kommentti

  6. If you create dynamically content to a website you may have encountered this problem.

    Scenario

    I have a web page that makes content dynamically. The content includes some clickable content like a button. The button that was made looks good but if you click it nothing happens.

    Look at example one.

    Most important parts of the code looks like this:

    Example 1

    Of course second button won't work because it's created after it's click function. Ok it's easily fixed as picture below presents.
    Example 2.

    Just move the highlighted click function inside the function that creates a button.


    The point

    Examples above are the basics what every jQuery using coder should already know. Point of this blog text is what if button is created twice? Click functions are also created twice at same time. So when button creation is fired twice the same function runs twice although it's unwanted behaviour. 

    Example 3.

    In example three, two dynamic buttons are created with for loop. This means that if last button is clicked the alert box will appear twice. 
    There is away to prevent this. I have faced this problem many times and appears that I haven't searched the answer enough from jQuery documentation. Now I found the answer and it's as the title says "unbind()".

    Example 4.


    Highlighted part on a picture shows the function. When function runs again and again you just have to unbind the old click-function every time the function runs. This way as example shows only one alert box appears when the last dynamically created button is clicked.

    Hopefully this tutorial how will help you. It certainly will ease my life.

    0

    Lisää kommentti


  7. Finnish TTVK (Tekijänoikeuden tiedotus- ja valvontakeskus ry) is planning to sue two Finland's biggest internet service providers Elisa and TeliaSonera. This is because TeliaSonera and Elisa provide their users a recording possibility in their IPTV-service.

    At last the IPTV seems to become a basic thing in Finland. IPTV’s advantages are that all tv-channels can be watched whether you were in cable or antenna home. Almost any IPTV program can be recorded to the service providers cloud. Users that have IPTV don’t have a need for big digiboxes with big and slow hard drives. Another advantage is that user can record any amount of programs at the same time in any amount of channels. Yours truly has a Wbox HD2 that can record three channels at the same time as you watch a fourth channel. Turning from IPTV to this normal digibox was first challenging because I have had a habit to record any program from EPG that interested me.

    Well to the point. IPTV is the best thing since turning the analog tv to digital. It’s a breakthrough that encourages service providers to enhance their outdated ADSL-connections. If you wonder why, I’ll explain. Let’s think that family has 24/1mb ADSL-connection and someone from the family watches HD-channel through IPTV and one surfs the Internet and watches videos from YouTube. It doesn’t take too long to notice that lame 24/1mb connection isn’t just enough. HD-channels will start to make loud cracking noises and it will be more like watching a cartoon than watching a movie. YouTube user notices that YouTube won’t buffer fast enough.

    The family that has IPTV is probably pleased with the service and just don’t want to give up because the connection isn’t fast enough. This means that family needs faster DSL-connection and they probably will contact their service provider to get the faster connection. The main point of this post. Finnish service providers don’t currently have any better connections to offer to the general public than 24/1mb. This is because of ADSL2+ can’t offer faster connections and it’s currently only technique that is available almost for everyone in Finland. I think that if customers need faster connections, service providers will find the way to provide the connection for customer sooner or later. If it doesn’t exist now, it doesn’t mean that it won’t exist in the future. It will improve infrastructure and will help Finland to keep its place at cutting edge of technology. TTKV, which was mentioned in the beginning of this blogpost is now planning to slow this improvement.

    It’s very short sighted to think that IPTV-recording services will harm anyone. It’s very far from piracy and is very equivalent to recording with digibox or even with VHS. Well, it does little harm. Let’s say that Expendables comes from tv and I record it with my IPTV. It will stay there for 90 days. TeliaSoneras service allows user to have recordings 90 days stored until those will be erased. That little harm is that I won’t probably buy or rent the movie for these 90 days because of my awesome IPTV-service. It’s a small harm comparing to piracy that happens in the internet for example by Piratebay like services. Almost all movies that come from tv are at least three years old. Not many people will rent or buy those movies or series. Notice also that TeliaSoneras service won’t allow user to record payed CMORE, MTV nordic, Discovery or any other cable like channels.

    What TTKV is doing is almost criminal. IPTV-recording is an easy target while they can’t do anything to REAL piracy. I really suggest that people at TTKV consider to get a real job or at least try to do their current job the way that it won’t hurt general public.
    4

    Katso kommentit

  8. I think I don't have to start telling how good jQuery Mobile(JQM) framework is. I think it's the fastest way to create mobile-webpage for newer smartphones. I have tested this framework with iPhone 4 (iOS), iPad 1 and 2 (iOS), HTC Desire HD (Android), Samsung Galaxy Tab (Android), HTC Mozart (WP7), Nokia Lumia 800 (WP7) and amazing Nokia 5230 (Symbian).
    I even got my hands on a Blackberry tablet for few minutes. Unfortunately my mobile detection didn't count it as a mobile device so I can't tell how well JQM works on it.
    Devices that understand JQM well and run it smoothly are iOS and Android devices. Amazingly JQM works in Nokia 5230's own browser. It doesn't look as good as on iOS or Android devices, but it’s functional. JQM works with WP7 also. Full list of supported devices can be seen here.

    #Skip this part if you are not interested in my opinions#
    I'm from Finland, the land of Nokia. The great Nokia has employed Finns for decades and is the most known brand from Finland.
    Actually it's not too long time ago that I admired Nokia myself. I was very proud of that we had something like Nokia in this little cold country. This is the time when Nokia had just published E63 and E71 "smartphones". I still think that those were one of the best business smartphones of that time. Those were little bit like Blackberry rip-offs but what can you do if you can’t buy Blackberry from Finland.
    To the point. For a long time now I haven’t had faith in Nokia. Finland or Finnish shareholders own only a little fraction of Nokia. Well, head office of Nokia is still located in Finland, but I think that not for long anymore. Deal (or alliance) with Microsoft was the last nail in the coffin.
    As a developer, WP7 operating system looked promising. I had my first glance of it at Geeks On Wheels-seminar at Tampere. It's promising but I think that it's too raw operating system for Nokia. Android or Maemo would have been better choices. Personally I think that engineers that have worked at Nokia have that kind of knowledge that when they leave Nokia, we will soon have lots of new innovative companies at Finland. These companies will do the same for the technology world that Angry Birds did for the gaming world.
    These are just my own opinions and the point of this blog text was not to tell how sad I'm because of Nokia.
    #Skip this part if you are not interested of my opinions#

    The problem that this blog-post solves is explained next. If content like list items is fetched with ajax the JQM-theme won’t work on it. This is because the JQM does different kind of changes at start to the content that is inside the pages.

    JQM will change next button from this:
    <a href="#" class="notheme_button" data-role="button">No theme button</a>
    in to this:
    <a class="notheme_button ui-btn ui-btn-up-c ui-btn-corner-all ui-shadow ui-btn-up-undefined" data-role="button" href="#" data-corners="true" data-shadow="true" data-iconshadow="true" data-inline="false" data-wrapperels="span">
    <span class="ui-btn-inner ui-btn-corner-all">
    <span class="ui-btn-text">No theme button</span>
    </span>
    </a>


    If the content is fetched with ajax and placed to some JQM-page it won't do these changes. Thats why I'm introducing .trigger("create").

    This is the normal JQM page:
    <div data-role="page"  data-theme="c" id="main">
        <!-- header -->
        <div data-role="header" data-theme="a">          
            <h1>.trigger("create");</h1>
        </div>
        <!-- header -->
        <!-- content -->
        <div data-role="content">
            <a href="#" class="notheme_button" data-role="button">No theme button</a>
            <a href="#" class="button" data-role="button">Refresh theme button</a>
            <div id="job_list">
            </div>
        </div>
        <!-- content -->
    </div>

    Let's say that we want to put content inside to div#job_list with ajax. Content that I want is links styled with listview.
    Let’s fetch the content like this:
    $(".button").click(function(){
        ajax_procedure("ajax.php?giveLinks=yes","theme");
    });

    Simple javascript ajax function(You can use jQuery .ajax() or .get() too).
    function ajax_procedure(ajax_url,style){
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }

            xmlhttp.open("GET",ajax_url,false);
            xmlhttp.send(null);
            //alert(xmlhttp.responseText);
            if(style == "theme"){
                theme(xmlhttp.responseText);
            }
            else{
                notheme(xmlhttp.responseText);
            }
    }

    Here is the php file that gives the list of links as a response:
    <?php
        if($_GET['giveLinks'] == "yes"){
            echo '<ul data-role="listview" data-inset="true" data-theme="d">';
                echo "<li><a href='http://www.google.fi' rel='external'>Google</a></li>";
                echo "<li><a href='http://www.yahoo.fi' rel='external'>Yahoo</a></li>";
            echo '</ul>';
        }
    ?>

    and the functions that put response to div#job_list.
    function theme(response){
            $('#job_list').html(response);
            $('#main').trigger("create");
    }

    function notheme(response){
            $('#job_list').html(response);
    }

    This solution is not big secret and it can be found from stackoverflow also. I just explained and simplified the procedure a little. 
    Why? If you haven't encountered this problem yet and you are building JQM based apps you are about to struggle with this problem.

    Here's the working example of.trigger("create").








    2

    Katso kommentit


  9. This is a tutorial how to make a hitbox with javascript. This code can be used to detect if objects in canvas were hitted. My way is using arrays to store the objects properties.
    First understand that object is a block that starts and ends somewhere in canvas in both x- and y-axel.

    This shows what data is needs to be stored

    Let's define arrays for objects x- and y-axels start and end points. Let's also define array that defines what was hitted.
    var hit_areaxs = new Array(),hit_areaxe = new Array(), hit_areays = new Array(),hit_areaye = new Array(),hit_what = new Array();

    Next we put "Cow" to array.
    hit_what[0] = "Cow"; //defines hitboxes name
    hit_areaxs[0] = cow_x; //defines startpoint
    hit_areaxe[0] = cow_x + cow_size; //defines endpoint
    hit_areays[0] = cow_y; //defines startpoint
    hit_areaye[0] = cow_y + cow_size; //defines endpoint


    After that create a function that detects if mouse hit the hitbox.
    Function needs two more arrays.
    var x_hit= new Array(),y_hit=new Array();
    These arrays store the name of the object that was hit.

    Hit test happens in for loop:
    for(var i = 0; i < hit_areaxs.length; i++) { //loop can use any hit_areas x or y start or end point
    x_hit[i]="x"; // define something to x_hit and y_hit arrays to ensure that
    y_hit[i]="y"; // x_hit and y_hit have diffirent values

    if(hit_areaxs[i] < mouseX && hit_areaxe[i] > mouseX){ //check if any object in x-axel were hitted
    x_hit[i] = hit_what[i]; //store the hitted objects name
    }
    if(hit_areays[i] < mouseY && hit_areaye[i] > mouseY){ //check if any object in y-axel were hitted
    y_hit[i] = hit_what[i]; //store the hitted objects name
    }

    if(x_hit[i] == y_hit[i]){ //if x and y hit values are the same print hitted objects name in console.log
    console.log("You hitted: " + hit_what[i]);
    }
    }


    This shows what click does



    0

    Lisää kommentti

  10. You may have struggled with JQuery .animate and CSS3 shadow. Shadow can be applied for text and boxes like divs. Because .animate() can’t (or at least I haven’t got it working) animate box-shadow animation, I’ll show you a way to do it another way.
    Instead of using .animate() I use .css(). Function .css() itself doesn’t have the capability of animating things. CSS3 has this capability. It’s called transition. Transition can be applied to text- and box-shadow. First you need to tell where you want to apply transition effect (in example it’s: all) then how long transition lasts (0.5s) and last the type of timing (ease-in-out).
    Here’s how to make box glow when you put your mouse over:


    <body>

    <div class="apply_to_this">
    This is div
    </div>

    <script>
    $('.apply_to_this').mouseover(function(){
    $('.apply_to_this').css({
    'box-shadow':'0px 1px 5px 2px white,0px 0px 2px black inset',
    '-moz-transition': 'all 0.5s ease-in-out',
    '-webkit-transition': 'all 0.5s ease-in-out',
    '-o-transition': 'all 0.5s ease-in-out',
    'transition': 'all 0.5s ease-in-out'
    });
    });
    $('.apply_to_this').mouseout(function(){
    $('.apply_to_this').css({
    'box-shadow':'0px 1px 5px black,0px 0px 2px black inset',
    '-moz-transition': 'all 0.5s ease-in-out',
    '-webkit-transition': 'all 0.5s ease-in-out',
    '-o-transition': 'all 0.5s ease-in-out',
    'transition': 'all 0.5s ease-in-out'
    });
    });
    </script>
    </body>

    Notice that you can do the same with css by using :hover.

    Working example goo.gl/9kI8z
    1

    Katso kommentit

Top posts on this blog
Top posts on this blog
About me
About me
Peter Virtanen Web developer at Staart Oy Founder of GetSOME
Ladataan
© Peter Virtanen. Teema: Dynaamiset näkymät. Sisällön tarjoaa Blogger. Ilmoita väärinkäytöstä.