Posts

Showing posts from July, 2005

Convert Timestamp To Date In Laravel?

Answer : timestamp columns like created_at are being parsed first. the U is simply the timestamp format. you can return your own format. for other formats see date docs. edit: as stated in my comment, getDateFormat() is for both ways (insert, selects). your best bet would be using format inside the model. example: public function getMyBirthdayAttribute() { return $this->my_birthday->format('d.m.Y'); } use $model->my_birthday to call the attribute. // controller $posts = Post::all(); // within sometemplate.blade.php @foreach($posts as $post) my formatted date: {{ $post->my_birthday }} @endforeach The better way to manage dates with Laravel IMHO is to use the getDates accessor that is build into Laravel. All you need to do is to set a method on your Model as such. public function getDates() { return [ 'my_birthday', 'created_at', 'updated_at', ]; } This will return a Carbon object. Carbon is insa

A Certificate Chain Could Not Be Built To A Trusted Root Authority

Image
Answer : I also met the same issue in Win 7 sp1. The solution is below: Download the certificate file from Microsoft: MicrosoftRootCertificateAuthority2011.cer If the link invalid someday, you can download from MicrosoftRootCertificateAuthority2011.cer - github. Double click the .cer file downloaded just now, then install the certificate following below captures: Re-install your .NET Framework 4.6.2 installation package. Then the problem will be resolved. May it be helpful for you. I recently ran into this issue with systems behind a firewall that didn't have internet access. I ran /extract on the .NET Framework 4.6.2 MSI and was able to run the x64 installer directly without the certificate check. Maybe not the "right" way to go, but it worked. could it create problem to install the same certificate on several systems? No, it will not be a problem even if the systems would be connected to the internet in the future. When you connect the s

Android YouTubePlayer With Unauthorized Overlay On Top Of Player

