Skip to content

Instantly share code, notes, and snippets.

View muhammad-naderi's full-sized avatar

Muhammad Naderi muhammad-naderi

View GitHub Profile
<?php
$sign_in_form_id = 6;
add_action( 'gform_after_submission_' . $sign_in_form_id , 'mu_remove_form_entry' );
/**
* Prevents Gravity Form entries from being stored in the database
* for a specific form. with $sign_in_form_id Id.
*
* @global object $wpdb The WP database object.
@muhammad-naderi
muhammad-naderi / Ion Set Self Signed SSL
Created September 6, 2017 08:51
this gist is gathered from here or there in the internet, and I made a few adjustment to support all of Ion getInstance/getDefault models.
public void setSelfSignedSSL(Context mContext, @Nullable String instanceName){
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
// cert file stored in \app\src\main\res\raw
InputStream caInput = new BufferedInputStream(mContext.getAssets().open("certificate.cer"));
Certificate ca = cf.generateCertificate(caInput);
caInput.close();
@muhammad-naderi
muhammad-naderi / implement.kt
Created June 19, 2018 16:06
implementation of simplest endless recycler view ever
private fun setupRecyclerView(recyclerView : RecyclerView) {
recyclerView.addOnScrollListener(getOnScrollListener())
}
private fun getOnScrollListener(): RecyclerView.OnScrollListener {
val listener = EndlessScrollViewListener.LoadMoreListener {
Log.d("Scroll", "Loading more ...")
SmsHelper.load(context!!)
}
return EndlessScrollViewListener(listener).scrollListener
@muhammad-naderi
muhammad-naderi / EndlessScrollViewListener.java
Last active June 19, 2018 16:11
simplesset endless scroll view listener ever
import android.support.v7.widget.RecyclerView;
public class EndlessScrollViewListener {
private LoadMoreListener listener;
public EndlessScrollViewListener(LoadMoreListener listener) {
this.listener = listener;
}
public RecyclerView.OnScrollListener getScrollListener() {
@muhammad-naderi
muhammad-naderi / GetRunningUser.cs
Last active July 17, 2019 04:52
Get running / initiating user in Dynamics 365
using System;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
namespace GeneralTools
{
public class GetRunningUser : CodeActivity
{
@muhammad-naderi
muhammad-naderi / UserExistsInTeam.cs
Created July 17, 2019 04:59
Dynamics365 - Check if a user exists in a team
using System.Activities;
using System.Linq;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
namespace GeneralTools
{
public class UserExistsInTeam : CodeActivity
{
@muhammad-naderi
muhammad-naderi / IonSetSelfSignedSSL.java
Last active June 22, 2020 03:41
this gist is gathered from here or there on the internet, and I made a few adjustment to support all of Ion getInstance/getDefault models. You just need to call #setSelfSignedSSL() before you make your Ion call to a self signed https endpoint. also put the .cer file in the assets folder
public void setSelfSignedSSL(Context mContext, @Nullable String instanceName){
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
// cert file stored in \app\src\main\assets
InputStream caInput = new BufferedInputStream(mContext.getAssets().open("certificate.cer"));
Certificate ca = cf.generateCertificate(caInput);
caInput.close();
@muhammad-naderi
muhammad-naderi / LocaleHelper.java
Last active November 7, 2020 09:36
a quick Context wraper to change locale of android app in runtime, supporting changes in direction (RTL <-> LTR)
package com.mu.tools;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.Configuration;
import android.os.Build;
import java.util.Locale;
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@muhammad-naderi
muhammad-naderi / CompressionHelper.java
Last active March 22, 2022 15:35
GZip Compression/Decompression Java and C#
import android.util.Base64;
import com.google.android.gms.common.util.IOUtils;
import org.jetbrains.annotations.Nullable;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;