This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cv = document.getElementById('cv'); | |
var c = cv.getContext('2d'); | |
var txtDiv = document.getElementById('txt'); | |
var fileBtn = document.getElementById("up-button"); | |
var img = new Image(); | |
img.src = 'a.jpg'; | |
img.onload = init; // 图片加载完开始转换 | |
fileBtn.onchange = getImg; | |
// 根据灰度生成相应字符 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var githubList = [ | |
{ | |
name:'系统基础库', | |
list: [ | |
{name:'Category/Util', | |
list: [ | |
{name:'sstoolkit', owner:'soffes', desc:'一套Category类型的库,附带很多自定义控件 功能不错~'}, | |
{name:'BlocksKit', owner:'pandamonia', desc:'将Block风格带入UIKit和Founcation'}, | |
{name:'cocoa-helpers', owner:'enormego', desc:'一些Cocoa的扩展 2年前的工程'}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Bitmap loadBitmapFromView(View v) { | |
int w = v.getWidth(); | |
int h = v.getHeight(); | |
Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); | |
Canvas c = new Canvas(bmp); | |
// c.drawColor(Color.WHITE);//如果不设置canvas画布为白色,则生成透明 | |
v.layout(0, 0, w, h); | |
v.draw(c); | |
return bmp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 参考https://medium.com/@BladeCoder/kotlin-singletons-with-argument-194ef06edd9e | |
*/ | |
open class SingletonHolder<out T, in A>(creator: (A) -> T) { | |
private var creator: ((A) -> T)? = creator | |
@Volatile private var instance: T? = null | |
fun getInstance(arg: A): T { | |
val i = instance | |
if (i != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import java.lang.reflect.Method; | |
public class ReflectApplication { | |
private static Context CONTEXT; | |
private ReflectApplication() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.app.Application; | |
import android.os.Bundle; | |
/** | |
* 应用前后台状态监听帮助类,仅在Application中使用 | |
* 参考:https://blog.csdn.net/bzlj2912009596/article/details/80073396 | |
*/ | |
public class AppFrontBackHelper { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import java.lang.ref.WeakReference; | |
import java.util.Stack; | |
/** | |
* 获取当前的activity | |
* 两种思路: 1.弱引用持有当前activity | |
* 2.使用栈维护所有的activity,然后获取栈顶的activity | |
* 参考:https://www.jianshu.com/p/77f754446009 |