Posts

Showing posts from February, 2012

Android - How To Access Emulator Screenshot Via Emulator?

Image
Answer : It will save in your PC . You can also specify the location of screenshots from the emulator settings . Please see the following image for reference. Emulate Volume Down + Power event to trigger Android's screenshot, then screenshot pictures will be stored at emulator's /storage/emulated/0/Pictures/Screenshots . Here is the script. Run adb shell , then copy the code below and run, you should see the emulator start taking a screenshot. cat > /data/local/tmp/screenshot.sh <<EOF #!/bin/sh echo 'volume key: down' sendevent /dev/input/event1 1 114 1 echo 'power key: down' sendevent /dev/input/event1 1 116 1 sendevent /dev/input/event1 0 0 0 sleep 1 echo 'volume key: up' sendevent /dev/input/event1 1 114 0 echo 'power key: up' sendevent /dev/input/event1 1 116 0 sendevent /dev/input/event1 0 0 0 EOF sh /data/local/tmp/screenshot.sh NOTE: My emulator's input device is "/dev/input/event1", this may be differ

Check If Variable Is Empty Javascript Code Example

Example 1: is var is not blank then display value in javascript if ( data !== null && data !== '' ) { // do something } Example 2: javascript check if object is null or empty if ( typeof value !== 'undefined' && value ) { //deal with value' } ; Example 3: javascript check if undefined or null or empty string // simple check do the job if ( myString ) { // comes here either myString is not null, // or myString is not undefined, // or myString is not '' (empty). } Example 4: javascript check if variable is empty if ( value ) { // } /** * This will evaluate to true if value is not: * null * undefined * NaN * empty string ("") * 0 * false */

Change Position Of Google Maps API's "My Location" Button

Answer : You can get the "My Location" button and move it, like : public class MapFragment extends SupportMapFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mapView = super.onCreateView(inflater, container, savedInstanceState); // Get the button view View locationButton = ((View) mapView.findViewById(1).getParent()).findViewById(2); // and next place it, for exemple, on bottom right (as Google Maps app) RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams(); // position on right bottom rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); rlp.setMargins(0, 0, 30, 30); } } Just use GoogleMap.setPadding(left, top, right, bottom), which allows you to indicate parts of the map that may be obscured by other views. Setting padding re-positions the s

Converting String To Int Js 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: javascript string to integer < script language = "JavaScript" type = "text/javascript" > var a = "3.3445" ; var c = parseInt ( a ) ; alert ( c ) ; < / script > Example 4: string to int javascript var text = '3.14someRandomStuff' ; var pointNum = parseFloat ( text ) ; // returns 3.14 Example 5: string to number javascript new Number ( valeur ) ; var a = new Number ( '123' ) ; // a === 123 donnera false var b = Number ( '123' ) ; // b === 123 donnera true a instanceof Number ; // donnera true b instanceof Number ; // donnera false

Align Div Side By Side Html Responsive Code Example

Example 1: how to align two divs side by side .wrapper { display: flex; flex-wrap: wrap; } .wrapper>div { flex: 1 1 150px; height: 500px; } Example 2: div side by side .float-container { border: 3px solid #fff; padding: 20px; } .float-child { width: 50%; float: left; padding: 20px; border: 2px solid red; } < div class = " float-container " > < div class = " float-child " > < div class = " green " > Float Column 1 </ div > </ div > < div class = " float-child " > < div class = " blue " > Float Column 2 </ div > </ div > </ div >

Codeigniter 4 Query Builder Entity Code Example

Example 1: query builder codeigniter $this - > db - > set ( 'name' , $name ) ; $this - > db - > set ( 'title' , $title ) ; $this - > db - > set ( 'status' , $ status ) ; $this - > db - > insert ( 'mytable' ) ; Example 2: codeigniter 4 query builder select $builder - > select ( 'title, content, date' ) ; $query = $builder - > get ( ) ; // Executes: SELECT title, content, date FROM mytable

Closing Gitlab Merge Request

Answer : In Gitlab, the merged status means the relevant commits have been merged and no action is needed. A closed merge request is one that has been put aside or considered irrelevant. It is therefore not merged into the code base. Therefore, you only merge MRs when you're happy with the changes and close them if you think the changes are not worthy of being integrated into the code base ever. A typical workflow would be the following: User A works on a new feature in a feature branch and pushes their work to that branch. They can open a merge request to merge their feature branch into master. User B pulls the feature branch, eventually rebasing it onto master, and runs the tests they want. If User B is happy with the changes/new feature, they can merge the MR into master (or whatever branch you merge into) The merge request will be shown as merged Of course it's better if the tests run automatically in a CI. With GitLab 12.2 (August 2019), you have n

Bootstrap 4 Tooltip Dynamic Content Code Example

Example: bootstrap tooltip on dynamic element $("body").tooltip({ selector: '[data-toggle="tooltip"]' });

Cpp Std Erase Code Example

Example: c++ erase remove std :: vector < int > v = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; v . erase ( std :: remove ( v . begin ( ) , v . end ( ) , 5 ) , v . end ( ) ) ; // v will be {0 1 2 3 4 6 7 8 9}

Checking Something IsEmpty In Javascript?

Answer : If you're testing for an empty string: if(myVar === ''){ // do stuff }; If you're checking for a variable that has been declared, but not defined: if(myVar === null){ // do stuff }; If you're checking for a variable that may not be defined: if(myVar === undefined){ // do stuff }; If you're checking both i.e, either variable is null or undefined: if(myVar == null){ // do stuff }; This is a bigger question than you think. Variables can empty in a lot of ways. Kinda depends on what you need to know. // quick and dirty will be true for '', null, undefined, 0, NaN and false. if (!x) // test for null OR undefined if (x == null) // test for undefined OR null if (x == undefined) // test for undefined if (x === undefined) // or safer test for undefined since the variable undefined can be set causing tests against it to fail. if (typeof x == 'undefined') // test for empty string if (x === '') // if you know

Button Small Bootstrap Code Example

Example 1: large button in bootstrap <!-- Large buttons --> < button type = " button " class = " btn btn-primary btn-lg " > Large button </ button > <!-- Medium Buttons --> < button type = " button " class = " btn btn-primary " > Large button </ button > <!-- Small Buttons --> < button type = " button " class = " btn btn-primary btn-sm " > Large button </ button > <!-- Block Buttons --> < button type = " button " class = " btn btn-primary btn-lg btn-block " > Block level button </ button > Example 2: bootstarp btn colors < button type = " button " class = " btn btn-primary " > Blue </ button > < button type = " button " class = " btn btn-secondary " > Grey </ button > < button type = " button " class = " btn btn-success &quo

Pip Install Anaconda-clean Code Example

Example 1: delete conda from machine conda install anaconda - clean # install the package anaconda clean anaconda - clean -- yes # clean all anaconda related files and directories rm - rf ~ / anaconda3 # removes the entire anaconda directory rm - rf ~ / . anaconda_backup # anaconda clean creates a back_up of files / dirs , remove it # ( conda list ; cmd shouldn ' t respond after the clean up ) Example 2: uninstall anaconda ubuntu # Install anaconda - clean conda install anaconda - clean # start anaconda - clean anaconda - clean -- yes

Active Directory: Viewing "Attribute Editor" After Finding An Account Via ADUC's "Find" Option

Image
Answer : Solution 1: I'd say set up a query for the user search instead of using the Find feature. It's a few extra clicks, but gives you the Attribute Editor tab properly. Make sure you set the query definition to the "Users..." type instead of the "Common Queries" type, so you get the right search behavior.. ..and the Attribute Editor tab works on the object when opened from this view. Solution 2: This seems to be a solution! http://activedirectoryfaq.com/2014/10/ad-attribute-editor-missing-make-search-visible Open de object after using "Find". Click the "Member of" tab. Open a group of which the object is a member. Close the object window. Locate the object in the group and double-click it. The object window should open with the "Attribute Editor" available. Should work. Tried it myself but I don't have an Attribute Editor available (Attribute Editor does not exist in a 2000/2003 forest). https:/

"Application.Quit" Leaves Excel Running In The Background

Answer : Before Excel 2016 , Excel had the possibilities to have multiple Excel files in a single window. In Excel 2016 , it is one window per application. The problem with your code is that it closes an instance. Based on the fact how the Excel files were opened, this would be either enough or not. E.g., if Excel files were opened in the same instance this would be quite enough. A bit of an amateur myself and I realize this is a bit of an old thread, but I am wondering if you save the workbook (as you do) but also close the workbook and quit Excel, it may clear up the task manager. I notice you save the workbook but don't actually close the workbook, so it stays open. I ran into a similar issue before and I think this finally what fixed it. This is code I use every time I want to quit Excel. Usually I have 2 books open, one is a template (which I don't save) and the other is one that was created with data from the template. ActiveWorkbook.Close SaveChanges:=True Ap

Best Math Font With Times New Roman In XeLaTeX

Image
Answer : I'm not sure what's supposed to be best . The following methods work well , though. For the Times (New) Roman text font, you could choose (via \setmainfont ) Times New Roman XITS TeX Gyre Termes Stix Two Text (see http://stixfonts.org/ for more information) For a Times (New) Roman-like math font, first load the unicode-math package and then load (via \setmathfont ) XITS Math TeX Gyre Termes Math Stix Two Math . Alternatively, just use \usepackage{fontspec} \usepackage{newtxtext,newtxmath} First Addendum : A personal comment on the mostly minuscule differences between Times (aka Times Roman ) and Times New Roman . To the best of my knowledge, there are only two readily-noticeable differences among the two fonts when using Latin letters (more differences occur with Greek letters): the italic lowercase letter z : it's "swashy" with Times Roman, but non-swashy with Times New Roman; and the % symbol, in both upright and i

Cannot Drop Column : Needed In A Foreign Key Constraint

Answer : Having a look at MySql docs I've found a warning about foreign_key_keys : Warning With foreign_key_checks=0, dropping an index required by a foreign key constraint places the table in an inconsistent state and causes the foreign key check that occurs at table load to fail. To avoid this problem, remove the foreign key constraint before dropping the index (Bug #70260). IMHO you should drop FOREIGN KEY before DROP the COLUMN. ALTER TABLE `user` DROP FOREIGN KEY `FK_G38T6P7EKUXYWH1`; ALTER TABLE `user` DROP COLUMN `region_id`; I've set up a rextester example, check it here.

Alpha Testing Is Done At. Code Example

Example: what is alpha testing Alpha testing is done by the in-house developers Sometimes alpha testing is done by the client or outsourcing team with the presence of developers or testers.

Case-insensitive REPLACE In MySQL?

Answer : If replace(lower()) doesn't work, you'll need to create another function. My 2 cents. Since many people have upgraded from MySQL to MariaDB those people will have available a new function called REGEXP_REPLACE . Use it as you would a normal replace, but the pattern is a regular expression. This is a working example: UPDATE `myTable` SET `myField` = REGEXP_REPLACE(`myField`, '(?i)my insensitive string', 'new string') WHERE `myField` REGEXP '(?i)my insensitive string' The option (?i) makes all the subsequent matches case insensitive (if put at the beginning of the pattern like I have then it all is insensitive). See here for more information: https://mariadb.com/kb/en/mariadb/pcre/ Edit: as of MySQL 8.0 you can now use the regexp_replace function too, see documentation: https://dev.mysql.com/doc/refman/8.0/en/regexp.html Alternative function for one spoken by fvox. DELIMITER | CREATE FUNCTION case_insensitive_replace ( REPLA
Answer : The LaTeX macros \begin{equation} and \[ both initiate a display-math group, and the macros \end{equation} and \] both terminate a display-math group. (In addition, the equation environment provides a method for numbering the equations, whereas \[ ... \] does not.) The LaTeX macros \begin{equation} and \[ are designed purposefully so as not to let users open a display-math group twice; this is why you're getting the error message "Bad math environment delimiter" when LaTeX encounters \[ after having processed \begin{equation} . The upshot: Use one or the other method for setting up a display-math group, but don't use both simultaneously. For a more-detailed discussion of how various LaTeX displaymath environments are set up, see this answer to the question "What are the differences between $$ , \[ , align , equation and displaymath ?" Shameless self-citation alert! I can't improve @Mico 's correct accepted answer to the qu

Bootstrap Cdn V3.3.7 Code Example

Example 1: bootstrap 3 cdn < ! - - Latest compiled and minified CSS - -> < link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity = "sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin = "anonymous" > < ! - - Optional theme - -> < link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity = "sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin = "anonymous" > < ! - - Latest compiled and minified JavaScript - -> < script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity = "sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin = "anonymous" > < / script > Example 2: boot