Posts

Showing posts from July, 2011

COUNT CASE And WHEN Statement In MySQL

Answer : Use: SELECT SUM(CASE WHEN t.your_column IS NULL THEN 1 ELSE 0 END) AS numNull, SUM(CASE WHEN t.your_column IS NOT NULL THEN 1 ELSE 0 END) AS numNotNull FROM YOUR_TABLE t That will sum up the column NULL & not NULL for the entire table. It's likely you need a GROUP BY clause, depending on needs.

C++ Erase Vector Element By Value Rather Than By Position?

Answer : How about std::remove() instead: #include <algorithm> ... vec.erase(std::remove(vec.begin(), vec.end(), 8), vec.end()); This combination is also known as the erase-remove idiom. You can use std::find to get an iterator to a value: #include <algorithm> std::vector<int>::iterator position = std::find(myVector.begin(), myVector.end(), 8); if (position != myVector.end()) // == myVector.end() means the element was not found myVector.erase(position); You can not do that directly. You need to use std::remove algorithm to move the element to be erased to the end of the vector and then use erase function. Something like: myVector.erase(std::remove(myVector.begin(), myVector.end(), 8), myVec.end()); . See this erasing elements from vector for more details.

Can Someone Explain MappedBy In JPA And Hibernate?

Answer : MappedBy signals hibernate that the key for the relationship is on the other side. This means that although you link 2 tables together, only 1 of those tables has a foreign key constraint to the other one. MappedBy allows you to still link from the table not containing the constraint to the other table. By specifying the @JoinColumn on both models you don't have a two way relationship. You have two one way relationships, and a very confusing mapping of it at that. You're telling both models that they "own" the IDAIRLINE column. Really only one of them actually should! The 'normal' thing is to take the @JoinColumn off of the @OneToMany side entirely, and instead add mappedBy to the @OneToMany . @OneToMany(cascade = CascadeType.ALL, mappedBy="airline") public Set<AirlineFlight> getAirlineFlights() { return airlineFlights; } That tells Hibernate "Go look over on the bean property named 'airline' on the th

Convert A PHP Script Into A Stand-alone Windows Executable

Answer : Peachpie http://www.peachpie.io https://github.com/iolevel/peachpie Peachpie is PHP 7 compiler based on Roslyn by Microsoft and drawing from popular Phalanger. It allows PHP to be executed within the .NET/.NETCore by compiling the PHP code to pure MSIL. Phalanger http://v4.php-compiler.net/ http://wiki.php-compiler.net/Phalanger_Wiki https://github.com/devsense/phalanger Phalanger is a project which was started at Charles University in Prague and was supported by Microsoft. It compiles source code written in the PHP scripting language into CIL (Common Intermediate Language) byte-code. It handles the beginning of a compiling process which is completed by the JIT compiler component of the .NET Framework. It does not address native code generation nor optimization. Its purpose is to compile PHP scripts into .NET assemblies, logical units containing CIL code and meta-data. Bambalam https://github.com/xZero707/Bamcompile/ Bambalam PHP EXE Compiler/Embedder is a free command line

Bootstrap Table Responsive Class Name Code Example

Example: bootstrap table < table class = " table " > < thead > < tr > < th scope = " col " > # </ th > < th scope = " col " > First </ th > < th scope = " col " > Last </ th > < th scope = " col " > Handle </ th > </ tr > </ thead > < tbody > < tr > < th scope = " row " > 1 </ th > < td > Mark </ td > < td > Otto </ td > < td > @mdo </ td > </ tr > < tr > < th scope = " row " > 2 </ th > < td > Jacob </ td > < td > Thornton </ td > < td > @fat </ td > </ tr > < tr > < th scope = " row " > 3 </ th > < td > Larry </ td >

Js Cast Int Code Example

