Posts

Showing posts from June, 2021

Homemade Perlin Noise Unity Code Example

Example 1: perlin noise unity // HOW TO IMPLEMENT A PERLIN NOISE FONCTION TO GET A TERRAIN HEIGHT IN UNITY using UnityEngine ; public static class NoiseCreator { /// scale : The scale of the "perlin noise" view /// heightMultiplier : The maximum height of the terrain /// octaves : Number of iterations (the more there is, the more detailed the terrain will be) /// persistance : The higher it is, the rougher the terrain will be (this value should be between 0 and 1 excluded) /// lacunarity : The higher it is, the more "feature" the terrain will have (should be strictly positive) public static float GetNoiseAt ( int x , int z , float scale , float heightMultiplier , int octaves , float persistance , float lacunarity ) { float PerlinValue = 0f ; float amplitude = 1f ; float frequency = 1f ; for ( int i = 0 ; i < octaves ; i ++ ) { // Get the perlin value at that octave and add it

Create Qr Code Png Image Of 200*200 Using Phpqrcode Code Example

Example: create qr code png image of 200*200 using phpqrcode QRlib . php also does support SVG , doesn 't it? https://github.com/t0k4rt/phpqrcode require_once(__DIR__.' / phpqrcode - master / qrlib . php '); echo QRcode::svg(' hello' ) ;

Android Studio 3.1.1 CreateProcess Error=206, The Filename Or Extension Is Too Long

Answer : I guess you are the windows user, there is a file path limit of 8191 in Windows XP and above. http://support.microsoft.com/kb/830473/en-us The simplest way this shorten the file path, like change the project folder into D:\, and refact your project path, and always use ASCII chars for the folder name. UTF-8 chars use 2-3 bytes. or move useless dependency. or change to MAC platform. ;) The reason is at the compile step, there is a command like javac xxxx, combine all dependences's path in one line. For me this worked. Go to Build -> Clean. File -> Invalidate Cache and Restart Or It might be due to network issue. Please check connectivity.

Transition Rotate3d Css Code Example

Example: css rotate animation <img class="image" src="http://i .stack .imgur .com /pC1Tv .jpg " alt="" width="120" height="120" > .image { position : absolute ; top : 50 % ; left : 50 % ; width : 120 px ; height : 120 px ; margin : -60 px 0 0 -60 px ; -webkit-animation : spin 4 s linear infinite ; -moz-animation : spin 4 s linear infinite ; animation : spin 4 s linear infinite ; } @-moz-keyframes spin { 100% { -moz-transform : rotate ( 360 deg ) ; } } @-webkit-keyframes spin { 100% { -webkit-transform : rotate ( 360 deg ) ; } } @keyframes spin { 100% { -webkit-transform : rotate ( 360 deg ) ; transform : rotate ( 360 deg ) ; } }

Convert Date Format Hours Php Code Example

Example 1: php change date format To convert the date-time format PHP provides strtotime() and date() function. We change the date format from one format to another. Change YYYY-MM-DD to DD-MM-YYYY <? php . $currDate = "2020-04-18" ; $changeDate = date ( "d-m-Y" , strtotime ( $currDate ) ) ; echo "Changed date format is: " . $changeDate . " (MM-DD-YYYY)" ; ?> Example 2: change date format php $currDate = "2020-08-25" ; $changeDate = date ( "d-m-Y" , strtotime ( $currDate ) ) ; echo $changedDate ;

Enumerator In Unity Code Example

Example 1: unity enum using UnityEngine ; using System . Collections ; public class EnumScript : MonoBehaviour { enum Direction { North , East , South , West } ; void Start ( ) { Direction myDirection ; myDirection = Direction . North ; } Direction ReverseDirection ( Direction dir ) { if ( dir == Direction . North ) dir = Direction . South ; else if ( dir == Direction . South ) dir = Direction . North ; else if ( dir == Direction . East ) dir = Direction . West ; else if ( dir == Direction . West ) dir = Direction . East ; return dir ; } } Example 2: unity enum private enum State { Idle , Walk , Attack , }

Cannot Ignore .idea/workspace.xml - Keeps Popping Up

Answer : I was facing the same issue, and it drove me up the wall. The issue ended up to be that the .idea folder was ALREADY commited into the repo previously, and so they were being tracked by git regardless of whether you ignored them or not. I would recommend the following, after closing RubyMine/IntelliJ or whatever IDE you are using: mv .idea ../.idea_backup rm .idea # in case you forgot to close your IDE git rm -r .idea git commit -m "Remove .idea from repo" mv ../.idea_backup .idea After than make sure to ignore .idea in your .gitignore Although it is sufficient to ignore it in the repository's .gitignore, I would suggest that you ignore your IDE's dotfiles globally. Otherwise you will have to add it to every .gitgnore for every project you work on. Also, if you collaborate with other people, then its best practice not to pollute the project's .gitignore with private configuation that are not specific to the source-code of the project. I had t

