Skip to content

Instantly share code, notes, and snippets.

@suanmiao
suanmiao / oci_download_multi_threads.py
Last active December 13, 2023 22:01
oci_download_multi_threads.py
import oci
import os
import sys
import concurrent.futures
def download_file(object_storage_client, namespace, bucket_name, object_name, local_directory):
file_name = object_name.split('/')[-1]
if file_name: # Skip directories
local_file_path = os.path.join(local_directory, file_name)
get_obj = object_storage_client.get_object(namespace, bucket_name, object_name)
@suanmiao
suanmiao / oci_download.py
Created December 13, 2023 19:39
oci_download.py
import oci
import os
import sys
def download_directory(object_storage_client, namespace, bucket_name, oci_prefix, local_directory):
# Create local directory if it does not exist
if not os.path.exists(local_directory):
os.makedirs(local_directory)
# List all objects in the OCI directory
@suanmiao
suanmiao / data_cleaning_mpt_7b_chat_experiment.py
Created October 23, 2023 22:42
Data cleaning code for MPT-7B-Chat
#Please note that the code below is specifically optimized for MPT-7B-Chat model on the Databricks Documentation dataset, modifications may be required for other models or datasets.
import re
from html import unescape
# Keep all HTML tags
# No code is needed as we are keeping all HTML tags
# Replace multiple newlines or multiple empty lines with one newline
private static ResponseHolder httpUploadFile(String targetUrl,
String filePath, ArrayList<NameValuePair> headerArrayList,
ArrayList<NameValuePair> paramsArrayList) {
// about url
for (int i = 0; i < paramsArrayList.size(); i++) {
NameValuePair nowPair = paramsArrayList.get(i);
if (i == 0) {
targetUrl += ("?" + nowPair.getName() + "=" + nowPair
.getValue());
@suanmiao
suanmiao / WavingView.java
Created April 10, 2015 05:22
WavingView
public class WavingView extends View
implements
ValueAnimator.AnimatorUpdateListener,
Animator.AnimatorListener {
private int maxWaveRadius, minWaveRadius;
private int centerX, centerY;
private final long WAVE_SPREAD_DURATION = 2000;
private final long WAVE_DELAY_DURATION = 1000;
private final int WAVE_AMOUNT = 4;
package com.wandoujia.roshan.notification;
import java.util.List;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.PendingIntent;
import android.content.Context;
import android.media.AudioManager;
import android.media.RemoteController;
@suanmiao
suanmiao / Code Refrence
Created January 11, 2015 14:14
WeClient API Code Reference
/***
* 1.这是半年前的代码,因此有些Url有冗余,实现部分也有很冗余,主要参考的是url和实现部分的参数;
* 2.注意base url和path的概念
* 3.
***/
//URL
public static final String URL_LOGIN = "https://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN";
public static final String URL_GET_MESSAGE_LIST = "https://mp.weixin.qq.com/cgi-bin/message";
public static final String URL_GET_NEW_MESSAGE_COUNT = "https://mp.weixin.qq.com/cgi-bin/getnewmsgnum";
@suanmiao
suanmiao / WechatHackAPI.markdown
Created June 13, 2014 15:58
WeChat Hack API
@suanmiao
suanmiao / WechatHack.markdown
Created June 8, 2014 14:56
Wechat Hack API
@suanmiao
suanmiao / gist:0c8699e0d07c7c1880fd
Created June 6, 2014 12:20
BTC Mining Calculator

BitCoin Mining Calcuator

  • Code:

      float price =nowBean.getPrice();  
      float elecPriceFloat = nowBean.getElecPrice(); 
      float deviceCostFloat = nowBean.getDeviceCost();
      float currency = nowBean.getCurrency();
      String unitString = "";