This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
compileSdkVersion 21 | |
buildToolsVersion "21.0.0" | |
defaultConfig { | |
minSdkVersion 21 | |
targetSdkVersion 21 | |
} | |
compileOptions { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.panayiotisgeorgiou.androidxmlresources | |
import android.support.v7.app.ActionBarActivity; | |
import android.widget.ImageView; | |
import android.widget.LinearLayout; | |
import android.widget.TextView; | |
import android.content.res.TypedArray; | |
import android.os.Bundle; | |
public class MainActivity extends ActionBarActivity { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
function changeEach(el){ | |
var text = document.getElementById(el).value; | |
var capital = text.toUpperCase(); | |
document.getElementById(el).value = capital; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_visitor_ip() { | |
$ip = ''; | |
if ($_SERVER['HTTP_CLIENT_IP']) | |
$ip = $_SERVER['HTTP_CLIENT_IP']; | |
else if($_SERVER['HTTP_X_FORWARDED_FOR']) | |
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; | |
else if($_SERVER['HTTP_X_FORWARDED']) | |
$ip = $_SERVER['HTTP_X_FORWARDED']; | |
else if($_SERVER['HTTP_FORWARDED_FOR']) | |
$ip = $_SERVER['HTTP_FORWARDED_FOR']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// related posts | |
$related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 6, 'post__not_in' => array($post->ID) ) ); | |
if( $related ){ ?> | |
<div class="related_posts"> | |
<h2>Related Tutorials</h2> | |
<ul> | |
<?php foreach( $related as $post ) { | |
setup_postdata($post); ?> | |
<li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function your_excerpt_length( $length ) { | |
return 70; | |
} | |
add_filter( 'excerpt_length', 'your_excerpt_length' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Database configs | |
$host="localhost"; | |
$dbuser=""; | |
$dbpass=""; | |
$dbname = ""; | |
$link = mysqli_connect($host, $dbuser, $dbpass, $dbname); | |
if (mysqli_connect_errno()) | |
echo mysqli_connect_error(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$string = 'please contact me on email@emaildomain.com'; | |
ereg_replace("[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,3})", "<a href=\"mailto:\\0\">\\0</a>", $string); | |
ereg_replace is deprecated therefore we can use: | |
function convertEmailToLinks($string) { | |
return preg_replace("/[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,3})/", "<a href=\"mailto:\\0\">\\0</a>", $string); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To check if your device support Bluetooth Low Energy programmically, check (getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)). | |
Android 4.3 (API Level 18) introduces built-in platform support for Bluetooth Low Energy in the central role and provides APIs that apps can use to discover devices, query for services, and read/write characteristics. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List running service of Android device |