Can't Uninstall/reinstall NuGet Package

Answer : In your Solution or Project you will find a file called packages.config . Open this file and you will see all the packages that NuGet has installed. The file will look something like this: <?xml version="1.0" encoding="utf-8"?> <packages> <package id="Json" version="2.0.3" targetFramework="net45" /> </packages> Simply delete the line of your package and save the file. <?xml version="1.0" encoding="utf-8"?> <packages> </packages> Then run NuGet again and it should install. The JSON.NET NuGet package should just work with a Windows Phone 8.0 project. Adding it in VS2012 NuGet manager pulls in the WP7 version of JSON.NET. (packages\Newtonsoft.Json.4.5.10\lib\sl3-wp\Newtonsoft.Json.dll) JSON.NET is now also available as a Portable Class Library which you can consume from WP8 (available in NuGet or in source form). UPDATE: The latest version of N

AltGr Randomly Stops Working On Windows 10

Answer : The issue happens when you open a RDP connection. Just bring the RDP window in foreground and press Alt + Enter . The issue will disappear on all other windows too Source: How to Fix Alt Gr Key Not Working. In my case left Shift + Caps Lock + AltGr helped. I have no idea what it does, but it works. Some utility programs can also "steal" the keyboard stroks. In my case it appeared that the VirtualDesktopManager resulted in non-functional AltGr, so I could not write [ and ] .

Can I Check Playtime On PS4 Without PS Plus?

Answer : No There Is no official way for a user to check their playtime statistics. And as for checking RDR2 playtime exclusively Rockstar didnt include the ability to check it unlike their former games (you could check a lot of your in-game stats on their website for GTA-V etc. ). You can enable an email from playstation that will send you your total playtime for the year but you can't check this whenever you want. Sources: 1 2 3 Yes , you can check all stats including playtime on rockstar's social club website. Just login with your platform account.

What Is Class In Oops Code Example

Example: class in oops // DEFINITION /* In object-oriented programming, a class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods). */

Cron Fivem Download Code Example

Example: fivem cron -- Execute task 5:10, every day function CronTask(d, h, m) print('Task done') end TriggerEvent('cron:runAt', 5, 10, CronTask) -- Execute task every monday at 18:30 function CronTask(d, h, m) if d == 1 then print('Task done') end end TriggerEvent('cron:runAt', 18, 30, CronTask)

Ubuntu 18 Install Nvm Code Example

Example 1: install node js ubuntu sudo apt - get install curl curl - sL https : //deb.nodesource.com/setup_13.x | sudo -E bash - sudo apt - get install nodejs # Check node version node - v # v 13.9 .0 # Also , check the npm version npm - v # 6.13 .7 Example 2: install nvm ubuntu curl - o - https : //raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash export NVM_DIR = "$([ -z " $ { XDG_CONFIG_HOME - } " ] && printf %s " $ { HOME } / . nvm " || printf %s " $ { XDG_CONFIG_HOME } / nvm ")" [ - s "$NVM_DIR/nvm.sh" ] && \ . "$NVM_DIR/nvm.sh" # This loads nvm . Now you can use nvm Example 3: ubuntu 18 install nodejs cd ~ curl - sL https : //deb.nodesource.com/setup_12.x -o nodesource_setup.sh sudo bash nodesource_setup . sh sudo apt install nodejs nodejs - v # shows your version

Add A PDF Viewer To A WPF Application

Answer : As already suggested by @NawedNabiZada, one tried and straightforward way is to use embedded InternetExplorer to show Adobe PDF Reader ActiveX control. So it assumes you are running on Windows and have Adobe PDF Reader installed. Then you create a user control, window etc. that contains following control: <WebBrowser x:Name="pdfWebViewer"></WebBrowser> In the constructor navigate to blank page: pdfWebViewer.Navigate(new Uri("about:blank")); To load a PDF document to that control use this simple code: pdfWebViewer.Navigate(fullPathToPDF); This approach is used by many Windows software not only WPF apps including SAP client, but has a hidden problem, see this question. The Adobe PDF Reader Addon in Internet Explorer must be enabled for this to work. There are various problems with Acrobat Reader XI, better to use DC version. To enable Adobe PDF go to IE settings, add-ons and find Adobe PDF Reader and enable it (AR XI and above

Error: Expected Declaration Or Statement At End Of Input } In C Code Example

Example: error: expected declaration or statement at end of input /*Normally that error occurs when a } was missed somewhere in the code*/

