Skip to content

Instantly share code, notes, and snippets.

View smarteist's full-sized avatar
🙂
I may be slow to respond.

Ali Hosseini smarteist

🙂
I may be slow to respond.
View GitHub Profile
@smarteist
smarteist / LocaleHelper.java
Created December 9, 2018 13:14
Android Locale Changer
package com.rayana.himeapp.Utility;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.LocaleList;
import android.preference.PreferenceManager;
@smarteist
smarteist / utils.php
Created December 30, 2018 20:28
php utils
<?php
class utils
{
public static function get_request_headers()
{
$headers = array();
@smarteist
smarteist / xdebug-mac.md
Created March 31, 2019 19:38 — forked from ankurk91/xdebug-mac.md
php xDebug on Ubuntu/Mac and phpStorm 2018

🪲 Install and Configure xDebug on MacOS for PhpStorm 🐘

⚠️ This guide only applies to Homebrew v1.6+

  • Check your version brew --version before proceeding

  • Assuming that you have already installed php and apache via Homebrew v1.6+

  • Install xDebug php extension

pecl channel-update pecl.php.net
pecl clear-cache
@smarteist
smarteist / install_postman.sh
Last active April 29, 2019 14:37
Postman 7 Installation SH commands for ubuntu
#!/bin/bash
# Get postman app
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
sudo tar -xzf postman.tar.gz -C /opt
sudo ln -s /opt/Postman/Postman /usr/bin/postman
sudo apt-get -y install libgconf2-4
sudo apt-get -y install libcanberra-gtk-module
sudo apt-get -y install libcanberra-gtk-module:i386
#Create a Desktop Entry
cat > ~/.local/share/applications/postman.desktop <<EOL
@smarteist
smarteist / DiffUtilCallback
Last active May 24, 2019 07:02
It's more simple callback for calculating the diff between two non-null items in a list.
/**
* It's more simple callback for calculating the diff between two non-null items in a list.
* <p>
* {@link DiffUtil.Callback} serves two roles - list indexing, and item diffing. ItemCallback handles
* just the second of these, which allows separation of code that indexes into an array or List
* from the presentation-layer and content specific diffing code.
*
* @param <T> Type of items to compare.
*/
public abstract class DiffUtilCallback<T> extends DiffUtil.Callback {
@smarteist
smarteist / dl.php
Last active January 7, 2020 15:07
download using php
<?php
// File to download.
$url = 'http://195.248.240.40/bs/q7HOz9I1yd3qoyoLjsQu/user.admin.hilet.2019-12-27_11-00-18_GMT.tar.gz';
// Open file
$fp = fopen($url, 'r');
file_put_contents(basename($url), $fp);
@smarteist
smarteist / Webpack configs.js
Last active January 10, 2020 15:23
Webpack configs
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const globSync = require('glob').sync;
@smarteist
smarteist / DiffUtilCallback.java
Last active January 23, 2020 20:16
It's more simple callback for calculating the diff between two non-null items in a list.
/**
* It's more simple callback for calculating the diff between two non-null items in a list.
* <p>
* {@link DiffUtil.Callback} serves two roles - list indexing, and item diffing. ItemCallback handles
* just the second of these, which allows separation of code that indexes into an array or List
* from the presentation-layer and content specific diffing code.
*
* @param <T> Type of items to compare.
*/
@smarteist
smarteist / liveBlur.dart
Created March 14, 2020 19:13
Its a live blur view for flutter
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// ignore: must_be_immutable
class MovableStackItem extends StatefulWidget {
Widget _child;
double _radius;
Color _color;
@smarteist
smarteist / InfiniteScrollProvider.java
Last active October 4, 2020 06:58
Android recyclerView Infinite Scrolling (Endless Scrolling)
package com.nodano.memo.utils.AppUtils;
import androidx.annotation.NonNull;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.content.res.Resources;