Posts

Showing posts from April, 2001

Android XXHDPI Resources

Answer : According to the post linked in the G+ resource: The gorgeous screen on the Nexus 10 falls into the XHDPI density bucket. On tablets, Launcher uses icons from one density bucket up [0] to render them slightly larger. To ensure that your launcher icon (arguably your apps most important asset) is crisp you need to add a 144*144px icon in the drawable-xxhdpi or drawable-480dpi folder. So it looks like the xxhdpi is set for 480dpi. According to that, tablets use the assets from one dpi bucket higher than the one they're in for the launcher. The Nexus 10 being in bucket xhdpi will pull the launcher icon from the xxhdpi. Source Also, was not aware that tablets take resources from the asset bucket above their level. Noted. The DPI of the screen of the Nexus 10 is ±300, which is in the unofficial xhdpi range of 280‑400. Usually, devices use resources designed for their density. But there are exceptions, and exceptions might be added in the future. T

Visual Studio Code Auto Indent Shortcut Code Example

Example 1: visual studio code auto indent On Windows Shift + Alt + F On Mac Shift + Option + F On Ubuntu Ctrl + Shift + I Example 2: shortcode to format code in Visul studio In Visual Studio , the shortcut for Code Formatting is Ctrl + k Ctrl + D Example 3: visual studio code indent outdent shortcut Indent using tab key . Outdent using Shift + tab key . Example 4: visual studio code windows auto indent Shift + Alt + F Example 5: viscode format automatico { // Controls if the editor should automatically format the line after typing "beautify.onSave" : true , "editor.formatOnSave" : true , // You can auto format any files based on the file extensions type. "beautify.JSfiles" : [ "js" , "json" , "jsbeautifyrc" , "jshintrc" , "ts" ] }

Bootstrap 3 Carousel Multiple Items Example

Example: bootstrap 4 carousel multiple items responsive <!-- Top content --> < div class = " top-content " > < div class = " container-fluid " > < div id = " carousel-example " class = " carousel slide " data-ride = " carousel " > < div class = " carousel-inner row w-100 mx-auto " role = " listbox " > < div class = " carousel-item col-12 col-sm-6 col-md-4 col-lg-3 active " > < img src = " assets/img/backgrounds/1.jpg " class = " img-fluid mx-auto d-block " alt = " img1 " > </ div > < div class = " carousel-item col-12 col-sm-6 col-md-4 col-lg-3 " > < img src = " assets/img/backgrounds/2.jpg " class = " img-fluid mx-auto d-block " alt = " img2 "

How To Copy A Char Cstring To Replace The Other One C++ Code Example

Example 1: c++ replace character in string # include <algorithm> # include <string> void some_func ( ) { std :: string s = "example string" ; std :: replace ( s . begin ( ) , s . end ( ) , 'x' , 'y' ) ; // replace all 'x' to 'y' } Example 2: c++ replace character in string # include <string> # include <regex> using namespace std ; string test = "abc def abc def" ; // The string to replace // You need to write your part to replace inside the regex(), and write what is the replacement after test = regex_replace ( test , regex ( "abc" ) , "Ziv" ) ; // The replacement.

Apache's Deprecated SSLCertificateChainFile Directive (AH02559)

Answer : Given that you're using this in your apache config: SSLCertificateFile /etc/apache2/cert/ssl.crt SSLCertificateKeyFile /etc/apache2/cert/ssl.key The /etc/apache2/cert/ssl.crt file should contain certificate of e.g. yourdomain.com certificate of first intermediate CA, signed by root CA (e.g.StartCom Class 1 Primary Intermediate Server CA) certificate of second intermediate CA, signed by first intermediate CA (if there is a second intermediate CA in your certificate chain) You need to put all intermediate CA's certificates in the crt file. Depending on the certificate chain of your certificate there will be varying number of CAs invovled. You don't even need to add the root CA, as it has to be in the trust store of any clients, otherwise clients will get an error page, also, if you add it to your chain, it will just be additional overhead for establishing SSL connections, as it has to be transferred for every new SSL session. Actually most client

Checkbox Size Change Code Example

Example 1: css resize checkbox input [ type = checkbox ] { transform : scale ( 1.5 ) ; } Example 2: input checkbox size css input [ type = checkbox ] { transform : scale ( 1.5 ) ; } <label><input type= "checkbox" > Test</label>

Address Validation Using Google Maps API

Answer : The answer probably depends how critical it is for you to receive support and possible customization for this service. Google can certainly do this. Look into their XML and Geocoding API's. You should be able to craft an XML message asking Google to return Map coordinates for a given address. If the address is not found (invalid), you will receive an appropriate response. Here's a useful page: http://code.google.com/apis/maps/documentation/services.html#XML_Requests Note that Google's aim in providing the Maps API is to plot addresses on actual maps. While you can certainly use the data for other purposes, you are at the mercy of Google should one of their maps not exactly correspond to your legal or commercial address validation needs. If you paid for one of the services you mentioned, you would likely be able to receive support should certain addresses not resolve the way you expect them to. In other words, you get what you pay for ;) . If you have the t

Array Reverse Php Code Example

Example 1: php reverse array $array= array(1,2,3,4,5); $reversedArray = array_reverse($array); var_dump($y); Example 2: array reverse php array_reverse($array); Example 3: php array_reverse keep keys <?php $input = array("php", 4.0, array("green", "red")); $reversed = array_reverse($input); $preserved = array_reverse($input, true); print_r($input); print_r($reversed); print_r($preserved); ?>

Check If A Table Exists In Rails

Answer : In Rails 5 the API became explicit regarding tables/views, collectively data sources . # Tables and views ActiveRecord::Base.connection.data_sources ActiveRecord::Base.connection.data_source_exists? 'kittens' # Tables ActiveRecord::Base.connection.tables ActiveRecord::Base.connection.table_exists? 'kittens' # Views ActiveRecord::Base.connection.views ActiveRecord::Base.connection.view_exists? 'kittens' In Rails 2, 3 & 4 the API is about tables . # Listing of all tables and views ActiveRecord::Base.connection.tables # Checks for existence of kittens table/view (Kitten model) ActiveRecord::Base.connection.table_exists? 'kittens' Getting the status of migrations: # Tells you all migrations run ActiveRecord::Migrator.get_all_versions # Tells you the current schema version ActiveRecord::Migrator.current_version If you need more APIs for migrations or metadata see: ActiveRecord::SchemaMigration this is the ActiveRecord::Base

Online Turbo C Compiler For Graphics Code Example

Example 1: online c compiler I Personally Like https : //www.programiz.com/c-programming/online-compiler/ Example 2: online c compiler You can try https : //www.onlinegdb.com/ this as well, works really well for me. You can also save code there .

Bool To String Arduino Code Example

Example 1: bool to string arduino YourVariable.tostring(); Example 2: bool to string arduino String(yourVariable);

Button Onclick Go To Different Page Code Example

Example 1: js onclick redirect < button onclick = "location.href='www.yoursite.com'" > Click Me < / button > Example 2: how to open a new html page on button click in javascript < button id = "myButton" class = "float-left submit-button" > Home < / button > < script type = "text/javascript" > document . getElementById ( "myButton" ) . onclick = function ( ) { location . href = "www.yoursite.com" ; } ; < / script >

BehaviorSubject Vs Observable?

Image
Answer : BehaviorSubject is a type of subject, a subject is a special type of observable so you can subscribe to messages like any other observable. The unique features of BehaviorSubject are: It needs an initial value as it must always return a value on subscription even if it hasn't received a next() Upon subscription, it returns the last value of the subject. A regular observable only triggers when it receives an onnext at any point, you can retrieve the last value of the subject in a non-observable code using the getValue() method. Unique features of a subject compared to an observable are: It is an observer in addition to being an observable so you can also send values to a subject in addition to subscribing to it. In addition, you can get an observable from behavior subject using the asObservable() method on BehaviorSubject . Observable is a Generic, and BehaviorSubject is technically a sub-type of Observable because BehaviorSubject is an observable wi

Php Générer Date To String Code Example

Example 1: format('Y-m-d H:i:s'); ?> < ? php $date = new DateTime ( '2000-01-01' ) ; echo $date -> format ( 'Y-m-d H:i:s' ) ; ? > Example 2: phph date < ? php // Définit le fuseau horaire par défaut à utiliser. Disponible depuis PHP 5.1 date_default_timezone_set ( 'UTC' ) ; // Affichage de quelque chose comme : Monday echo date ( "l" ) ; // Affichage de quelque chose comme : Monday 8th of August 2005 03:12:46 PM echo date ( 'l jS \of F Y h:i:s A' ) ; // Affiche : July 1, 2000 is on a Saturday echo "July 1, 2000 is on a " . date ( "l" , mktime ( 0 , 0 , 0 , 7 , 1 , 2000 ) ) ; /* utilise les constantes dans le paramètre format */ // Affichage de quelque chose comme : Wed, 25 Sep 2013 15:28:57 -0700 echo date ( DATE_RFC2822 ) ; // Affichage de quelque chose comme : 2000-07-01T00:00:00+00:00 echo date ( DATE_ATOM , mktime ( 0 , 0 , 0 , 7 , 1 , 2000 ) ) ; ? >

Authenticate User Using Omniauth And Facebook For A Rails API?

Answer : the best way I found (after being stuck for a while on this issue ) is to do your omniauth2 (specifically in my case using satellizer angular plugin) manually... I'll discuss the solution for Facebook as it was my case, but everything could apply to any other provider. first you have to know how omniauth2 works (as documented for humans here)... Client: Open a popup window for user to authenticate. Client: Sign in (if necessary), then authorize the application. Client: After successful authorization, the popup is redirected back to your app. with the code (authorization code) query string parameter the redirect back url must match your front-end app url not the back-end url and it must be specified in your facebook app configurations Client: The code parameter is sent back to the parent window that opened the popup. Client: Parent window closes the popup and sends a POST request to backend/auth/facebook with code parameter. Server: code ( A

Can I Create A New Session In Another Tab Or Window In Google Chrome?

Answer : Currently, this is not possible. You can use multiple profiles in Google Chrome, though. Read the instructions here. Enable multiple accounts: https://www.google.com/accounts/MultipleSessions Then, create a bookmark(let) or a keyboard shortcut for each mailbox: https://mail.google.com/mail/u/0/#inbox https://mail.google.com/mail/u/1/#inbox Source: http://lifehacker.com/5733636/switch-between-multiple-gmail-accounts-with-a-url-hack MultiLogin is down from the google webstore, but there is an alternative (SessionBox) https://chrome.google.com/webstore/detail/sessionbox-beta/megbklhjamjbcafknkgmokldgolkdfig

Blender 2.6: Select Object By Name Through Python

Answer : bpy.data.objects['OBJECT'].select = True Selection data is contained within the individual objects. You can read and write them as shown. In a slightly more readable form: object = bpy.data.objects['OBJECT'] object.select = True bpy.ops.object.select_name() has been replaced by bpy.ops.object.select_pattern() (around 2.62, I think?), which is a more powerful version (it can select an exact name, but also use patterns with wildcards, be case-insensitive, etc.): bpy.ops.object.select_pattern(pattern="Cube") import bpy def returnObjectByName (passedName= ""): r = None obs = bpy.data.objects for ob in obs: if ob.name == passedName: r = ob return r obs = bpy.data.objects bpy.ops.object.select_all(action='DESELECT') for ob in obs: print (ob.name) myObj = returnObjectByName(ob.name) if myObj != None: print (dir(myObj)) myObj.selected = True myObj.loc

Calculate The Standard Deviation Of Grouped Data In A Spark DataFrame

Image
Answer : Spark 1.6+ You can use stddev_pop to compute population standard deviation and stddev / stddev_samp to compute unbiased sample standard deviation: import org.apache.spark.sql.functions.{stddev_samp, stddev_pop} selectedData.groupBy($"user").agg(stdev_pop($"duration")) Spark 1.5 and below ( The original answer ): Not so pretty and biased (same as the value returned from describe ) but using formula: you can do something like this: import org.apache.spark.sql.functions.sqrt selectedData .groupBy($"user") .agg((sqrt( avg($"duration" * $"duration") - avg($"duration") * avg($"duration") )).alias("duration_sd")) You can of course create a function to reduce the clutter: import org.apache.spark.sql.Column def mySd(col: Column): Column = { sqrt(avg(col * col) - avg(col) * avg(col)) } df.groupBy($"user").agg(mySd($"duration").a