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 / RuntimePermissionsActivity.java
Created March 31, 2019 08:57
Runtime Permissions In Android >= 6
package asaadi.hossin.app;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.SparseIntArray;
public abstract class RuntimePermissionsActivity extends AppCompatActivity {
@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 / Utils.php
Created September 2, 2019 18:04
str_slug() (Str::slug) for arabic & Persian (farsi) Languages in laravel
<?php
/**
* Created by PhpStorm.
* User: Hossin Asaadi
* Date: 9/2/2019
* Time: 7:43 PM
*/
namespace App\Traits;
@hossinasaadi
hossinasaadi / RegNumericRange.min.js
Last active December 19, 2019 09:42
Numeric Range Generator in Js and jquery
/***
* Regex Numeric Range Generator
* Author: Erwin Yusrizal <erwin.yusrizal@gmail.com>
* Version: 1.0.0
*/
this.RegNumericRange=function(){function t(r,e,n,s){return null===n&&(n={}),this instanceof t?(this.minValue=r,this.maxValue=e,this.options=this.extend({},this.defaults,n),void(this.data={})):new t(r,e,n,s)}return t.prototype.defaults={MatchWholeWord:!1,MatchWholeLine:!1,MatchLeadingZero:!1,showProcess:!1},t.prototype.generate=function(t){var r=this.minValue.toString(),e=this.maxValue.toString(),n=[],s=[],i=[];if(!this.minValue||!this.maxValue){var a="Minimum & Maximum value is required!";if("function"==typeof t)return t({success:!1,message:a});throw new Error(a)}if(!this.isNumeric(this.minValue)||!this.isNumeric(this.maxValue)){var a="Minimum & Maximum value must numbers only!";if("function"==typeof t)return t({success:!1,message:a});throw new Error(a)}if(parseInt(this.minValue)===parseInt(this.maxValue)||parseInt(this.minValue)>parseInt(this.maxValue)){var a="Max. value must greater than Min. val
@hossinasaadi
hossinasaadi / regex_range.php
Created December 19, 2019 09:41
regex generator for range between two numbers in PHP
<?php
function regex_range($from, $to) {
if($from < 0 || $to < 0) {
throw new Exception("Negative values not supported");
}
if($from > $to) {
throw new Exception("Invalid range $from..$to, from > to");
}
@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() {