Example 1: how to convert string to int js let string = "1" ; let num = parseInt ( string ) ; //num will equal 1 as a int Example 2: Javascript string to int var myInt = parseInt ( "10.256" ) ; //10 var myFloat = parseFloat ( "10.256" ) ; //10.256 Example 3: string to number javascript // Method - 1 ### parseInt() ### var text = "42px" ; var integer = parseInt ( text , 10 ) ; // returns 42 // Method - 2 ### parseFloat() ### var text = "3.14someRandomStuff" ; var pointNum = parseFloat ( text ) ; // returns 3.14 // Method - 3 ### Number() ### Number ( "123" ) ; // returns 123 Number ( "12.3" ) ; // returns 12.3 Number ( "3.14someRandomStuff" ) ; // returns NaN Number ( "42px" ) ; // returns NaN Example 4: how to change a string to number in javascript let theInt = parseInt ( "5.90123" ) ; //5 let theFloat = parseFloat ( "5.90123" ) ;

CSS Transition Doesn't Work With Top, Bottom, Left, Right

Answer : Try setting a default value in the css (to let it know where you want it to start out) CSS position: relative; transition: all 2s ease 0s; top: 0; /* start out at position 0 */ Perhaps you need to specify a top value in your css rule set, so that it will know what value to animate from . In my case div position was fixed , adding left position was not enough it started working only after adding display block left:0; display:block;

Admob Vs AdSense

Answer : AdMob is used for native applications, so you should use AdMob in this case. AdSense is used for mobile web applications. The amount of revenue in an ad-based model really depends on the amount of users and ad requests. Ads can be a good stream of revenue but you do need the user base for it to take off. According to your last question: Users click ads in mobile apps much more than on websites and it is much easier to make money on mobile platforms. It is quite harder than 1-2 years ago, but you can still get through. If you want to make money on apps Android is a very good choice, but if you would prefer to sell your apps choose iPhone. Simple answer: Adsense : For websites. If you login in adsense website you'll read "Show ads on your own website". Admob : For natives or hybrids apps ("mob" comes from mobile). This would be your case. If you login in Admob's website you'll read "Earn more from your apps the smart way". If

Android Studio - Manually Download System Image For Emulator

Answer : In windows: First locate your android-sdk. By default it's in your C:\Users\Your.name\AppData\Local\ in it's root folder. where you can find: SDK Manager.exe, make a folder name it "system-images", my api 25 image is at system-images\android-25\google_apis\x86_64\Files Hope you can Figure it out. Comment if you have any problem. In mac OSX: ~/Library/Android/sdk/system-images/android-[API_VERSION]/[API_TYPE]/x86 Replace [API_VERSION] with Android version you are downloading and the [API_TYPE] can either be google_apis_playstore or google_apis depending on whether the image you are downloading comes with Google Play or not. On Windows 10: Download the file from e.g.: https://dl.google.com/android/repository/sys-img/google_apis/x86-27_r09.zip. Extract the zipped file. Copy (OR Cut, not recommended) the contents of the extracted folder e.g.: x86 . Find the android-sdk folder. By default, it should be located at C:\Users\[YOUR USER NA

CSS Transforms VS Transitions

Answer : transition and transform are separate CSS properties, but you can supply transform to transition to "animate" a transformation. transition The CSS transition property listens for changes to specified properties (background-color, width, height, etc.) over time. transition Property Syntax: selector { transtion: [property-name] [duration] [timing-function] [delay] } For example, the below styles will change the color of a div's background to orange over a period of 1 second upon hover. div { width: 100px; height: 100px; background-color: yellow; transition: background-color 1s; /* timing function and delay not specified */ } div:hover { background-color: orange; } <div></div> transform The CSS transform property rotates/scales/skews an element over the X,Y, or Z axes. Its behavior does not relate to transition . Simply put, on page load, the element will just appear rotated/skewed/scaled. Now if you wanted the rotating/skewing/

Css3 Animation Generator Code Example

Example: animation generator css <div id= "animated-example" class= "animated zoomIn" ></div>

