Showing posts with label Selfhelp_Code_Leadership_etc_etc_howlotsofmonney. Show all posts
Showing posts with label Selfhelp_Code_Leadership_etc_etc_howlotsofmonney. Show all posts

Monday, July 19, 2021

Cool face style

 

Try this style for size:

 

<style>
  .ehm:after{
  	content: "😎";
  	display: inline-block;
  	transform: rotate(0deg);
  	font-size: 1900%;
  	opacity: 1;
  	animation-name: ballroll;
  	animation-duration: 6s;
  	animation-delay: -2s;
  	animation-iteration-count: infinite;
  
  }
    @keyframes ballroll{
      0%{ content: "🤩"; transform: rotate(0deg);}
      25%{transform: rotate(3deg);}       
      60%{content: "😎";}
      75%{transform: rotate(-3deg);}
      100% {content: "👍";}
      }
}
</style>
<div>
Try this style for size:

</div>
<p class="ehm" 	></p>

Wednesday, March 24, 2021

How to get AJAX ”get” to work on wp(WordPress) in vanilla js(javascript ) when there is namespace, when press button –jQuery (NO jQuery)

 Huh! This take a lot a time, to figure out so many moving parts.

1. No "data" needed at all, but "action"

First I try figure out what jQuery does, but that was lot of scramble I got nothing. Finally then I figure to look inside admin-ajax.php itself if there is hint's how it works. And there I found what I been looking for.

 


So right url is on form:

...wp-admin/admin-ajax.php?action=testfirst

Where "testfirst" is that what $_GET add in $action from the url.

2.This kind of button and two div's for the AJAX on somewhere in WP Templates

 <div id="demo"></div>
 <div id="demo2"></div>
 <button id="spesial_button" onclick="P_lifg()">I am spesial</button>
 
"P_lifg()" is function that has the ajax get.

3.Next js script file

I name it OWnajaxjs.js

You know like in https://www.w3schools.com/js/js_ajax_intro.asp But few changes.
Pic from w3schools

And that admin-ajax.php page it's "empty" that must fill by specials actions on functions.php
But here now it OWnajaxjs.js file:


var urlToajax=jsajaxe_S.ajaxurl;


 function P_lifg(){ 
 
	 var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
    document.getElementById("demo").innerHTML = this.responseText;
    document.getElementById("demo2").innerHTML = urlToajax+ "?action=testfirst";
    }
  };
	
	
	xmlhttp.open("GET", urlToajax+ "?action=testfirst", true); 	
	xmlhttp.send(0);
	
 }


//file end
That jsajaxe_S.ajaxurl is the actual location of admin-ajax.php this js file get it from php in wp_localize_script at the functions.php.

"demo" div will get AJAX dump and "demo2" get url to location where dump is so one can go there to check it out.


4.functions.php 1. Register, Localize and Enqueue script that is OWnajaxjs.js


So add this in functions.php

5.functions.php 2. wp_ajax_ wp_ajax_nopriv_

add_action( 'wp_ajax_testfirst', __NAMESPACE__ .'\\FunctionTF' );
add_action( 'wp_ajax_nopriv_testfirst', __NAMESPACE__ .'\\FunctionTF');
 Next the pic that explains it all:

6.functions.php 3.action function here FunctionTF

  function FunctionTF(){

  exit( "Hola hola" );

		
	} 
Yes see, it "hola hola" is inside exit(), this take long time to figure out, there was conflicting information in web where to lay code here, but then I figure to again return to a admin-ajax.php file, and from there I get notice, that there are certain inbuild core ajax actions so I figure to go and check how one of them handle AJAXhandle I choose wp_ajax_rest_nonce() function and behold on 


7. If you get everything right



Monday, August 24, 2020

When 1+1 is a three or more

Lately I been the learning C++ on http://www.cplusplus.com/, then I catch me eye a silly news, that some times,
1+1=3 Like family and breeding, I get idea to test my new skills on this subject

#include 
using namespace std;

class Pulsu {
  public:
    int Afterbreed;
    int BreedingRate;
    Pulsu () {};
    Pulsu (int x, int y){Afterbreed=x; BreedingRate=y;}
    Pulsu operator + (const Pulsu&);
};

Pulsu Pulsu::operator+ (const Pulsu& p) {
  Pulsu temp;
  //temp.BreedingRate=(BreedingRate+p.BreedingRate)/2;
 if((BreedingRate+p.BreedingRate)%2==0){
     temp.BreedingRate=int ((BreedingRate+p.BreedingRate)/2);
     
 }else{
     temp.BreedingRate=int ((BreedingRate+p.BreedingRate+1)/2);//I notice these must alter to int or else //error
     //it is not int if like 3/2
 }




  if( (Afterbreed-p.Afterbreed)<=0){
      temp.Afterbreed =(Afterbreed*2)+ (Afterbreed*temp.BreedingRate) -(Afterbreed-p.Afterbreed);
      
      }else{
          temp.Afterbreed =(p.Afterbreed*2)+(Afterbreed*temp.BreedingRate) +(Afterbreed-p.Afterbreed);
          
          }
  
  
  return temp;
}



