Skip to content

Instantly share code, notes, and snippets.

View DrustZ's full-sized avatar
🌻
🥇

Mingrui Zhang DrustZ

🌻
🥇
View GitHub Profile
UIImage* resizeImageToSize(UIImage* image, CGSize size)
{
UIGraphicsBeginImageContext(size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
//Account for flipped coordspace
CGContextTranslateCTM(ctx, 0.0, size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
# -*- coding: utf-8 -*-
from multiprocessing.dummy import Pool as ThreadPool
from lxml import html
import requests
import string
THREADS=10
punctuation = '!"#$%&\'()*+,-./:;<=>?[\\]^_`{|}~'
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
/*****************************************************************
LSM9DS0_AHRS.ino
SFE_LSM9DS0 Library AHRS Data Fusion Example Code
Jim Lindblom @ SparkFun Electronics
Original Creation Date: February 18, 2014
https://github.com/sparkfun/LSM9DS0_Breakout
Modified by Kris Winer, April 4, 2014
The LSM9DS0 is a versatile 9DOF sensor. It has a built-in
@DrustZ
DrustZ / pvanet.py
Last active January 20, 2018 07:59
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
def debug(debug_open, x, layername):
if debug_open:
print x.size(), 'after', layername
class PVANet(nn.Module):
@DrustZ
DrustZ / emoji_server.py
Created June 4, 2018 06:15
Simple server with deepemoji
# -*- coding: utf-8 -*-
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
# -*- coding: utf-8 -*-
import example_helper
import json
import csv
import urllib
import numpy as np
from deepmoji.sentence_tokenizer import SentenceTokenizer
from deepmoji.model_def import deepmoji_emojis
from deepmoji.global_variables import PRETRAINED_PATH, VOCAB_PATH
@DrustZ
DrustZ / WagnerFischer.js
Last active July 3, 2018 02:49
Wagner-Fischer Levenshtein distance, now with a means to generate all possible optimal alignments. (js version)
//A library adopted from Python version Wagner & Fischer algorithm:
//url: https://gist.github.com/kylebgorman/8034009
//for more information, please go to the original library
function INSERTION(A, cost=1){
return cost;
}
function DELETION(A, cost=1){
return cost;
}
@DrustZ
DrustZ / AudioMediaOperation.java
Created April 25, 2019 08:10
Android audio operations. WAV/raw to raw/wav; merge wav files.
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
@DrustZ
DrustZ / Simulation.cs
Created May 15, 2019 23:44
Simulate keyboard and mouse input in WPF (similar to sendkeys in winform)
using System;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Windows.Input;
namespace Demo
[
{
"link": "https://m.weibo.cn/detail/4661384946125143",
"Time": "Wed Jul 21 13:10:38 +0800 2021",
"address": "河南省郑州市崔庙镇",
"lng": 113.330031,
"lat": 34.64436,
"post": "郑州#河南暴雨互助# 📢#河南暴雨救援# 求助帖❗️❗️❗️被困求救地址:荥阳市崔庙镇王宗店村情况:房子塌了,一对母女被困塌房里,现在救援队过不去,路面双向被冲断,母女还被困两个小时了,没有办法,寻求社会帮助,只能皮艇支援!!!!!!☎️:13653820035 ",
"urgent": "",
"category": "",