Std String Format C++ Code Example

Example: format string cpp # include <iostream> # include <format> int main ( ) { std :: cout << std :: format ( "Hello {}!\n" , "world" ) ; }

Can We Have Multiple CNAMES For A Single Name?

Answer : Solution 1: Multiple CNAME records for the same fully-qualified domain name is a violation of the specs for DNS. Some versions of BIND would allow you to do this (some only if you specified the multiple-cnames yes option) and would round-robin load-balance between then but it's not technically legal. There are not supposed to be resource records (RRs) with the same name as a CNAME and, to pick nits, that would include multiple identical CNAMEs. Quoth RFC 1034, Section 3.6.2: If a CNAME RR is present at a node, no other data should be present; this ensures that the data for a canonical name and its aliases cannot be different. This rule also insures that a cached CNAME can be used without checking with an authoritative server for other RR types. The letter-of-the RFC method to handle what you're doing would be with a single CNAME referring to a load-balanced "A" record. Solution 2: You cannot. A CNAME makes one record another name for a

Scrolltop Javascript Code Example

Example 1: jquery get document scrolltop var top = ( $ ( window ) . scrollTop ( ) || $ ( "body" ) . scrollTop ( ) ) ; Example 2: js scrollto element. scrollTo ( x , y ) ; window. scrollTo ( x , y ) ; element .scrollTo ( { top : 100 , left : 100 , behavior : 'smooth' } ) ; Example 3: jquery keep scroll position var scroll = $ ( window ) . scrollTop ( ) ; // yada $ ( "html" ) . scrollTop ( scroll ) ; Example 4: html scroll div to top var myDiv = document. getElementById ( 'containerDiv' ) ; myDiv.innerHTML = variableLongText ; myDiv.scrollTop = 0 ; Example 5: javascript scroll privent // left: 37 , up: 38 , right: 39 , down: 40 , // spacebar: 32 , pageup: 33 , pagedown: 34 , end: 35 , home: 36 var keys = { 37 : 1 , 38 : 1 , 39 : 1 , 40 : 1 } ; function preventDefault ( e ) { e. preventDefault ( ) ; } function preventDefaultForScrollKeys ( e ) { if ( keys [ e .keyCode ] ) { preventDefault ( e ) ; return false

Convert Video To Apng/png?

Answer : This sort of thing has been done before (with gif) using imagemagick. APNG is not an official file format - the PNG group doesn't support this extension. Even if you get this to work, you are likely going to have lingering issues. You should probably consider an animated gif, unless you have some reason you are forced to use png. Checkout the page on Video Handling. Also take a look at Animation Basics and Optimization. I appear to be able to convert avi to apng directly on linux, but it fails on windows. A work around on windows would be to convert the movie to a sequence of stills: convert test.avi frame%04d.png if you want to use ffmpeg, this will extract frames every 5 seconds: ffmpeg -i test.avi -y -ss 5 -an -r 1/5 frame%03d.png then making the animation by using the apng edit firefox plugin. mng never gained much support, but APNG apparently has some support these days (FF/Chrome/Safari); more than WebP (Chrome/Opera). Be sure to check for browser support fo

CSS Set Div 'top' With Jquery From Div 'height'

Answer : You will need to set the css property 'top' on the #footer div, not call .top() on the div itself. $("#footer").css('top', $("#text").height() + "px"); or along those lines Replace .top with .offset({top: somenumber}) http://api.jquery.com/offset/

Can't Start Hostednetwork

Answer : This happen after you disable via Control Panel -> network adapters -> right click button on the virtual connection -> disable To fix that go to Device Manager ( Windows-key + x + m on windows 8, Windows-key + x then m on windows 10), then open the network adapters tree , right click button on Microsoft Hosted Network Virtual Adapter and click on enable. Try now with the command netsh wlan start hostednetwork with admin privileges. It should work. Note: If you don't see the network adapter with name 'Microsoft Hosted Network Virtual Adapter' try on menu -> view -> show hidden devices in the Device Manager window. Let alone enabling the network adapter under Device Manager may not help. The following helped me resolved the issue. I tried Disabling and Enabling the Wifi Adapter (i.e. the actual Wifi device adapter not the virtual adapters) in Control Panel -> Network and Internet -> Network Connections altogether worked