Answer : I faced the same problem today, and for me the error in the logs was: W/YouTubeAndroidPlayerAPI﹕ YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor com.google.android.youtube.player.YouTubePlayerView{42686bc8 V.E..... ........ 0,0-1200,675 #7f0a00a0 app:id/video_player}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: -10, top: -10, right: -10, bottom: -10 (these should all be positive). I fixed this by removing the padding in the YouTubePlayerView in the layout. So my layout looks like this: <com.google.android.youtube.player.YouTubePlayerView android:id="@+id/video_player" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#000" /> I had the same error. Although I did the XML changes, I continued to receive the error: YouTube video p

Android Sdk Path Not Specified Code Example

Example: android studio please provide the path to the android sdk After the installation, immediately close Android Studio,then start it as administrator. A message might popup asking for the sdk manager location. Ignore it (Close the popup). Go to Tools > SDK Manager and click on the edit button on the right of Android SDK Location. Then click Next, next and you're good to go. Android Studio will let you install the sdk manager.

Dotnet Core GlobalHost Code Example

Example: globalhost in .net core public class Program { public static void Main ( string [ ] args ) { var host = CreateHostBuilder ( args ) . Build ( ) ; var hubContext = host . Services . GetService ( typeof ( IHubContext < ChatHub > ) ) ; host . Run ( ) ; } public static IHostBuilder CreateHostBuilder ( string [ ] args ) => Host . CreateDefaultBuilder ( args ) . ConfigureWebHostDefaults ( webBuilder => { webBuilder . UseStartup < Startup > ( ) ; } ) ; }

Check If Variable Is Empty Bash Code Example

Example 1: bash if null or empty if [ - z "$variable" ] ; then echo "$variable is null" ; else echo "$variable is not null" ; fi Example 2: bash if variable is not empty VAR = `echo Hello world` if [ [ - n "$VAR" ] ] ; then echo "Variable is set" ; fi Example 3: bash check if variable is empty if [ - z "$var" ] # return true if $ var is unset

Button Onclick In Angular Code Example

Example: onclick event in angular ( click ) = "myClickFunction($event)"

Android Material Design Library Dependency Code Example

Example 1: android material design gradle dependency implementation 'com.google.android.material:material:1.1.0' Example 2: material design android dependency androidx dependencies { // ... implementation 'com.google.android.material:material: < version > ' // ... }

CROSS JOIN Vs INNER JOIN In SQL

Image
Answer : Here is the best example of Cross Join and Inner Join. Consider the following tables TABLE : Teacher x------------------------x | TchrId | TeacherName | x----------|-------------x | T1 | Mary | | T2 | Jim | x------------------------x TABLE : Student x--------------------------------------x | StudId | TchrId | StudentName | x----------|-------------|-------------x | S1 | T1 | Vineeth | | S2 | T1 | Unni | x--------------------------------------x 1. INNER JOIN Inner join selects the rows that satisfies both the table . Consider we need to find the teachers who are class teachers and their corresponding students. In that condition, we need to apply JOIN or INNER JOIN and will Query SELECT T.TchrId,T.TeacherName,S.StudentName FROM #Teacher T INNER JOIN #Student S ON T.TchrId = S.TchrId SQL FIDDLE Result x--------------------------------------x | TchrId | TeacherName | StudentName | x----

Examples Of Runtime Errors In C++

Example: runtime error in c++ Runtime errors indicate bugs in the program or problems that the designers had anticipated but could do nothing about .

Android Studio 3.0 Unsigned Apk Not Installing

Image
Answer : Looks like we can not directly use the apk after running on the device from the build->output->apk folder. After upgrading to android studio 3.0 you need to go to Build -> Build Apk(s) then copy the apk from build -> output -> apk -> debug Like this - Fist Click On Build Icon on android studio after that click Build APK(s) then Generate APK the copy Apk. It is working perfact.

150 Pound In Kg Code Example

Example: 150 pound in kg let pound = 1; let kilogram = 0.453592;

Consistent Way To Define Document Title, Subtitle, Author, Affiliation, Abstract Etc

Answer : There are really two questions here: how to define the interface and how to implement it. I'll only tackle the former, because the implementation would require several hours' work. First you have to decide whether using non standard commands, say \Title and \Author instead of \title and \author . There are many classes around and different realizations. For instance, the standard classes ( article , report and book ) allow for only one \author command, others want that different authors go in distinct \author commands ( amsart does this). I'll assume you go with \title and multiple \author commands for maximum flexibility. The best approach is, in my opinion, using a key-value syntax. A document always has a title, and sometimes a short title for the header or a subtitle. I would do it like \title[ subtitle=A subtitle, short-title=A short title ]{The very long title of this document} rather than providing a bunch of commands such as \subtitle and

Convert Sql Result To List Python

Answer : If you have an iterable in Python, to make a list, one can simply call the list() built-in: list(cursor.fetchall()) Note that an iterable is often just as useful as a list, and potentially more efficient as it can be lazy. Your original code fails as it doesn't make too much sense. You loop over the rows and enumerate them, so you get (0, first_row), (1, second_row) , etc... - this means you are building up a list of the nth item of each nth row, which isn't what you wanted at all. This code shows some problems - firstly, list() without any arguments is generally better replaced with an empty list literal ( [] ), as it's easier to read. Next, you are trying to loop by index, this is a bad idea in Python. Loop over values, themselves, not indices you then use to get values. Also note that when you do need to build a list of values like this, a list comprehension is the best way to do it, rather than creating a list, then appending to it. cursor = connnect_db()

Css Gradient Background Button

Answer : Well, they used this in default state: background: #0079FF; background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0096FF), to(#005DFF)); background: -webkit-linear-gradient(0% 0%, 0% 100%, from(#0096FF), to(#005DFF)); background: -moz-linear-gradient(center top, #0096FF, #005DFF); For hover they have other colors of course. Just change the color for your needs.

2b2t Free Priority Queue Code Example

Example: 2b2t go code a hack client dumbass

Android : How To Set MediaPlayer Volume Programmatically?

Answer : Using AudioManager , you can simply control the volume of media players. AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 20, 0); also from MediaPlayer (But I didn't try that) setVolume(float leftVolume, float rightVolume) Since: API Level 1 Sets the volume on this player. This API is recommended for balancing the output of audio streams within an application. Unless you are writing an application to control user settings, this API should be used in preference to setStreamVolume(int, int, int) which sets the volume of ALL streams of a particular type. Note that the passed volume values are raw scalars. UI controls should be scaled logarithmically. Parameters leftVolume left volume scalar rightVolume right volume scalar Hope this help audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); For Volume UP audi

Create A Landscape Page In A Portrait Document Latex Code Example

Example: latex rotate page \usepackage{pdflscape} ... \begin{landscape} … \end{landscape}

Target Id In Html With Css Code Example

Example 1: how to call an id in css <style > #selector { color : red ; } /* # is id selector */ </style> <div id= "selector" > <p>This is an id</p> </div> Example 2: css how to style id /*put a # infront of the id*/ /*<section id="example"></section>*/ #example { margin : auto ; }

59 Prime Number Code Example

Example: first prime numbers #include<bits/stdc++.h> using namespace std ; bool Is_Prime ( long long x ) { if ( x % 2 == 0 ) return false ; for ( int i = 3 ; i * i <= x ; i += 2 ) if ( x % i == 0 ) return false ; return true ; } int main ( ) { // first n prime numbers int n ; cin >> n ; int i = 1 ; while ( n - - ) { while ( !Is_Prime ( + + i ) ) ; cout << i << " " ; } }