Posts

Showing posts from August, 2000

Convert DateTime To String PHP

Answer : You can use the format method of the DateTime class: $date = new DateTime('2000-01-01'); $result = $date->format('Y-m-d H:i:s'); If format fails for some reason, it will return FALSE . In some applications, it might make sense to handle the failing case: if ($result) { echo $result; } else { // format failed echo "Unknown Time"; } The simplest way I found is: $date = new DateTime(); //this returns the current date time $result = $date->format('Y-m-d-H-i-s'); echo $result . "<br>"; $krr = explode('-', $result); $result = implode("", $krr); echo $result; I hope it helps. echo date_format($date,"Y/m/d H:i:s");

'cout' Was Not Declared In This Scope

Answer : Put the following code before int main() : using namespace std; And you will be able to use cout . For example: #include<iostream> using namespace std; int main(){ char t = 'f'; char *t1; char **t2; cout<<t; return 0; } Now take a moment and read up on what cout is and what is going on here: http://www.cplusplus.com/reference/iostream/cout/ Further, while its quick to do and it works, this is not exactly a good advice to simply add using namespace std; at the top of your code. For detailed correct approach, please read the answers to this related SO question. Use std::cout , since cout is defined within the std namespace. Alternatively, add a using std::cout; directive.

[range] Unity Code Example

Example: how to set a range for public int or float unity using UnityEngine ; public class Example : MonoBehaviour { // This integer will be shown as a slider, // with the range of 1 to 6 in the Inspector [ Range ( 1 , 6 ) ] public int integerRange ; // This float will be shown as a slider, // with the range of 0.2f to 0.8f in the Inspector [ Range ( 0.2f , 0.8f ) ] public float floatRange ; }

How To Add A New Empty Gameobject As A Child In Unity Code Example

Example: unity create empty gameobject in code objToSpawn = new GameObject ( "Cool GameObject made from Code" ) ;

C Programming Rand Function Code Example

Example: random number generator c rand ( ) % ( maxlimit + 1 - minlimit ) + minlimit ;

"Cannot Connect To ITunes Store" In-app Purchases

Image
Answer : Make sure you have signed out of any production iTunes accounts on the device. I was getting this error on my test phone which was logged in with my actual iTunes account. You cannot test apps using your production iTunes account, hence the error. I just wish Apple provided a better error so as to avoid this guesswork... see In-App Purchase FAQ: Cannot connect to iTunes Store Your app is running in the Simulator, which does not support In-App Purchase For testing in app purchases always use real devices. For newcomers, make sure your in-app purchasing product's status is Ready to Submit , with no "missing metadata". In my case, what was missing was the localization of the subscription's group.

Math.floor Cpp Code Example

Example: floor() in c++ floor ( x ) : This function in C ++ returns the smallest possible integer value which is smaller than or equal to the given argument . Input : 2.5 , - 2.1 , 2.9 Output : 2 , - 3 , 2

Brew Install Aws Cli Code Example

Example 1: brew update aws cli brew install awscli Example 2: aws cli install # AWS CLI V2 # Installing on linux # depends on glibc, groff, and less curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install Example 3: aws terminal in mac curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" unzip awscli-bundle.zip sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Cannot Open Source File "iostream.h"C/C++ Code Example

Example: cannot open source file "iostream" //include paths gcc -v -E -x c++ -

C# MongoDB Distinct Query Syntax

Answer : You could try the following approach: var filter = new BsonDocument(); var categoriesList = await blogContext.Articles.DistinctAsync<string>("categories", filter);

6 Factorial Is Code Example

Example 1: factorial of 8 function getFactorial($int) { $factorial = 1; for ($i = $int; $i > 1; $i--) { $factorial *= $i; } echo "The factorial of " . $int . " is " . $factorial . ' < br > '; } Example 2: Factorial Number // METHOD ONE const factorialNumber = num => { let factorials = [] for(let i = 1; i <= num; i++) factorials.push(i) return factorials.reduce((acc , curr) => acc * curr, 1) } // METHOD TWO const factorialNumber = num => { let factorial = 1, i = 1 while(i <= num){ factorial *= i; i++ } return factorial } // METHOD THREE function factorialNumber(num) { if(num < 1) return 1 else return factorialNumber(num - 1) * num }

Can't Debug Current Typescript File In VS Code Because Corresponding JavaScript Cannot Be Found

Answer : The problem may be with your map files and not with configuration. Before trying anything else you want to make sure your paths that you are using in your launch configuration are correct. You can do so by substituting the paths with absolute paths on your system temporarily to see if it works. If it does not work you should: Check your tsconfig and make sure mapRoot under compilerOptions is not set to anything. This is what official documentation has to say about it: Specifies the location where debugger should locate map files instead of generated locations. Use this flag if the .map files will be located at run-time in a different location than the .js files. The location specified will be embedded in the sourceMap to direct the debugger where the map files will be located. You can read more about it here In most of the cases, you don't really want to set it to anything. Also, make sure that "sourceMap" : true` is set in co

Android: Set View Style Programmatically

Answer : Technically you can apply styles programmatically, with custom views anyway: private MyRelativeLayout extends RelativeLayout { public MyRelativeLayout(Context context) { super(context, null, R.style.LightStyle); } } The one argument constructor is the one used when you instantiate views programmatically. So chain this constructor to the super that takes a style parameter. RelativeLayout someLayout = new MyRelativeLayout(new ContextThemeWrapper(this,R.style.RadioButton)); Or as @Dori pointed out simply: RelativeLayout someLayout = new RelativeLayout(new ContextThemeWrapper(activity,R.style.LightStyle)); Now in Kotlin: class MyRelativeLayout @JvmOverloads constructor( context: Context, attributeSet: AttributeSet? = null, defStyleAttr: Int = R.style.LightStyle, ) : RelativeLayout(context, attributeSet, defStyleAttr) or val rl = RelativeLayout(ContextThemeWrapper(activity, R.style.LightStyle)) What worked for me: Button b = new Button(new

How To Apply Css Only Safari Browser Code Example

Example 1: Safari only CSS hack @media not all and ( min-resolution : .001 dpcm ) { @supports ( -webkit-appearance : none ) { ... } } Example 2: css for safari only @media not all and ( min-resolution : .001 dpcm ) @supports ( -webkit-appearance : none ) Example 3: css especifico para safari /* Safari 7.1+ */ _ ::-webkit-full-page-media , _ :future , :root .safari_only { color : #0000FF ; background-color : #CCCCCC ; }

Custom Cursor Image Html Code Example

Example 1: cursor as image css You can use own image or emoji as cursor <style > a { cursor : url ( "custom.gif" ) , url ( "custom.cur" ) , default ; } </style> <p>Place your mouse pointer <a href= "#" >over me</a> to reveal the custom cursor.</p> Example 2: css change cursor to image .module { cursor : url ( 'path-to-image.png' ) , auto ; }