All Ascii Characters Copy Paste Code Example

Example: every ascii character copy var s = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';

Composer Phar Download Code Example

Example 1: install composer phar php - r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php - r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer - setup . php php - r "unlink('composer-setup.php');" Example 2: install composer php - r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php - r "if (hash_file('sha384', 'composer-setup.php') === '795f976fe0ebd8b75f26a6dd68f78fd3453ce79f32ecb33e7fd087d39bfeb978342fb73ac986cd4f54edd0dc902601dc') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;

Check Right Mouse Button Click Unity Code Example

Example 1: how to detect a mouse click in unity using UnityEngine ; using System . Collections ; if ( Input . GetMouseButtonDown ( 0 ) ) { //Left Mouse Button } else if ( Input . GetMouseButtonDown ( 1 ) ) { //Right Mouse Button } if ( Input . GetMouseButtonDown ( 2 ) ) { //Middle Mouse Button } Example 2: unity left mouse button //Key Code in the Input Project Settings is "mouse 0" Input . GetKey ( KeyCode . Mouse0 ) )

Cursor Size Css Code Example

Example: css cursor size cursor : url ( one.svg ) , url ( two.svg ) 5 5 , progress ;

Vim Go To Last Line Code Example

Example 1: how to go to top of file in vim Type "gg" in command mode . This brings the cursor to the first line NOTE : in linux terminal , open a file with vim like below . vim file . c In command mode ( press Esc if you are not sure ) you can use . type "gg" , then cursor will point to the first line first character in file . c file Example 2: vim move to the last line you edited # Basic syntax : ` . Example 3: vijm jump to end of file Move cursor to end of file in vim In short press the Esc key and then press Shift + G to move cursor to end of file in vi or vim text editor under Linux and Unix - like systems

Media Query Breakpoints 2021 Example Syntax

Example: media query breakpoints // Best Practice suggests // keep default style for smallest screen size ( portrait mobile , below 576 px ) // and then proceed in assending order with media query like below // Small devices ( landscape phones , 576 px and above till next break point ) @media ( min-width : 576 px ) { ... } // Medium devices ( tablets , 768 px and above till next break point ) @media ( min-width : 768 px ) { ... } // Large devices ( desktops , 992 px and above till next break point ) @media ( min-width : 992 px ) { ... } // so on ...

Ag Grid Showing No Row To Show When Data Is Loading Code Example

Example 1: ag grid showing no row to show when data is loading this.gridOptions.suppressNoRowsOverlay = true; this.service.getData() .subscribe(data => { if (!data || !data.length) { this.gridOptions.suppressNoRowsOverlay = false; this.gridOptions.api.showNoRowsOverlay(); } Example 2: ag grid showing no row to show < ag-grid-angular class = " ag-theme-balham " [columnDefs] = " columnDefs " [defaultColDef] = " defaultColDef " [rowData] = " rowData " (gridReady) = " onGridReady($event) " [overlayLoadingTemplate] = " loadingTemplate " [overlayNoRowsTemplate] = " noRowsTemplate " . . > </ ag-grid-angular > export class AppComponent { private noRowsTemplate; private loadingTemplate; constructor() { this.loadingTemplate = ` < span class = " ag-overlay-loading-center " > data is loading... </ span >

How To Add Component In Unity C# Code Example

Example 1: Add component object to gameobject unity //to add a new ridgidbody gameobject . AddComponent < Rigidbody > ( ) ; //to add a new meshCollider gameobject . AddComponent < MeshCollider > ( ) ; //Original answer by MakerBenjammin6, cleanup by me. Example 2: unity add component //Use the AddComponent<T>() Method to add a component to your gameobject GameObject gameObject ; gameObject . AddComponent < BoxCollider > ( ) ; //Component has to be an actual Unity component

Sass Multiple Classes Selector Code Example

Example: scss multiple classes .container { background : red ; & .desc { background : blue ; } } /* compiles to: */ .container { background : red ; } .container .desc { background : blue ; }

Angular 5 Material: Dropdown (select) Required Validation Is Not Working

Answer : Based on the excellent answer of (from zero to hero), I want to clarify 2 points mentioned in comments: 1- You have to use ngModel not value 2- You have to give the control a name Full credit goes to him, I wanted to clarify this to any newcomer like me as it took me 2 hours to find out why it doesn't work You added required to the select's option , not the select . Do it like: <mat-form-field> <mat-select placeholder="Favorite food" name="select" [(ngModel)]="select" required> <mat-option *ngFor="let food of foods" [value]="food.value" > {{ food.viewValue }} </mat-option> </mat-select> </mat-form-field> DEMO