48 Inch To Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

Make Triangle Css Code Example

Example 1: css circle #circle { width : 100 px ; height : 100 px ; background : red ; border-radius : 50 % } Example 2: css triangle .arrow-up { width : 0 ; height : 0 ; border-left : 5 px solid transparent ; border-right : 5 px solid transparent ; border-bottom : 5 px solid black ; } .arrow-down { width : 0 ; height : 0 ; border-left : 20 px solid transparent ; border-right : 20 px solid transparent ; border-top : 20 px solid #f00 ; } .arrow-right { width : 0 ; height : 0 ; border-top : 60 px solid transparent ; border-bottom : 60 px solid transparent ; border-left : 60 px solid green ; } .arrow-left { width : 0 ; height : 0 ; border-top : 10 px solid transparent ; border-bottom : 10 px solid transparent ; border-right : 10 px solid blue ; } Example 3: how to make a triangle in css .triangle { border-left : 5 px solid transparent ; border-right : 5 px

Convert A String To Uppercase In Javascript Code Example

Example 1: uppercase javascript var str = "Hello World!" ; var res = str . toUpperCase ( ) ; //HELLO WORLD! Example 2: javascript uppercase string var str = "Hello World!" ; var res = str . toUpperCase ( ) ;

Apple - Create An APFS RAM Disk

Answer : It works if you create a JHFS+ volume first and convert it to APFS in a second step: DISK_ID=$(hdiutil attach -nomount ram://$((<number_of_blocks>))) diskutil eraseDisk JHFS+ "RAM Disk" $DISK_ID diskutil apfs convert $(tr -d ' '<<<${DISK_ID}s2) If the RAM disk has a size of 2 GiB (4 * 1024 * 1024)(block_size) or smaller no EFI partition is created and the 3rd command is: diskutil apfs convert $(tr -d ' '<<<${DISK_ID}s1) or more generally: DISK_ID=$(hdiutil attach -nomount ram://$((<number_of_blocks>))) SIZE=$(diskutil info $DISK_ID | awk -F'[^0-9]*' '/Disk Size/ {print$4}') diskutil eraseDisk JHFS+ "RAM Disk" $DISK_ID if [ $SIZE -le 2147483648 ]; then diskutil apfs convert $(tr -d ' '<<<${DISK_ID}s1); else diskutil apfs convert $(tr -d ' '<<<${DISK_ID}s2); fi Result: ... /dev/disk2 (disk image): #: TYPE NAME SIZE

Angular5: Need To Prevent NgbTooltip From Rendering Before Data Is Returned From Observable

Answer : Look into using OnInit lifecycle hook which is processed first when a component is loaded. Documentation For ngOnInit Thats simple enough, then move that call to the service as seen below into the life cycle hook. Give the class a public variable ie public toolTipData: string; (moved into OnInit) this.planService.getAuditDetails(planId, fieldName, fieldValue) .subscribe((auditDetail: AuditDetail) => { this.tooTipData = auditDetail.toolTipInfo // (guessing at name) this.auditDetail = auditDetail; this.loadCompleted = true); }, (errors) => { console.log(errors) // api error status code. } }); In the HTML set the tool tip value to [ngbTooltip]="toolTipData" This should help populate the tool tip appropriately. The asynchronous changes aren't showing up because NgbTooltip window uses ChangeDetectionStrategy.OnPush and the only way to trigger change detection is calling open() on a closed tooltip. In order t

Copy Directory Docker File Code Example

Example: docker copy folder to container docker cp Desktop/imagesets < container id > :tf_files/flower_photos/imagesets