int main () { 
  Pulsu Ratfemales={22,0};//22 is how many and 0 is breedinrate
  Pulsu Ratmales={15,3};
  Pulsu Ratfamily;
  Ratfamily=Ratmales+Ratfemales;
  cout << Ratfamily.Afterbreed <<'\n' ;
  return 0;
}
According https://www.onlinegdb.com/online_c++_compiler  52 is answer.
Yes! and it was no 1+1 but 22+15 and breeding rate 0 and 3

Wednesday, August 12, 2020

HTML entity maker

First write &# then number in there at the list below and you can then use that HTML entity. Find more entities by changing the numbers.

first

last

Wednesday, May 6, 2020

How end threads in C#

I finally figure out how to; end threads in C#, it is not a CloseHandle(hThrd) neither Abort(). They[threads] end automatically when the control flow reach end of that thread.

Consider flowing code thing, on Visual Studio WinForm project. That has two threads and one main thread:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//Those comes with WinForm this is new. 
using System.Threading;

namespace Test_that_new_Loop_thing
{
    public partial class Form1 : Form
    {
        bool lever = true;//when this is false a while-loop in place 28 stop
        public Form1()
        {
            //then some threads
            Thread thread1 = new Thread(new ThreadStart(Looppi_threadissa1)); // this is thread1 it run function that is inside it.
            Thread thread2 = new Thread(new ThreadStart(for_threadi2)); //these threads are in places 26 and 43
            InitializeComponent();
            thread2.Start();
            thread1.Start();
        }
        public void Looppi_threadissa1() {//26
            try {
                while (lever) //28
                {

                    Thread.Sleep(10);
                }

            }
            catch (Exception)
            {



            }
          
        }
        public void for_threadi2()//43
        {
            try {
                for (int i = 0; i < 1400; i++)
                {

                    Thread.Sleep(10);
                }
                lever = false;//lever turn false so while in pace 28 end.
                MessageBox.Show("Now the both threads end");

            }
            catch (Exception)
            {



            }
          

        }

    }
}

Yes see extra threads end when they end like main thread does too.

Tuesday, April 14, 2020

C# how get Form tick faster?



I try various things, only those who have try a lot, know the context. This now here is the advanced stuff.
  
Why use the ticks in first place, while(true) is always pretty fast. But InitializeCompinent() newer start or end, now matter which side of it, the while(true)-loop is because there is always certain threading and asynchronization.

So I end-up to do  System.Windows.Forms.Timer tick from that, but it was too slow for the thing I plan to do.

Thread, thread was my mind, so I get idea to spend up the ticks by stop the timer on the threads very own function.

(And I need to make mention: async worker not work here at all, it is for internet stuff, I try that at one point. )

myTimerforTest.Interval = 1; //slow :(
myTimerforTest.Tick += new EventHandler(TheLoop);
myTimerforTest.Start();
... much lower on the code sheet.
private void TheLoop(object sender, EventArgs e)
{
myTimerforTest.Stop();/*here start the error and I though first it speed up the process*/
Thread thread = new Thread(new ThreadStart(WhileTrueInsideThisFunction));
thread.Start();

}

Yes don't do that in above, it make error so big it shut down a whole computer, it some how make that it newer get out that Loop function. But it give me idea for the way that seem to work. Here it is.

//So this go in Form()
Thread thread = new Thread(new ThreadStart(Loop));
thread.Priority = ThreadPriority.Lowest;/* even the slowest this work better than the Tick */
InitializeComponent();
thread.Start();
... then much lower at the code sheet after Form(): 
   private void Loop()
        {
            try
            {
                while (true)
                {
                    //Here the code
                    Thread.Sleep(10); /* when while is in sleep, it go making the InitializeComponent()-function. */
                }

            }
            catch (Exception) { 
            
            }
          

        }

Yes, but this "using thread" is now in the uncharted territory meaning if you close the form thread still looping and other cases might occur that you except more automation, but actually you need yourself write commands down.  

Don't take this too seriously, if you know more official best practice way make fast tick on form() then use it. Soon as I figure it out I use it too.

Thursday, March 12, 2020

SUPER APOSTLE FOR GREATER SOFTWARE PRODUCTIVITY AND ROBUSTNESS



Here some killer buzzwords, whichess them behind the big abstract magic to a greatnes ultra speed development.

Here comes the big drops:


Division of labour i.e. the specialization



Let smart person do the smart thing and boring guys make the boring things, also make artist guy make the art.

