Skip to content

Instantly share code, notes, and snippets.

View luanvuhlu's full-sized avatar

luan vu luanvuhlu

View GitHub Profile
function ab2str(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf));
}
function ajaxDownload(url, params, successCallback, errorCallback){
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
if (this.status === 200) {
var type = xhr.getResponseHeader('Content-Type');
adb logcat *:S ReactNative:V ReactNativeJS:V
@luanvuhlu
luanvuhlu / chiasenhac.py
Created October 6, 2017 11:10 — forked from vietvudanh/chiasenhac.py
download album from chiasenhac
# Fucking scripts to download from chiasenhac, whole album!
import os
from bs4 import BeautifulSoup
import requests
from multiprocessing import Pool
NUMBER_PROCESS = 8
MUSIC_QUALITY = '320'
@luanvuhlu
luanvuhlu / chiasenhac-dowloader.py
Created October 6, 2017 11:20 — forked from cuongnv23/chiasenhac-dowloader.py
Python script to download mp3 files from chiasenhac.com
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import re
import argparse
import errno
import requests
from bs4 import BeautifulSoup
@luanvuhlu
luanvuhlu / install-rsync-macosx.sh
Last active November 9, 2017 07:35
How to install & compile rsync on Mac OSX
#Compile rsync 3.1.2
#Follow these instructions in Terminal on both the client and server to download and compile rsync 3.1.2:
#Download and unarchive rsync and its patches
curl -O http://rsync.samba.org/ftp/rsync/src/rsync-3.1.2.tar.gz
tar -xzvf rsync-3.1.2.tar.gz
rm rsync-3.1.2.tar.gz
curl -O http://rsync.samba.org/ftp/rsync/src/rsync-patches-3.1.2.tar.gz
tar -xzvf rsync-patches-3.1.2.tar.gz
@luanvuhlu
luanvuhlu / isach.py
Created November 24, 2017 09:06
Download books
import urllib2
from bs4 import BeautifulSoup
BASE_URL = 'http://isach.info/mobile/story.php?story=tru_tien_2__tieu_dinh&chapter='
CHAPTER_START = 2
def main():
chapters = get_chapters_arr()
public class AppZip
{
List<String> fileList;
private static final String OUTPUT_ZIP_FILE = "C:\\MyFile.zip";
private static final String SOURCE_FOLDER = "C:\\testzip";
AppZip(){
fileList = new ArrayList<String>();
}
@luanvuhlu
luanvuhlu / gist:7996857b5a5f8657df08fb297ce0d10c
Last active December 31, 2017 09:41
React native: Display photo with ratio
Image.getSize(this.props.image, (srcWidth, srcHeight) => {
const maxHeight = Dimensions.get('window').height;
const maxWidth = Dimensions.get('window').width;
const ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight);
this.setState({ width: srcWidth * ratio, height: srcHeight * ratio });
}, error => {
console.log('error:', error);
});
@luanvuhlu
luanvuhlu / gist:086b444385ead82e1d397b5fe75463d3
Created December 31, 2017 09:42
React Native: Hide status bar
componentDidMount() {
StatusBar.setHidden(true);
}
var a = () => Promise.resolve(1);
var b = () => Promise.reject(new Error(2));
var c = () => Promise.resolve(3);
Promise.all([a(), b(), c()].map(p => p.catch(e => e)))
.then(results => console.log(results)) // 1,Error: 2,3
.catch(e => console.log(e));
var console = { log: msg => div.innerHTML += msg + "<br>"};