Skip to content

Instantly share code, notes, and snippets.

Avatar

Muhammad Naderi muhammad-naderi

View GitHub Profile
@muhammad-naderi
muhammad-naderi / UserExistsInTeam.cs
Created Jul 17, 2019
Dynamics365 - Check if a user exists in a team
View UserExistsInTeam.cs
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 / GetRunningUser.cs
Last active Jul 17, 2019
Get running / initiating user in Dynamics 365
View GetRunningUser.cs
using System;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
namespace GeneralTools
{
public class GetRunningUser : CodeActivity
{
@muhammad-naderi
muhammad-naderi / CompressionHelper.java
Last active Jul 19, 2020
GZip Compression/Decompression Java and C#
View CompressionHelper.java
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;
@muhammad-naderi
muhammad-naderi / implement.kt
Created Jun 19, 2018
implementation of simplest endless recycler view ever
View implement.kt
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 Jun 19, 2018
simplesset endless scroll view listener ever
View EndlessScrollViewListener.java
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 / IonSetSelfSignedSSL.java
Last active Jun 22, 2020
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
View IonSetSelfSignedSSL.java
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 / Ion Set Self Signed SSL
Created Sep 6, 2017
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.
View Ion Set Self Signed SSL
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 / LocaleHelper.java
Last active Nov 7, 2020
a quick Context wraper to change locale of android app in runtime, supporting changes in direction (RTL <-> LTR)
View LocaleHelper.java
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;
@muhammad-naderi
muhammad-naderi / functions-mu-encryption.php
Created Jul 12, 2016
Wordpress encrypt usermeta data database
View functions-mu-encryption.php
<?php
/**
* Created by PhpStorm.
* User: Muhammad
* Date: 05/07/2016
* Time: 01:20 PM
*/
add_filter('get_user_metadata', 'decrypt_user_meta',10,4);
View PSWebServiceLibrary.php
<?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