Skip to content

Instantly share code, notes, and snippets.

View huaigu's full-sized avatar

Alex Wang huaigu

View GitHub Profile
@huaigu
huaigu / UIImageView+Webcache_Animation.c
Created December 27, 2016 07:10 — forked from cherifya/UIImageView+Webcache_Animation.c
Improve SDWebImage library with support for a UIActivityIndicator and optional image transition. The transition animation is a simple fade-in.
//
// UIImageView+Webcache_Animation.m
// Tubesmix
//
// Created by Cherif YAYA on 17/03/13.
// Copyright (c) 2013 Cherif YAYA. All rights reserved.
//
#import "UIImageView+Webcache_Animation.h"
@huaigu
huaigu / MBProgressHUD+Rx.swift
Created December 27, 2016 09:12 — forked from zzdjk6/MBProgressHUD+Rx.swift
Convenient way to show MBProgressHUD while RxSwift signal executing
extension ObservableType {
func showHUDWhileExecuting(view: UIView) -> RxSwift.Observable<Self.E> {
dispatch_async(dispatch_get_main_queue()) {
MBProgressHUD.showHUDAddedTo(view, animated: true)
}
return self.doOn { (_) in
dispatch_async(dispatch_get_main_queue()) {
@huaigu
huaigu / MBProgressHUD+Additions.h
Created December 27, 2016 09:16 — forked from yas375/MBProgressHUD+Additions.h
Migrating from SVProgressHUD to MBProgressHUD. We needed to expose `hasFinished` from MBProgressHUD's implementation and have added tests to make sure we remember about it when we upgrade MBProgressHUD. We didn't use Swift's default values and instead have added multiple `showStatus...` because we need to use it from Objective-C.
//
// MBProgressHUD+Additions.h
// Caremobile
//
// Created by Victor Ilyukevich on 4/13/16.
// Copyright © 2016 Care Zone Inc. All rights reserved.
//
@interface MBProgressHUD (Additions)
- (BOOL)hasFinished;
@huaigu
huaigu / post-receive
Created June 8, 2017 05:42 — forked from lemiorhan/post-receive
Post-receive hook to deploy the code being pushed to production branch to a specific folder
#!/bin/bash
target_branch="production"
working_tree="PATH_TO_DEPLOY"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then
@huaigu
huaigu / js
Created July 17, 2017 07:28
Use axios to refresh authorization token
axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
const originalRequest = error.config;
if (error.response.status === 401 && !originalRequest._retry) {
originalRequest._retry = true;
@huaigu
huaigu / keybase.md
Created September 10, 2019 03:55
keybase

Keybase proof

I hereby claim:

  • I am huaigu on github.
  • I am huaigu (https://keybase.io/huaigu) on keybase.
  • I have a public key ASCKSd8CeUX5SBVBJye1blJAmZ-Rt6ktRRWj2CmE3SblQwo

To claim this, I am signing this object:

@huaigu
huaigu / safer_farming.md
Created August 19, 2020 14:52
Some minimum safety measures to take when farming new or unaudited pools

DISCLAIMER: I am not a security expert, this is nowhere near a substitute for a real professional audit, even following all of these steps you are at extreme risk whenever touching one of these pools. Do not put more than you can lose into any ETH smart contract, let alone an unaudited untested one. And obviously, needless to say none of this is financial advice. SHRIMP is just one of these pools that I am using as an example, this is not an audit nor a recommendation to go farm it.

In this guide, I will discuss some steps you can take to protect yourself from falling victim to farming pool scams. Note that this guide is about the safety of your deposits, not about the safety of principal in new tokens or in new token liquidity pools.

The first important thing you need to do is find the contract you will be interacting with. Sometimes this is easier than others. Often the best technique is to find the token you will be farming on etherscan, then look at the top holders. For most farms, the farming contract

@huaigu
huaigu / keybase.md
Created January 25, 2021 04:48
Keybase verification

Keybase proof

I hereby claim:

  • I am huaigu on github.
  • I am coderbojack (https://keybase.io/coderbojack) on keybase.
  • I have a public key ASCXZjh88XxCqcLOj-ovdyNYKy-2TaeUwRDCXeKUionMFwo

To claim this, I am signing this object:

@huaigu
huaigu / BABYCAKE.sol
Created February 9, 2022 09:52 — forked from CryptoInvestorPro/BABYCAKE.sol
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.6.2+commit.bacdbe57.js&optimize=true&runs=200&gist=
// SPDX-License-Identifier: MIT
//
// $BabyCake proposes an innovative feature in its contract.
//
// DIVIDEND YIELD PAID IN CAKE! With the auto-claim feature,
// simply hold$BabyCake and you'll receive CAKE automatically in your wallet.
//
// Hold Baby Cake and get rewarded in Cake on every transaction!
//
@huaigu
huaigu / main.py
Last active March 15, 2022 09:54
Convert PDF to Images with PyMuPDF
# pip install Pillow
# pip install PyMuPDF
# For windows, use "pip install PyMuPDF==1.18.19" if error occurred
def export_with_pymupdf(filepath):
import fitz
from PIL import Image
if not filepath or not os.path.isfile(filepath):
return