Skip to content

Instantly share code, notes, and snippets.

@a7madev
a7madev / Xcode - Cocoapods.bash
Created October 15, 2014 08:22
Xcode - Cocoapods
# Source: http://cocoapods.org
gem install cocoapods
@a7madev
a7madev / Android - Back Button in Actionbar.java
Created October 15, 2014 12:08
Android - Back Button in Actionbar
//configure Actionbar
ActionBar actionbar = getActionBar();
actionbar.setDisplayHomeAsUpEnabled(true);
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
@a7madev
a7madev / Mac - ADB Connect.bash
Created October 16, 2014 07:43
Mac - ADB Connect
#!/bin/bash
cd /Applications/Android\ Studio.app/sdk/platform-tools
clear
read -p "Enter device IP address: " ip
./adb connect $ip
@a7madev
a7madev / Android - Check Internet Connection.java
Created October 16, 2014 09:30
Android - Check Internet Connection
private boolean checkForInternetConnection() {
Boolean internetIsAvailable = false;
//check for internet connection
try {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
} catch (Exception e) {
Log.d(TAG, "checkForInternetConnection Exception", e);
@a7madev
a7madev / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@a7madev
a7madev / open_whatsapp_contact.java
Created October 16, 2014 16:34
Open Whatsapp Contact Chat
void openWhatsappContact(String number) {
Uri uri = Uri.parse("smsto:" + number);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.setPackage("com.whatsapp");
startActivity(Intent.createChooser(i, ""));
}
@a7madev
a7madev / WordPress Functions.php
Last active August 29, 2015 14:07
Wordpress Functions
<?php
<!-- Logout and redirect to home -->
echo wp_logout_url( home_url() );
<!-- Get Page Title -->
echo get_the_title();
<!-- Redirect -->
wp_redirect('');
@a7madev
a7madev / WordPress - Update Website URL.sql
Created November 24, 2014 07:04
WordPress - Update Website URL
UPDATE `database`.`wp_options` SET `option_value` = 'http://localhost/wp' WHERE `wp_options`.`option_id` = 1;
UPDATE `database`.`wp_options` SET `option_value` = 'http://localhost/wp' WHERE `wp_options`.`option_id` = 2;
@a7madev
a7madev / C# Retrieve Data from Database.cs
Created January 2, 2015 17:51
C# Retrieve Data from Database
SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand();
cmd.Connection=con;
cmd.CommandType=CommandType.Text;
cmd.CommandText="select column from table where condition;";
@a7madev
a7madev / WordPress - Rewrite Root Rules.php
Last active August 29, 2015 14:24
WordPress - Rewrite Root Rules
/**
**================================================================================================================**
* Rewrite Root Rules
**================================================================================================================**
**================================================================================================================**
**/
add_action('generate_rewrite_rules', 'roots_add_rewrites');
function roots_add_rewrites($content) {
$theme_name = next(explode('/themes/', get_stylesheet_directory()));
global $wp_rewrite;