Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

banxi banxi1988

🏠
Working from home
Block or report user

Report or block banxi1988

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@banxi1988
banxi1988 / DeferredCharField.py
Created May 30, 2019
Model 保存之后第延迟初始化的 CharField 字段实现
View DeferredCharField.py
class BasicDeferredDefaultAttribute:
"""
实现支持延迟的 deferred_default 方法
在之前的 Video及Post, asset_id 相关的默认属性生成需要用到 pk, pk 是数据库保存之后自动生成的.
本 Descriptor 实现逻辑是相当于修改版本的 DeferredAttribute. 如果有 pk 并且对应的值为空值.则调用对应的函数读取值并设置.
然后再调用 save.
这个方法要求 Model 在 init 中设置对应的值为 models.DEFERRED
@banxi1988
banxi1988 / p835-image-overlap.go
Created May 13, 2018
leetcode p835 image overlap go solution
View p835-image-overlap.go
package main
import "fmt"
func overlapCount(img1, img2 [][]int) int {
count := 0
for i := 0; i < len(img1); i++ {
for j := 0; j < len(img1[0]); j++ {
if img1[i][j] == 1 && img2[i][j] == 1 {
@banxi1988
banxi1988 / main.py
Created Jan 25, 2017
微信 Android 自动发红包脚本
View main.py
# -*- coding: utf-8 -*-
from com.android.monkeyrunner import MonkeyRunner as mr,MonkeyDevice as md
# Imports the monkeyrunner modules used by this program
# usage : $monkeyrunner main.py
# 下面的坐标是针对 1080 x 1920 的设备的 如果是其他分辨率的设备请自行调整
__author__ = 'banxi'
# Connects to the current device, returning a MonkeyDevice object
print("Waiting for connect...")
device = mr.waitForConnection()
@banxi1988
banxi1988 / print_class_hierachy.m
Last active Mar 17, 2016
Using Objective Runtime API Dump Class hierachy
View print_class_hierachy.m
#import <Foundation/Foundation.h>
@import ObjectiveC;
void print_class_hierachy(Class cls){
printf("%s\n",class_getName(cls));
Class superclass = class_getSuperclass(cls);
int current_level = 0;
while (superclass) {
current_level++;
for (int level = 0; level < current_level;level++) {
View hello_world.asm
%define SYSCALL_WRITE 0x2000004
%define SYSCALL_EXIT 0x2000001
global start
start:
mov rdi, 1
;mov rsi, str
lea rsi, [rel str]
mov rdx, strlen
mov rax, SYSCALL_WRITE
@banxi1988
banxi1988 / CommentView.swift
Created Jul 2, 2015
一个简单的 CommentView ,模仿网易新闻评论框
View CommentView.swift
//
// CommentView.swift
// GuilinLegal
//
// Created by Haizhen Lee on 15/7/2.
// Copyright (c) 2015年 banxi1988 . All rights reserved.
//
import UIKit
@banxi1988
banxi1988 / BuildTreeWithPreorderInorder.swift
Created Jul 2, 2015
Build Binary Tree with Preorder and Inorder
View BuildTreeWithPreorderInorder.swift
func buildTreeWithPreorder(preorder:[Int],andInorder inorder:[Int]) -> TreeNode?{
if preorder.isEmpty || inorder.isEmpty{
return nil
}
var branchList = [TreeNode]()
let root = TreeNode(val: 0)
branchList.append(root)
var preorderArray = [[Int]]()
@banxi1988
banxi1988 / DrawBinaryTree.swift
Last active Aug 29, 2015
Swift 绘制二叉树类
View DrawBinaryTree.swift
import UIKit
class TreeNode{
let val:Int
var left:TreeNode?
var right:TreeNode?
init(val:Int){
self.val = val
}
}
@banxi1988
banxi1988 / Main.java
Created Jun 27, 2015
Java 并发多线程的等待结果完成的问题
View Main.java
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.*;
import java.util.logging.Formatter;
/**
* Created by banxi on 15/6/27.
@banxi1988
banxi1988 / LoadMoreControl.swift
Created Jun 23, 2015
LoadMoreControl like UIRefreshControl
View LoadMoreControl.swift
//
// LoadMoreControl.swift
// GuilinLegal
//
// Created by Haizhen Lee on 15/6/19.
// Copyright (c) 2015年 banxi1988. All rights reserved.
//
import UIKit
You can’t perform that action at this time.