Skip to content

Instantly share code, notes, and snippets.

View alfredhot's full-sized avatar
🖥️
I may be slow to respond.

Alfred.D.Cui alfredhot

🖥️
I may be slow to respond.
View GitHub Profile
@alfredhot
alfredhot / ContinuedEditTextInput.java
Last active August 29, 2015 14:27
[android] 连续的EditText输入连续的内容 片段
for(int i=0; i<ET_COUNT ; i++){
EditText et = et_pincode[i];
final int index = i;
et.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
EditText et = (EditText)v;
if(keyCode==KeyEvent.KEYCODE_DEL){
@alfredhot
alfredhot / AutoSplitEditText.java
Last active August 29, 2015 14:27
[android] 自动分段的EditText 部分代码 待整理
EditText edit_pincode = (EditText) findViewById(R.id.layout_input_pincode);
EditText edit_pincode_date = (EditText) findViewById(R.id.btn_input_pincode_date);
edit_pincode.setOnClickListener(pincodeOnClickListener);
edit_pincode_date.setOnClickListener(dateOnClickListener);
edit_pincode.setOnFocusChangeListener(pincodeOnFocusListener);
edit_pincode_date.setOnFocusChangeListener(dateOnFocusListener);
edit_pincode.addTextChangedListener(pincodeWatcher);
edit_pincode_date.addTextChangedListener(dateWatcher);
@alfredhot
alfredhot / EditTextSelectable.java
Created August 18, 2015 04:48
[android] 문자선택 listener가 포함된 EditText를 만들기
package com.alfroid.android.util.widget;
import android.content.Context;
import android.text.Editable;
import android.util.AttributeSet;
import android.widget.EditText;
public class EditTextSelectable extends EditText{
@alfredhot
alfredhot / TextViewCountAnimation.java
Created August 21, 2015 09:41
[andoird] 숫자 카운트하는 애니메이션을 실행하는 코드
ValueAnimator animator = new ValueAnimator();
int cashBalance = Integer.valueOf(mCashBalanceResObject.cashBalance);
animator.setObjectValues(0,cashBalance);
animator.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
mACommon.doAutoResizeTextCash(R.id.layout_cash_charge_title,String.valueOf(animation.getAnimatedValue()));
}
});
animator.setEvaluator(new TypeEvaluator<Integer>() {
@alfredhot
alfredhot / WindowrequestAnimFrame
Created November 7, 2016 05:58
Javascript上性能消耗十分少的逐帧动画方式
window.requestAnimFrame = ( ->
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
( callback ) ->
window.setTimeout(callback, 1000 / 60) #定义每秒执行60次动画
)();
//========================================================================
@alfredhot
alfredhot / UseSweetAlert2.coffee
Created December 2, 2016 06:04
JavaScript 에서 sweetalert 을 쉽게 사용하기
$rootScope.showAlert= (content, type, fn) ->
if fn is null
fn = ->
null
if type is null
swal $rootScope.popup.title, content
.then fn
else
swal $rootScope.popup.title, content, type
.then fn
@alfredhot
alfredhot / 0_reuse_code.js
Created January 10, 2017 08:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@alfredhot
alfredhot / full-height.sass
Created May 17, 2017 02:13
[full-height]full-height-element(div) #tags: CSS, layout
.main-left
position: absolute
left: 0
top: 0
height: 100%
width: $base-width
background-color: #3d3c3c
color: #e1e1e1
&:before
content: ''
db.influencers.aggregate([
{
$match: {ac: 1}
},
{
$project: {_id: 1}
},
{
$lookup: {
from: 'media',
@alfredhot
alfredhot / repare_gray_files_in_harddist.sh
Created July 17, 2019 06:16
Clear Mac finder attribute
#!/bin/sh
echo `xattr -d -r com.apple.FinderInfo ./*`