Skip to content

Instantly share code, notes, and snippets.

@rockswang
rockswang / faceScore.js
Created October 13, 2020 10:33
微软小冰颜值鉴定接口(Node.js版)
const _ = require('lodash')
const { sendMsg, Recent, localPic } = require('../qq_api')
const { rp, UA, auraCdChk, num } = require('../utils')
module.exports = {
name: '颜值鉴定',
tags: ['exec', 'aura', 'group', 'cd'],
keywords: ['颜值', '好看吗'],
usage: ['(发照片后) [botNick_]颜值鉴定', '我好看吗?', '@某用户 好看吗'],
@rockswang
rockswang / Json.java
Created August 6, 2014 09:14
A JSONObject/JSONArray wrapper, simplifies JSON usage in android & java (json.org api)
package com.roxstudio.utils;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
- (BOOL)stringContainsEmoji:(NSString *)string {
__block BOOL returnValue = NO;
[string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
const unichar hs = [substring characterAtIndex:0];
// surrogate pair
if (0xd800 <= hs && hs <= 0xdbff) {
if (substring.length > 1) {
const unichar ls = [substring characterAtIndex:1];
@rockswang
rockswang / gist:8897953
Created February 9, 2014 11:44
android 单位之间的换算 TypedValue 我们知道 TypedValue 中有个applyDimension(int unit, float value, DisplayMetricsmetrics) 方法,通过这个方法可以将各种单位装换成像素,现在就来看看这个方法是如何实现的,也就知道了他们之间的转换关系,首先看源码:
/**
* Converts an unpacked complex data value holding a dimension to its final floating
* point value. The two parameters <var>unit</var> and <var>value</var>
* are as in {@link #TYPE_DIMENSION}.
*
* @param unit The unit to convert from.
* @param value The value to apply the unit to.
* @param metrics Current display metrics to use in the conversion --
* supplies display density and scaling information.
package nl.stroep.games.components;
import flambe.Component;
import nape.space.Space;
/**
* @author Mark Knol [blog.stroep.nl]
*/
class NapeDebugView extends Component
{
private var _space:Space;
package ;
class DevTools {
macro static public function measure(e, ?msg:String) {
if (msg == null)
msg = haxe.macro.ExprTools.toString(e);
return macro @:pos(e.pos) {
var start = haxe.Timer.stamp(),
result = [$e];//wrapping in the array skews the result a bit, but avoids issues with Void
var duration = haxe.Timer.stamp() - start;
@rockswang
rockswang / merge_audio.bat
Last active December 28, 2015 09:28
Use mp3 audio in mobile safari: Thread: https://groups.google.com/forum/#!topic/haxelang/cO1asB4ggUs Hi again I've been trying the web audio api via an extern class to get access to a js API with the functions I need to load and play the sounds. That was easy... But I got the same problem as with the openfl API. Sounds would not autoplay on iOS …
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
REM Batch file to create Audio SpriteSheet
REM Author: Glantucan
REM some var definitions (Subfolder must end with a \)
SET subfolder=seasons\
SET rootPath=%CD%\
SET assetsPath=%rootPath%assets\audio\%subfolder%
SET libPath=%rootPath%lib\audio\%subfolder%
@rockswang
rockswang / I18n.hx
Created June 21, 2013 09:36
I18n.hx porting to Haxe3 encountered compiling error "Invalid field access".
package com.roxstudio.i18n;
#if !macro
import nme.Assets;
#end
#if macro