80 20 rule is the new 90/90 rule.

 Use programming language that works, on the situation that be doing, don’t use wrong things, have overall mental picture what you are doing, do not blindly shot in the dark, but know what you doing; like it is some variant of a finite-state machine (FSM)

Redundancy


It is that have more than needed, the robust when one break there is another. Have lot of workforce.

 Like make two separated groups of people make the same Black box, Have them kinda fight against each other i.e. competition, I mean have; Say! Two to four --three people groups to race which of them teams make the Black box faster and better, the smaller Big O.

The winner team get a big price bonus this make them super nay ultra motivated. To a participate on the challenging competitions.

Don’t have these challenges to be about random poop, but hard critical parts of the thing that is under development.

This all for le smart people; the boring & Artist type they don’t need it, to the art is may be even harmful because it needed to be a coherent; and the boring stuff that not need much resources, but monkeying around.

You know three people teams the mocking programming, one sit the front of a computer do the all the coding, and two guys standing behind him mocking and nagging, because them want win nice prise.
Shuffle mix these teams every now and then, so they see more people and learn better from each other.

Black box thinking on the functions and classes.


There is no means how a code does it, but what it does, like the robust and how fast it do it. No “Keep it simple stupid”(kiss) here, let it be convoluted as it can be, and if it grow too unbearable just make them replace that part wholly to a new part.
the Black box thinking, it mean you dont look it. Just accept, and remember mutations are better and faster than the “return”.

Big turnover rate


Be nice give people a change by hiring them on much, don’t let stupid gatekeeper block business hiring all them relatives and friends, so no hr just hire yourself.
 Check all peoples Resumes and portfolios and check them demons keep mental note about the best ones and hire them then, and bargain thru all salary issues. If there is thousand applications then check all them thousand, you have probably do something more boring and even free.

When you check them applications focus on how big is candidate’s work memory and have he interests on all kinds of wisdom, his mental faculties, it is not so much important about his coding knowledge, but that is good if he just know some language, because he will learn while doing. Also don’t hire expensive titular coders that has long rock star CV they might be just part some work cartel and be much useless relative the expensiveness. Hire rather more those that CV and wallet is empty they got hunger and potential.

Big turnover, you now free Internship trainee etc. It is win-win they got mark at the CV and you a cheap labour.

Don’ t much unit test


That is thing of the past, there on modern IDE like Visual Studio, has a built-in testing thingies like, if you forgot “;” it got red underline, and same if you forgot initialize some variable.

 No unit test! just some checks that functions and code lines, and whatnow do what you expected them to do, make them print on console or try them separated other code that you then see that them works.

Trust legacy code and the makers of code languages and IDE’s and formulas.

Then there is also the market disruption, minimum viable product(mvp).

Remember the thing you do the product if it is cheap enough that is no burden to customer, and if it even barely can hold it’s function customer will use it.


Wednesday, March 11, 2020

Four hack in one


C#

You know, you paint or spray something the Graphics on screen monitor i.e. display. Then want fresh screen that to get rid of it. Here some hacks::

HACK 1&4

Instead: 

[StructLayout(LayoutKind.Sequential)]
public struct RECT
        {

public int Left;
            public int Top;
            public int Right;
            public int Bottom;
        }
add there constructor function so you can the “new” it like this:
RECT rECT= new RECT(100, 100, 100, 100);
Constructor I mean like this:
[StructLayout(LayoutKind.Sequential)] 
public struct RECT
        {

       

            private int Left;
            private int Top;
            private int Right;
            private int Bottom;
         

            public RECT(int left, int top, int right, int bottom) {
            Left=left;
            Top=top;
            Right=right;
            Bottom=bottom;

                }
        }

HACK 2

Instead this way to over load using “IntPtr lpRect
[DllImport("user32.dll")]
        static extern bool InvalidateRect(IntPtr hWnd, IntPtr lpRect, bool bErase);
.... and then later:
InvalidateRect(IntPtr.Zero, IntPtr.Zero, true);

That above it refresh whole screen, use “ref RECT lpRect” instead “IntPtr lpRect” like this:
[DllImport("user32.dll")]
static extern bool InvalidateRect(IntPtr hWnd, ref RECT lpRect, bool bErase);

.... Now! You can fresh certain Rectangular instead it all.
RECT rECT= new RECT(100, 100, 100, 100);
InvalidateRect(IntPtr.Zero, ref rECT, true);

HACK 3

You can use same numbers at Rectangle and RECT this way
new Rectangle(400, 450, 192, 180)
new RECT(400, 450, 192+400, 180+450)
You see other need upper right corner and width and high, and the other just need the bounds.

That [StructLayout(LayoutKind.Sequential)]

means or it not like mean nothing, it is just like, you know cargo cult I mean there no particular reason to add it. It little bit the robustivines.

3D blog is ending

 Later this month, 3D-blog will end. Thanks for all.