Support
Quality
Security
License
Reuse
kandi has reviewed CC and discovered the below as its top functions. This is intended to give you an instant insight into CC implemented functionality, and help decide if they suit your requirements.
业界首个支持渐进式组件化改造的Android组件化开源框架,支持跨进程调用。Componentize your android project gradually.
目录结构
- cc 组件化框架基础库(主要)
- cc-register CC框架配套的gradle插件(主要)
- cc-settings-2.gradle 组件化开发构建脚本(主要)
- demo demo主程序(调用其它组件,并演示了动态组件的使用)
- demo_base demo公共库(base类、util类、公共Bean等)
- demo_component_a demo组件A
- demo_component_b demo组件B(上方提供下载的apk在打包时local.properties中添加了demo_component_b=true)
- demo_component_jsbridge demo组件(面向组件封装的jsBridge,并演示了如何进行跨进程组件调用)
- demo_component_kt demo组件(kotlin)
- demo_interceptors demo全局拦截器(如果有多个app并且拦截器不同,可以创建多个module给不同app使用)
- cc-settings-demo.gradle 演示如何自定义配置文件,如:添加actionProcessor自动注册的配置
- demo-debug.apk demo安装包(包含demo/demo_component_a/demo_component_kt)
- demo_component_b-debug.apk demo组件B单独运行安装包
创建组件
public class ComponentA implements IComponent {
@Override
public String getName() {
//指定组件的名称
return "ComponentA";
}
@Override
public boolean onCall(CC cc) {
//在此处将组件内部的服务暴露给外部调用
//组件内部的逻辑与外部完全解耦
String actionName = cc.getActionName();
switch (actionName) {
case "showActivity": //响应actionName为"showActivity"的组件调用
//跳转到页面:ActivityA
CCUtil.navigateTo(cc, ActivityA.class);
//返回处理结果给调用方
CC.sendCCResult(cc.getCallId(), CCResult.success());
break;
default:
//其它actionName当前组件暂时不能响应,可以通过如下方式返回状态码为-12的CCResult给调用方
CC.sendCCResult(cc.getCallId(), CCResult.errorUnsupportedActionName());
break;
}
return false;
}
}
调用组件
CC.obtainBuilder("ComponentA")
.setActionName("showActivity")
.build()
.call();
遇到问题怎么办?
CC.enableDebug(true); //普通调试日志,会提示一些错误信息
CC.enableVerboseLog(true); //组件调用的详细过程日志,用于跟踪整个调用过程
Debunking outlook email features with library win32com
out_iter_folder = outlook.GetDefaultFolder(6).Folders['TEST']
Does Comparison Function specified with lambda function in std::sort return bool type?
int x = 5, y = 555;
bool b = x - y;
std::cout << b << std::endl; // Prints 1, means true
-----------------------
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;
int main() {
int number[] = {3, 5, 1, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23};
auto print = [](int n) { cout << n << " "; };
sort(begin(number), end(number), [](int n1, int n2) { return n2 - n1; });
// result: 9 6 1 5 3
for_each(begin(number), end(number), print);
cout << endl;
sort(begin(number), end(number), [](int n1, int n2) { return n1 - n2; });
// result: 3 5 1 6 9
for_each(begin(number), end(number), print);
cout << endl;
return 0;
}
Problem with FULLY_CONNECTED op in TF Lite
static tflite::MicroMutableOpResolver<1> micro_op_resolver;
tflite_status = micro_op_resolver.AddFullyConnected();
Dynamic Library error while using Tensorflow with GPU
# Quick and dirty: with channel specification
conda create -n tf_gpu_env python=3.8
conda activate tf_gpu_env
conda install tensorflow-gpu -c anaconda
conda install cudnn -c conda-forge
conda install cudatoolkit -c anaconda
# Sanity check for validating
# visibility of the GPUs to TF
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
conda env create -f environment.yml
## filename: environment.yml
## Environment File Definition
name: tfgpu_env # tensorflow-gpu environment
channels:
- conda-forge
- anaconda
- default
dependencies:
- python=3.8
## Core Necessities
- numpy # -c conda-forge, anaconda
- pandas # -c conda-forge, anaconda
- tabulate # -c conda-forge, anaconda # necessary for df.to_markdown() in pandas
- scipy # -c conda-forge, anaconda
- matplotlib # -c conda-forge, anaconda
## Jupyter Related
- jupyter # -c anaconda, conda-forge
- jupyterlab # -c anaconda, conda-forge
- jupyter_dashboards # -c conda-forge (see: https://medium.com/plotly/introducing-jupyterdash-811f1f57c02e)
- jupyter_contrib_nbextensions # -c conda-forge
## Progressbar
- tqdm # -c conda-forge, anaconda
## Machine Learning
- tensorflow-gpu # -c anaconda | version: 2.4.1 (linux), 2.3.0 (windows)
# - tensorflow # -c anaconda | version: 2.2.0 (linux), 2.1.0 (windows)
- cudnn # -c conda-forge | version: 8.1.0.77 (linux/windows)
# # -c anaconda | version: 7.6.5 (linux/windows)
- cudatoolkit # -c conda-forge | version: 8.1.0.77 (linux/windows)
# # -c anaconda | version: 11.0.221 (linux/windows)
- scikit-learn # -c conda-forge, anaconda
## Hyperparameter Optimization
- optuna # -c conda-forge # works for pytorch, tf/keras, mxnet, scikit-learn, xgboost, lightgbm
- keras-tuner # -c conda-forge
## Image Processing
- opencv # -c conda-forge, anaconda
- imageio # -c anaconda, conda-forge
## Image Augmentation
- albumentations # -c conda-forge
- imgaug # -c conda-forge
## Code Linting
- pylint # -c conda-forge, anaconda
- autopep8 # -c conda-forge, anaconda
## Installations with pip
- pip:
## Web App Framework
# - Flask-Testing
- streamlit # https://docs.streamlit.io/en/stable/troubleshooting/clean-install.html
# Instruction:
#-----------------------------------------------------------
#
## For an environment installed locally (under: ./.venv)
# mkdir -p .venv && cd .venv
# conda env create --prefix . -f ../environment.yml
## For Updating local environment
# cd .venv
# conda env update --prefix . -f ../environment.yml --prune
#
## For an environment installed globally
## with a name: fav_env
# NOTE: The env-name is stored inside the
# environment.yml file.
# conda env create -f environment.yml
## For Updating global environment from env-file
# conda env update -f ./environment.yml --prune
#
## Update conda itself
# conda update -n base -c defaults conda
#
## Creating a global environment in one-line: py37, py38
# conda create -n py37 python=3.7
# conda create -n py38 python=3.8
#
### In each of the envs: base, py37, py38
# conda install jupyter jupyterlab numpy scipy pandas matplotlib scikit-learn scikit-image tqdm plotly imageio requests pylint autopep8 tabulate opencv
#
## Export a platform independent copy of an environment
# conda env export --from-history > path/to/environment.yml
### Make exports directory (if not present already) and export
# $targetDir = conda_exports
# mkdir ./$targetDir
# conda env export --from-history > ./$targetDir/exported_environment.yml
-----------------------
# Quick and dirty: with channel specification
conda create -n tf_gpu_env python=3.8
conda activate tf_gpu_env
conda install tensorflow-gpu -c anaconda
conda install cudnn -c conda-forge
conda install cudatoolkit -c anaconda
# Sanity check for validating
# visibility of the GPUs to TF
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
conda env create -f environment.yml
## filename: environment.yml
## Environment File Definition
name: tfgpu_env # tensorflow-gpu environment
channels:
- conda-forge
- anaconda
- default
dependencies:
- python=3.8
## Core Necessities
- numpy # -c conda-forge, anaconda
- pandas # -c conda-forge, anaconda
- tabulate # -c conda-forge, anaconda # necessary for df.to_markdown() in pandas
- scipy # -c conda-forge, anaconda
- matplotlib # -c conda-forge, anaconda
## Jupyter Related
- jupyter # -c anaconda, conda-forge
- jupyterlab # -c anaconda, conda-forge
- jupyter_dashboards # -c conda-forge (see: https://medium.com/plotly/introducing-jupyterdash-811f1f57c02e)
- jupyter_contrib_nbextensions # -c conda-forge
## Progressbar
- tqdm # -c conda-forge, anaconda
## Machine Learning
- tensorflow-gpu # -c anaconda | version: 2.4.1 (linux), 2.3.0 (windows)
# - tensorflow # -c anaconda | version: 2.2.0 (linux), 2.1.0 (windows)
- cudnn # -c conda-forge | version: 8.1.0.77 (linux/windows)
# # -c anaconda | version: 7.6.5 (linux/windows)
- cudatoolkit # -c conda-forge | version: 8.1.0.77 (linux/windows)
# # -c anaconda | version: 11.0.221 (linux/windows)
- scikit-learn # -c conda-forge, anaconda
## Hyperparameter Optimization
- optuna # -c conda-forge # works for pytorch, tf/keras, mxnet, scikit-learn, xgboost, lightgbm
- keras-tuner # -c conda-forge
## Image Processing
- opencv # -c conda-forge, anaconda
- imageio # -c anaconda, conda-forge
## Image Augmentation
- albumentations # -c conda-forge
- imgaug # -c conda-forge
## Code Linting
- pylint # -c conda-forge, anaconda
- autopep8 # -c conda-forge, anaconda
## Installations with pip
- pip:
## Web App Framework
# - Flask-Testing
- streamlit # https://docs.streamlit.io/en/stable/troubleshooting/clean-install.html
# Instruction:
#-----------------------------------------------------------
#
## For an environment installed locally (under: ./.venv)
# mkdir -p .venv && cd .venv
# conda env create --prefix . -f ../environment.yml
## For Updating local environment
# cd .venv
# conda env update --prefix . -f ../environment.yml --prune
#
## For an environment installed globally
## with a name: fav_env
# NOTE: The env-name is stored inside the
# environment.yml file.
# conda env create -f environment.yml
## For Updating global environment from env-file
# conda env update -f ./environment.yml --prune
#
## Update conda itself
# conda update -n base -c defaults conda
#
## Creating a global environment in one-line: py37, py38
# conda create -n py37 python=3.7
# conda create -n py38 python=3.8
#
### In each of the envs: base, py37, py38
# conda install jupyter jupyterlab numpy scipy pandas matplotlib scikit-learn scikit-image tqdm plotly imageio requests pylint autopep8 tabulate opencv
#
## Export a platform independent copy of an environment
# conda env export --from-history > path/to/environment.yml
### Make exports directory (if not present already) and export
# $targetDir = conda_exports
# mkdir ./$targetDir
# conda env export --from-history > ./$targetDir/exported_environment.yml
-----------------------
# Quick and dirty: with channel specification
conda create -n tf_gpu_env python=3.8
conda activate tf_gpu_env
conda install tensorflow-gpu -c anaconda
conda install cudnn -c conda-forge
conda install cudatoolkit -c anaconda
# Sanity check for validating
# visibility of the GPUs to TF
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
conda env create -f environment.yml
## filename: environment.yml
## Environment File Definition
name: tfgpu_env # tensorflow-gpu environment
channels:
- conda-forge
- anaconda
- default
dependencies:
- python=3.8
## Core Necessities
- numpy # -c conda-forge, anaconda
- pandas # -c conda-forge, anaconda
- tabulate # -c conda-forge, anaconda # necessary for df.to_markdown() in pandas
- scipy # -c conda-forge, anaconda
- matplotlib # -c conda-forge, anaconda
## Jupyter Related
- jupyter # -c anaconda, conda-forge
- jupyterlab # -c anaconda, conda-forge
- jupyter_dashboards # -c conda-forge (see: https://medium.com/plotly/introducing-jupyterdash-811f1f57c02e)
- jupyter_contrib_nbextensions # -c conda-forge
## Progressbar
- tqdm # -c conda-forge, anaconda
## Machine Learning
- tensorflow-gpu # -c anaconda | version: 2.4.1 (linux), 2.3.0 (windows)
# - tensorflow # -c anaconda | version: 2.2.0 (linux), 2.1.0 (windows)
- cudnn # -c conda-forge | version: 8.1.0.77 (linux/windows)
# # -c anaconda | version: 7.6.5 (linux/windows)
- cudatoolkit # -c conda-forge | version: 8.1.0.77 (linux/windows)
# # -c anaconda | version: 11.0.221 (linux/windows)
- scikit-learn # -c conda-forge, anaconda
## Hyperparameter Optimization
- optuna # -c conda-forge # works for pytorch, tf/keras, mxnet, scikit-learn, xgboost, lightgbm
- keras-tuner # -c conda-forge
## Image Processing
- opencv # -c conda-forge, anaconda
- imageio # -c anaconda, conda-forge
## Image Augmentation
- albumentations # -c conda-forge
- imgaug # -c conda-forge
## Code Linting
- pylint # -c conda-forge, anaconda
- autopep8 # -c conda-forge, anaconda
## Installations with pip
- pip:
## Web App Framework
# - Flask-Testing
- streamlit # https://docs.streamlit.io/en/stable/troubleshooting/clean-install.html
# Instruction:
#-----------------------------------------------------------
#
## For an environment installed locally (under: ./.venv)
# mkdir -p .venv && cd .venv
# conda env create --prefix . -f ../environment.yml
## For Updating local environment
# cd .venv
# conda env update --prefix . -f ../environment.yml --prune
#
## For an environment installed globally
## with a name: fav_env
# NOTE: The env-name is stored inside the
# environment.yml file.
# conda env create -f environment.yml
## For Updating global environment from env-file
# conda env update -f ./environment.yml --prune
#
## Update conda itself
# conda update -n base -c defaults conda
#
## Creating a global environment in one-line: py37, py38
# conda create -n py37 python=3.7
# conda create -n py38 python=3.8
#
### In each of the envs: base, py37, py38
# conda install jupyter jupyterlab numpy scipy pandas matplotlib scikit-learn scikit-image tqdm plotly imageio requests pylint autopep8 tabulate opencv
#
## Export a platform independent copy of an environment
# conda env export --from-history > path/to/environment.yml
### Make exports directory (if not present already) and export
# $targetDir = conda_exports
# mkdir ./$targetDir
# conda env export --from-history > ./$targetDir/exported_environment.yml
-----------------------
# Quick and dirty: with channel specification
conda create -n tf_gpu_env python=3.8
conda activate tf_gpu_env
conda install tensorflow-gpu -c anaconda
conda install cudnn -c conda-forge
conda install cudatoolkit -c anaconda
# Sanity check for validating
# visibility of the GPUs to TF
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
conda env create -f environment.yml
## filename: environment.yml
## Environment File Definition
name: tfgpu_env # tensorflow-gpu environment
channels:
- conda-forge
- anaconda
- default
dependencies:
- python=3.8
## Core Necessities
- numpy # -c conda-forge, anaconda
- pandas # -c conda-forge, anaconda
- tabulate # -c conda-forge, anaconda # necessary for df.to_markdown() in pandas
- scipy # -c conda-forge, anaconda
- matplotlib # -c conda-forge, anaconda
## Jupyter Related
- jupyter # -c anaconda, conda-forge
- jupyterlab # -c anaconda, conda-forge
- jupyter_dashboards # -c conda-forge (see: https://medium.com/plotly/introducing-jupyterdash-811f1f57c02e)
- jupyter_contrib_nbextensions # -c conda-forge
## Progressbar
- tqdm # -c conda-forge, anaconda
## Machine Learning
- tensorflow-gpu # -c anaconda | version: 2.4.1 (linux), 2.3.0 (windows)
# - tensorflow # -c anaconda | version: 2.2.0 (linux), 2.1.0 (windows)
- cudnn # -c conda-forge | version: 8.1.0.77 (linux/windows)
# # -c anaconda | version: 7.6.5 (linux/windows)
- cudatoolkit # -c conda-forge | version: 8.1.0.77 (linux/windows)
# # -c anaconda | version: 11.0.221 (linux/windows)
- scikit-learn # -c conda-forge, anaconda
## Hyperparameter Optimization
- optuna # -c conda-forge # works for pytorch, tf/keras, mxnet, scikit-learn, xgboost, lightgbm
- keras-tuner # -c conda-forge
## Image Processing
- opencv # -c conda-forge, anaconda
- imageio # -c anaconda, conda-forge
## Image Augmentation
- albumentations # -c conda-forge
- imgaug # -c conda-forge
## Code Linting
- pylint # -c conda-forge, anaconda
- autopep8 # -c conda-forge, anaconda
## Installations with pip
- pip:
## Web App Framework
# - Flask-Testing
- streamlit # https://docs.streamlit.io/en/stable/troubleshooting/clean-install.html
# Instruction:
#-----------------------------------------------------------
#
## For an environment installed locally (under: ./.venv)
# mkdir -p .venv && cd .venv
# conda env create --prefix . -f ../environment.yml
## For Updating local environment
# cd .venv
# conda env update --prefix . -f ../environment.yml --prune
#
## For an environment installed globally
## with a name: fav_env
# NOTE: The env-name is stored inside the
# environment.yml file.
# conda env create -f environment.yml
## For Updating global environment from env-file
# conda env update -f ./environment.yml --prune
#
## Update conda itself
# conda update -n base -c defaults conda
#
## Creating a global environment in one-line: py37, py38
# conda create -n py37 python=3.7
# conda create -n py38 python=3.8
#
### In each of the envs: base, py37, py38
# conda install jupyter jupyterlab numpy scipy pandas matplotlib scikit-learn scikit-image tqdm plotly imageio requests pylint autopep8 tabulate opencv
#
## Export a platform independent copy of an environment
# conda env export --from-history > path/to/environment.yml
### Make exports directory (if not present already) and export
# $targetDir = conda_exports
# mkdir ./$targetDir
# conda env export --from-history > ./$targetDir/exported_environment.yml
-----------------------
# Quick and dirty: with channel specification
conda create -n tf_gpu_env python=3.8
conda activate tf_gpu_env
conda install tensorflow-gpu -c anaconda
conda install cudnn -c conda-forge
conda install cudatoolkit -c anaconda
# Sanity check for validating
# visibility of the GPUs to TF
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
conda env create -f environment.yml
## filename: environment.yml
## Environment File Definition
name: tfgpu_env # tensorflow-gpu environment
channels:
- conda-forge
- anaconda
- default
dependencies:
- python=3.8
## Core Necessities
- numpy # -c conda-forge, anaconda
- pandas # -c conda-forge, anaconda
- tabulate # -c conda-forge, anaconda # necessary for df.to_markdown() in pandas
- scipy # -c conda-forge, anaconda
- matplotlib # -c conda-forge, anaconda
## Jupyter Related
- jupyter # -c anaconda, conda-forge
- jupyterlab # -c anaconda, conda-forge
- jupyter_dashboards # -c conda-forge (see: https://medium.com/plotly/introducing-jupyterdash-811f1f57c02e)
- jupyter_contrib_nbextensions # -c conda-forge
## Progressbar
- tqdm # -c conda-forge, anaconda
## Machine Learning
- tensorflow-gpu # -c anaconda | version: 2.4.1 (linux), 2.3.0 (windows)
# - tensorflow # -c anaconda | version: 2.2.0 (linux), 2.1.0 (windows)
- cudnn # -c conda-forge | version: 8.1.0.77 (linux/windows)
# # -c anaconda | version: 7.6.5 (linux/windows)
- cudatoolkit # -c conda-forge | version: 8.1.0.77 (linux/windows)
# # -c anaconda | version: 11.0.221 (linux/windows)
- scikit-learn # -c conda-forge, anaconda
## Hyperparameter Optimization
- optuna # -c conda-forge # works for pytorch, tf/keras, mxnet, scikit-learn, xgboost, lightgbm
- keras-tuner # -c conda-forge
## Image Processing
- opencv # -c conda-forge, anaconda
- imageio # -c anaconda, conda-forge
## Image Augmentation
- albumentations # -c conda-forge
- imgaug # -c conda-forge
## Code Linting
- pylint # -c conda-forge, anaconda
- autopep8 # -c conda-forge, anaconda
## Installations with pip
- pip:
## Web App Framework
# - Flask-Testing
- streamlit # https://docs.streamlit.io/en/stable/troubleshooting/clean-install.html
# Instruction:
#-----------------------------------------------------------
#
## For an environment installed locally (under: ./.venv)
# mkdir -p .venv && cd .venv
# conda env create --prefix . -f ../environment.yml
## For Updating local environment
# cd .venv
# conda env update --prefix . -f ../environment.yml --prune
#
## For an environment installed globally
## with a name: fav_env
# NOTE: The env-name is stored inside the
# environment.yml file.
# conda env create -f environment.yml
## For Updating global environment from env-file
# conda env update -f ./environment.yml --prune
#
## Update conda itself
# conda update -n base -c defaults conda
#
## Creating a global environment in one-line: py37, py38
# conda create -n py37 python=3.7
# conda create -n py38 python=3.8
#
### In each of the envs: base, py37, py38
# conda install jupyter jupyterlab numpy scipy pandas matplotlib scikit-learn scikit-image tqdm plotly imageio requests pylint autopep8 tabulate opencv
#
## Export a platform independent copy of an environment
# conda env export --from-history > path/to/environment.yml
### Make exports directory (if not present already) and export
# $targetDir = conda_exports
# mkdir ./$targetDir
# conda env export --from-history > ./$targetDir/exported_environment.yml
postfix and openJDK 11: "No appropriate protocol (protocol is disabled or cipher suites are inappropriate)"
SSL-Session:
Protocol : TLSv1.2
...
how to sort a map by key when the values are the same?
public static <K extends Comparable<? super K>, V extends Comparable<? super V>> Map<K, V> newSortMapByValue(Map<K, V> map) {
List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<K, V>>() {
@Override
public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) {
// Check if values are the same
if (e1.getValue().equals(e2.getValue()))
// Compare e1 to e2, because A should be first element
return e1.getKey().compareTo(e2.getKey());
else
// Compare e2 to e1, because largest number should be first
return e2.getValue().compareTo(e1.getValue());
}
});
Map<K, V> result = new LinkedHashMap<>();
for (Map.Entry<K, V> entry : list) {
result.put(entry.getKey(), entry.getValue());
}
return result;
}
public static void main(String[] args) {
Map<String, Integer> map = new HashMap<>();
map.put("AA",10);
map.put("CC",5);
map.put("BB",5);
map.put("DD",15);
map.put("ZZ",15);
System.out.println(map);
Map sortedMap = newSortMapByValue(map);
System.out.println(sortedMap);
}
{AA=10, CC=5, BB=5, DD=15, ZZ=15}
{DD=15, ZZ=15, AA=10, BB=5, CC=5}
-----------------------
public static <K extends Comparable<? super K>, V extends Comparable<? super V>> Map<K, V> newSortMapByValue(Map<K, V> map) {
List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<K, V>>() {
@Override
public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) {
// Check if values are the same
if (e1.getValue().equals(e2.getValue()))
// Compare e1 to e2, because A should be first element
return e1.getKey().compareTo(e2.getKey());
else
// Compare e2 to e1, because largest number should be first
return e2.getValue().compareTo(e1.getValue());
}
});
Map<K, V> result = new LinkedHashMap<>();
for (Map.Entry<K, V> entry : list) {
result.put(entry.getKey(), entry.getValue());
}
return result;
}
public static void main(String[] args) {
Map<String, Integer> map = new HashMap<>();
map.put("AA",10);
map.put("CC",5);
map.put("BB",5);
map.put("DD",15);
map.put("ZZ",15);
System.out.println(map);
Map sortedMap = newSortMapByValue(map);
System.out.println(sortedMap);
}
{AA=10, CC=5, BB=5, DD=15, ZZ=15}
{DD=15, ZZ=15, AA=10, BB=5, CC=5}
-----------------------
public static <K extends Comparable<? super K>, V extends Comparable<? super V>> Map<K, V> newSortMapByValue(Map<K, V> map) {
List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<K, V>>() {
@Override
public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) {
// Check if values are the same
if (e1.getValue().equals(e2.getValue()))
// Compare e1 to e2, because A should be first element
return e1.getKey().compareTo(e2.getKey());
else
// Compare e2 to e1, because largest number should be first
return e2.getValue().compareTo(e1.getValue());
}
});
Map<K, V> result = new LinkedHashMap<>();
for (Map.Entry<K, V> entry : list) {
result.put(entry.getKey(), entry.getValue());
}
return result;
}
public static void main(String[] args) {
Map<String, Integer> map = new HashMap<>();
map.put("AA",10);
map.put("CC",5);
map.put("BB",5);
map.put("DD",15);
map.put("ZZ",15);
System.out.println(map);
Map sortedMap = newSortMapByValue(map);
System.out.println(sortedMap);
}
{AA=10, CC=5, BB=5, DD=15, ZZ=15}
{DD=15, ZZ=15, AA=10, BB=5, CC=5}
C++ Optimize Memory Read Speed
uint64_t total = 0;
for (auto cn = nums.begin(); cn < nums.end(); cn += 4)
{
total += cn[0];
total += cn[1];
total += cn[2];
total += cn[3];
}
uint64_t total = 0;
for (auto cn = nums.begin(); cn < nums.end(); cn += 4)
{
const uint64 n0 = cn[0];
const uint64 n1 = cn[1];
const uint64 n2 = cn[2];
const uint64 n3 = cn[3];
total += n0;
total += n1;
total += n2;
total += n3;
}
-----------------------
uint64_t total = 0;
for (auto cn = nums.begin(); cn < nums.end(); cn += 4)
{
total += cn[0];
total += cn[1];
total += cn[2];
total += cn[3];
}
uint64_t total = 0;
for (auto cn = nums.begin(); cn < nums.end(); cn += 4)
{
const uint64 n0 = cn[0];
const uint64 n1 = cn[1];
const uint64 n2 = cn[2];
const uint64 n3 = cn[3];
total += n0;
total += n1;
total += n2;
total += n3;
}
-----------------------
const std::size_t GB = 1024 * 1024 * 1024;
std::vector<int> nums(4 * GB);
std::generate(std::begin(nums), std::end(nums), [](){ return rand() % 1024; });
//...
const auto sum = std::accumulate(std::begin(nums), std::end(nums), 0);
How to connect to IBM MQ deployed to OpenShift?
kind: Service
apiVersion: v1
metadata:
name: ibm-mq
spec:
type: NodePort
ports:
- port: 1414
targetPort: 1414
nodePort: 30001
selector:
app: ibm-mq
-----------------------
com.ibm.mq.cfg.SSL.OutboundSNI=HOSTNAME
System.setProperty("com.ibm.mq.cfg.SSL.OutboundSNI","HOSTNAME");
-----------------------
com.ibm.mq.cfg.SSL.OutboundSNI=HOSTNAME
System.setProperty("com.ibm.mq.cfg.SSL.OutboundSNI","HOSTNAME");
Google App Script How to add a specific CC Email when sending automated Emails
MailApp.sendEmail(
recipient,
subject,
body,
{attachments: [newFile],
cc: "example@test.com"})
create a logical column for whether a row contains a string in any column
library(tidyverse)
df %>%
mutate(flag = pmap_lgl(., ~"aa" %in% str_to_lower(c(...))))
df %>%
rowwise() %>%
mutate(flag = "aa" %in% str_to_lower(c_across(everything())))
setDT(df)[, flag := transpose(.SD) %>% map_lgl(~"aa" %in% str_to_lower(.x))]
-----------------------
library(tidyverse)
df %>%
mutate(flag = pmap_lgl(., ~"aa" %in% str_to_lower(c(...))))
df %>%
rowwise() %>%
mutate(flag = "aa" %in% str_to_lower(c_across(everything())))
setDT(df)[, flag := transpose(.SD) %>% map_lgl(~"aa" %in% str_to_lower(.x))]
-----------------------
library(tidyverse)
df %>%
mutate(flag = pmap_lgl(., ~"aa" %in% str_to_lower(c(...))))
df %>%
rowwise() %>%
mutate(flag = "aa" %in% str_to_lower(c_across(everything())))
setDT(df)[, flag := transpose(.SD) %>% map_lgl(~"aa" %in% str_to_lower(.x))]
-----------------------
library(dplyr)
df %>%
rowwise() %>%
mutate(xyz = +any(grepl("aa", cur_data(), ignore.case = TRUE)))
# A tibble: 4 x 4
# Rowwise:
x y z xyz
<chr> <chr> <chr> <int>
1 cc ee AA 1
2 aa dd gg 1
3 BB ff bb 0
4 dd gg dd 0
Reduce(`+`, apply(df, 1, \(x) +(grepl("aa", x, , ignore.case = TRUE))) |>
t() |>
as.data.frame()) -> df$xyz
# A tibble: 4 x 4
# Rowwise:
x y z xyz
<chr> <chr> <chr> <int>
1 cc ee AA 1
2 aa dd gg 1
3 BB ff bb 0
4 dd gg dd 0
-----------------------
library(dplyr)
df %>%
rowwise() %>%
mutate(xyz = +any(grepl("aa", cur_data(), ignore.case = TRUE)))
# A tibble: 4 x 4
# Rowwise:
x y z xyz
<chr> <chr> <chr> <int>
1 cc ee AA 1
2 aa dd gg 1
3 BB ff bb 0
4 dd gg dd 0
Reduce(`+`, apply(df, 1, \(x) +(grepl("aa", x, , ignore.case = TRUE))) |>
t() |>
as.data.frame()) -> df$xyz
# A tibble: 4 x 4
# Rowwise:
x y z xyz
<chr> <chr> <chr> <int>
1 cc ee AA 1
2 aa dd gg 1
3 BB ff bb 0
4 dd gg dd 0
-----------------------
library(dplyr)
library(stringr)
df %>%
mutate(xyz = +(if_any(everything(),
~ str_detect(., regex('aa', ignore_case = TRUE)))))
# A tibble: 4 x 4
x y z xyz
<chr> <chr> <chr> <int>
1 cc ee AA 1
2 aa dd gg 1
3 BB ff bb 0
4 dd gg dd 0
-----------------------
library(dplyr)
library(stringr)
df %>%
mutate(xyz = +(if_any(everything(),
~ str_detect(., regex('aa', ignore_case = TRUE)))))
# A tibble: 4 x 4
x y z xyz
<chr> <chr> <chr> <int>
1 cc ee AA 1
2 aa dd gg 1
3 BB ff bb 0
4 dd gg dd 0
QUESTION
Debunking outlook email features with library win32com
Asked 2021-Jun-16 at 03:53I found ways to check with python using library win32com for outlook the following attributes for any given email.
import win32com.client as client
import win32com
outlook = client.Dispatch("Outlook.Application").GetNamespace('MAPI')
main_account = outlook.Folders.Item(1)
out_iter_folder = main_account.Folders['Inbox'].Folders['TEST']
if out_iter_folder.Items.Count > 0:
for i in reversed(range(0,item_count)):
message = out_iter_folder.Items[i]
message = out_iter_folder.Items[i]
Email subject:
message.Subject
Email sender:
mesage.SenderEmailAddress
Email categories/flag:
message.Categories
Email move from a folder to another:
message.Move
I would like to access for any given email:
receiver list (how would that work if I have more than one)?
cc list (" ")
Is there any other way to update the category on an email other than moving this email from a folder to another? I am working on a batch process and this moving in/out is slowing things.
When the email is sent from an email address "on behalf" of another email address how can I access the email on behalf?
ANSWER
Answered 2021-Jun-16 at 03:53MailItem.Recipients
collection.Recipient.Type
property equal olCC
( =2)MailItem.Categpries
property. Don't forget to call MailItem.Save
MailItem.SenderEmailAddress
. For the sent on behalf of address, read the PR_SENT_REPRESENTING_EMAIL_ADDRESS
MAPI property. Access it using MailItem.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0065001F")
In general, take a look at various Outlook object using OutlookSpy to familiarize yourself with the Outlook Object Model.
Also keep in mind that to access a subfolder of the Inbox folder, it is better to use something like
out_iter_folder = outlook.GetDefaultFolder(6).Folders['TEST']
where 6 is olFolderInbox
constant.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit