Skip to content

Instantly share code, notes, and snippets.

View hossinasaadi's full-sized avatar
🌍
Home

Hossin Asaadi hossinasaadi

🌍
Home
  • Amsterdam
View GitHub Profile
@hossinasaadi
hossinasaadi / custom-search-acf-wordpress.php
Created November 29, 2017 16:12 — forked from charleslouis/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}
@hossinasaadi
hossinasaadi / toolbarcolor
Created January 31, 2018 11:21 — forked from androidcodehunter/toolbarcolor
How to change toolbar back arrow color and title color?
From theme
<style name="SearchToolbar" parent="Theme.AppCompat.Light.NoActionBar">
//toolbar back arrow color
<item name="android:textColorSecondary">@android:color/white</item>
//toolbar title color
<item name="android:textColorPrimary">@android:color/white</item>
</style>
Also we can do it from java code:
@hossinasaadi
hossinasaadi / orientationChange.js
Created July 27, 2018 15:12 — forked from mynameispj/orientationChange.js
jQuery event that fires when the orientation (portrait, landscape) of a mobile device changes
window.addEventListener("orientationchange", function() {
alert(window.orientation);
//do whatever you want on orientation change here
}, false);
@hossinasaadi
hossinasaadi / activity-launchmode.xml
Created December 31, 2018 19:01 — forked from Yincan/activity-launchmode.xml
Android Activity LaunchMode attribute
<activity android:launchMode = ["standard" | "singleTop" | "singleTask" | "singleInstance"] ../>
@hossinasaadi
hossinasaadi / height.java
Created June 27, 2019 22:28 — forked from hamakn/height.java
Android: Get height of status, action, navigation bar (pixels)
// status bar height
int statusBarHeight = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
// action bar height
int actionBarHeight = 0;
final TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(
@hossinasaadi
hossinasaadi / add-metabox-to-taxonomy.php
Created May 13, 2020 18:22 — forked from ms-studio/add-metabox-to-taxonomy.php
simple but complete example of adding metabox to taxonomy - using WP 4.4 term meta functions
<?php
// source: http://wordpress.stackexchange.com/questions/211703/need-a-simple-but-complete-example-of-adding-metabox-to-taxonomy
// code authored by jgraup - http://wordpress.stackexchange.com/users/84219/jgraup
// REGISTER TERM META
add_action( 'init', '___register_term_meta_text' );
function ___register_term_meta_text() {
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@hossinasaadi
hossinasaadi / mac-setup-redis.md
Created May 3, 2021 21:19 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@hossinasaadi
hossinasaadi / FileObserver on Android
Created July 29, 2021 18:07 — forked from shirou/FileObserver on Android
Detect file change using FileObserver on Android
private class PathFileObserver extends FileObserver{
static final String TAG="FILEOBSERVER";
/**
* should be end with File.separator
*/
String rootPath;
static final int mask = (FileObserver.CREATE |
FileObserver.DELETE |
FileObserver.DELETE_SELF |
FileObserver.MODIFY |
@hossinasaadi
hossinasaadi / echo-enqueued-styles-scripts-wordpress.php
Created January 9, 2022 17:05 — forked from omurphy27/echo-enqueued-styles-scripts-wordpress.php
Wordpress - Print Out All Enqueued Scripts And Styles On A Page
<?php
// add the below to your functions file
// then visit the page that you want to see
// the enqueued scripts and stylesheets for
function se_inspect_styles() {
global $wp_styles;
echo "<h2>Enqueued CSS Stylesheets</h2><ul>";
foreach( $wp_styles->queue as $handle ) :
echo "<li>" . $handle . "</li>";