Posts

Showing posts from January, 2021

Cron Job Every 5 Seconds Code Example

Example 1: run cron every 15 minutes */15 * * * * Example 2: cron every 2 minutes */2 * * * *

Alternatives To Git Submodules?

Answer : Which is best for you depends on your needs, desires, and workflow. They are in some senses semi-isomorphic, it is just some are a lot easier to use than others for specific tasks. gitslave is useful when you control and develop on the subprojects at more of less the same time as the superproject, and furthermore when you typically want to tag, branch, push, pull, etc all repositories at the same time. gitslave has never been tested on windows that I know of. It requires perl. git-submodule is better when you do not control the subprojects or more specifically wish to fix the subproject at a specific revision even as the subproject changes. git-submodule is a standard part of git and thus would work on windows. git-subtree provides a front-end to git's built-in subtree merge strategy. It is better when you prefer to have a single-repository "unified" git history. Unlike the subtree merge strategy, it is easier to export changes to the different (dire

Clamp Rotation Unity Code Example

Example 1: unity clamp rotation float rotationX = 0 ; float rotationY = 0 ; // you might also have some rotation speed variable void Update ( ) { rotationX += Input . GetAxis ( "Vertical" ) * Time . deltaTime ; rotationX = Mathf . Clamp ( rotationX , minRotationX , maxRotationX ) ; rotationY += Input . GetAxis ( "Horizontal" * Time . deltaTime ; transform . rotation = Quaternion . Euler ( rotationX , rotationY , 0 ) ; } Example 2: how to clamp transform.rotation headRotation = Input . GetAxis ( "Mouse Y" ) * speed ; transform . Rotate ( 0 , 0 , - headRotation , Space . Self ) ; transform . eulerAngles . y = Mathf . Clamp ( transform . eulerAngles . y , - 90 , 90 ) ; Example 3: how to chagne rotation in unity transform . eulerAngles = new Vector3 ( 0f , 180f , 0f ) ; // rotates 180 degrees

Convert Decimal To Binary C Code Example

Example 1: binary to decimal in c #include #include int convert(long long n); int main() { long long n; printf("Enter a binary number: "); scanf("%lld", &n); printf("%lld in binary = %d in decimal", n, convert(n)); return 0; } int convert(long long n) { int dec = 0, i = 0, rem; while (n != 0) { rem = n % 10; n /= 10; dec += rem * pow(2, i); ++i; } return dec; } Example 2: c program from decimal to binary #include #include #include #define D 10 int main() { int i, n, k, vet[D]; printf("FROM DECIMALS TO BINARIES\nEnter decimal: "); scanf("%d", &n); k = 0; while (n != 0) { if ((n % 2) == 1) vet[k] = 1; else vet[k] = 0; n /= 2; k++; } printf("Transformed into binary: "); for(i = k - 1; i >= 0; i --) printf("%d", vet[i]); printf("\n\n"); system("pause"); }

Creating A Custom Exception Class And Custom Handler Class In Laravel 5.3

Answer : Laravel calls the render function of App\Exceptions\Handler class. So overriding it will not work. You have to add it in App\Exceptions\Handler class only. For example: <?php namespace App\Exceptions; use Exception; use Illuminate\Auth\AuthenticationException; use App\Project\Frontend\Repo\Vehicle\EloquentVehicle; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; class Handler extends ExceptionHandler { /** * A list of the exception types that should not be reported. * * @var array */ protected $dontReport = [ \Illuminate\Auth\AuthenticationException::class, \Illuminate\Auth\Access\AuthorizationException::class, \Symfony\Component\HttpKernel\Exception\HttpException::class, \Illuminate\Database\Eloquent\ModelNotFoundException::class, \Illuminate\Session\TokenMismatchException::class, \Illuminate\Validation\ValidationException::class, ]; /** * Report or log an except

GetComponent().Play Code Example

Example 1: how to play animation with code in unity public GameObject ExampleNPC ; void Update ( ) { if ( Input . GetButtonDown ( "Animation" ) ) // Make sure to refrence this in Input settings { ExampleNPC . GetComponent < Animator > ( ) . Play ( "Anim name" ) ; } } Example 2: play animation through script unity animator . Play ( "StateName" ) ;

Bootstrap-select Add Item And Select It

Answer : You have a typo. Instead of: $('#myselect').append('<option val="'+newitemnum+'">'+newitemdesc+'</option>'); You need: $('#myselect').append('<option value="'+newitemnum+'">'+newitemdesc+'</option>'); Here is a JSFiddle demo: http://jsfiddle.net/xbr5agqt/ The "Add and select 'Soy Sauce' option" button does the following: $("#myselect").append('<option value="'+newitemnum+'">'+newitemdesc+'</option>'); $("#myselect").val(4); $("#myselect").selectpicker("refresh"); One slightly faster approach (used by the "Add and select 'Relish' option" button) is to append the new <option> element with the selected attribute already applied: $("#myselect").append('<option value="'+newitemnum+'" selected=&

Ag-Grid Header Styles Not Changing With CSS On Component

Answer : Try using ::ng-deep combinator https://angular.io/guide/component-styles#deprecated-deep--and-ng-deep ::ng-deep .ag-theme-balham .ag-header { background-color: #e0e0e0; } If that does not work, put your css in the global stylesheet and check if the styles are overriden correctly Override the header-cell class instead .ag-theme-balham .ag-header-cell{ background-color: #e0e0e0; } and if you have header-group then .ag-theme-balham .ag-header-cell, .ag-theme-balham .ag-header-group-cell{ background-color: #e0e0e0; }

Android: How Does Bitmap Recycle() Work?

Answer : The first bitmap is not garbage collected when you decode the second one. Garbage Collector will do it later whenever it decides. If you want to free memory ASAP you should call recycle() just before decoding the second bitmap. If you want to load really big image you should resample it. Here's an example: Strange out of memory issue while loading an image to a Bitmap object. I think the problem is this: On pre-Honeycomb versions of Android, the actual raw bitmap data is not stored in VM memory but in native memory instead. This native memory is freed when the corresponding java Bitmap object is GC'd. However , when you run out of native memory, the dalvik GC isn't triggered, so it is possible that your app uses very little of the java memory, so the dalvik GC is never invoked, yet it uses tons of native memory for bitmaps which eventually causes an OOM error. At least that's my guess. Thankfully in Honeycomb and later, all bitmap data is stored in

Call Invoke Before Lateupdate And Update Unity Code Example

Example: what function is called just before the a script is ended c# OnDisable(){}