1,273 views

JS get type of variable javascript

var n = 0.87;
var sType = typeof n; //number
 
var str = "Hello Sapce!";
sType = typeof str; //string
 
typeof true === 'boolean';
typeof undefined === 'undefined';
 
typeof function() {} === 'function';
// etc.  ....... 
 
// try get type of null, Infinity, NaN .... 
var strTypeOfNull = typeof null;
alert(strTypeOfNull);
Posted in Javascript css html | Tagged | Comments Off on JS get type of variable javascript
1,260 views

JS check if variable or function exist javascript

Use typeof

// var nMyVariable = 0; // try comment and uncomment this row
 
if(typeof nMyVariable === 'undefined' ){
 alert("Variable not exist");
}ele{
 alert("Variable exist");
}
 
//////////////////////////
// chcek if function exist
function myFunciton (){
  alert("Hello Space!");
}
 
if(typeof myFunction === 'function'){
 myFunction();
}
Posted in Javascript css html | Tagged | Comments Off on JS check if variable or function exist javascript
1,703 views

CSS circle style html

      create div with class with name e.g. circle
      create in styleSheet.css class circle

html code

 <div class="circle" id="">3</div>

css code

.circle {
 border-radius: 50%;
    width: 50px;
    height: 50px;
    background: yellow;
    position: absolute;
    display: block;
    border: 6px solid blue;
    font-size: 50px;
    text-align: center;
}

3

Posted in Javascript css html | Tagged | Comments Off on CSS circle style html
2,108 views

Unchecked call to add(E) as a member of raw type java.util.List

// warnning
private List list = new ArrayList();
 
// ok /put type of added object
private List<String> list = new ArrayList<String>();
Posted in Bugs, warnings, errors | Tagged , | Comments Off on Unchecked call to add(E) as a member of raw type java.util.List
1,800 views

PHP get daylight saving time

$dst = date("I"); //I (capital i); 0 or 1 if daylight saving time
 
// example:
$hour = 14;
if(date("I")===1){
 $hour = $hour + 1;
}
// OR
$hour = 14 + date("I");
Posted in PHP | Tagged | Comments Off on PHP get daylight saving time
2,224 views

Access-Control-Allow-Origin Multiple Origin Domains

In browser’s console get message:
no 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore not allowed access.
PHP source code: put into start of php script

// different DOMAINS
$http_origin = $_SERVER['HTTP_ORIGIN'];
 
if ($http_origin == "http://www.domain1.com" || $http_origin == "http://www.domain2.com" || $http_origin == "http://www.domain3.info")
{  
    header("Access-Control-Allow-Origin: $http_origin");
}
 
// OR different SUBDOMAINS
 $http_origin = $_SERVER['HTTP_ORIGIN']; // e.g. http://bla.yourdomain.com/index.php
 
$pos = strpos($http_origin, ".yourdomain.com");
$dom = ".yourdomain.com";
$le = strlen($dom);
$pos = strpos($http_origin, $dom);
 
if($pos !== false){
	$my_subdomains = substr($http_origin, 0, $pos + $le); // e.g. substr equal http://bla.yourdomain.com
    header("Access-Control-Allow-Origin: $my_subdomains");
}
?>
<!DOCTYPE HTML>
<html>
  <head>
  <meta............... etc.
Posted in PHP | Tagged , | Comments Off on Access-Control-Allow-Origin Multiple Origin Domains
3,882 views

Histogram foto picture smartphone

Very dark picture, in photo editor black remains black
histogram-picture-very-black colored

Very bright picture, in photo editor white will white
histogram-picture-very-bright-picture

Dark picture but the chart is not in black color area – dark shades can be lighten in graphics editor
histogram-picture-diagram

Posted in Android Examples Code, Smartphones | Comments Off on Histogram foto picture smartphone
4,482 views

htaccess code

Change sitemap.txt to sitemap.php if url http://domain.com/sitemap.txt

# http://domain.com/sitemap.txt open sitemap.php
# in sitemap.php is function what return list of address
RewriteRule ^sitemap\.txt$ sitemap.php [L]
RewriteRule ^sitemap$ sitemap.php [L]

Remove www before subdomain name
www.www.subdomain.example.com
to
subdomain.example.com

RewriteCond %{HTTP_HOST} (^|\.)(www\.)([^\.]*)\.example\.com$ [NC]
RewriteRule (.*) http://%3.example.com/$1  [R=301,QSA,L]
Posted in Uncategorized | Tagged | Comments Off on htaccess code
5,501 views

Android 4.4 Lenovo A6000 black screen

Try reboot device.
Start device with start button on side of phone.
Screen will go to light black color.
Long press Start button for menu:
Power off
Reboot
Airplane mode

Reboot item is in same level like Start button.
Click on the screen – (Hear a click)
Now find OK button , it is under Reboot item on right side of screen.
Press OK (Hear a click)
Wait a moment.
If device to do nothing , try short press Start button (sreen will black)
and again to press Start button. If screen go to light black color,
try again find Reboot item as written above.

Posted in Android Examples Code, Bugs, warnings, errors | Tagged , | Comments Off on Android 4.4 Lenovo A6000 black screen
5,506 views

Android runtime change switch Activity theme

static boolean mbThemeLight = false;
 
 @Override
    public void onCreate(Bundle savedInstanceState) {
         if(mbThemeLight)
        setTheme(android.R.style.Theme_Light);
        super.onCreate(savedInstanceState);
        // bla bla bla..........
    }
 
private void switchTheme(){
 mbThemeLight = true;
 this.recreate();
}
Posted in Android Examples Code, Android Studio | Tagged | Comments Off on Android runtime change switch Activity theme
5,506 views