Skip to content

Instantly share code, notes, and snippets.

View vuthaihoc's full-sized avatar
🤒
ke ke ặc ặc

Stupid Dev vuthaihoc

🤒
ke ke ặc ặc
View GitHub Profile
@vuthaihoc
vuthaihoc / pdftitle.py
Last active May 25, 2021 01:40 — forked from TestItOnlyOnce/pdftitle.py
Rename pdf files to their content's titles (for Python 3; with wildcard support; default rename all pdfs)
#!/usr/bin/env python
"""
Extracts title from PDF files (Python 3).
Depends on: pdf, pyPDF2, PDFMiner3k, unidecode.
Usage:
pdftitle -d tmp --rename *.pdf{}
"""
from io import StringIO
@vuthaihoc
vuthaihoc / viewer.html
Created November 9, 2019 17:10 — forked from larsneo/viewer.html
Pinch zoom implementation for PDF.js viewer
<!-- Goes into viewer.html just before ending </body> -->
<script>
let pinchZoomEnabled = false;
function enablePinchZoom(pdfViewer) {
let startX = 0, startY = 0;
let initialPinchDistance = 0;
let pinchScale = 1;
const viewer = document.getElementById("viewer");
const container = document.getElementById("viewerContainer");
const reset = () => { startX = startY = initialPinchDistance = 0; pinchScale = 1; };
@vuthaihoc
vuthaihoc / questions.md
Last active July 12, 2019 04:11 — forked from amitmerchant1990/questions.md
Questions
1) What is Asynchronous call?
  • A function that enables processing to continue without waiting for function to return the value.
2) What is Full-text search ?
  • In this we can match a word or phrase in multiple columns and fetch rows accordingly. The Full-text searches are supported for MyISAM tables only ex. : SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('database');
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@vuthaihoc
vuthaihoc / test.php
Last active September 17, 2018 17:36
Tiny Problems
- Problem 1: Cho mảng nhiều chiều
[
a => 1,
b => 2,
c => [
d => 4,
e => 5,
f => [ g => 6]
]
]
# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013
@vuthaihoc
vuthaihoc / benchmark+go+nginx.md
Created June 1, 2018 10:23 — forked from hgfischer/benchmark+go+nginx.md
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@vuthaihoc
vuthaihoc / post.md
Created April 11, 2018 19:03 — forked from ikwattro/post.md
Discover Graph Databases with Neo4j & PHP

Discover Graph Databases with Neo4j and PHP

Graph databases are now one of the core technologies of companies dealing with highly connected data.

Business graphs, social graphs, knowledge graphs, interest graphs and media graphs are frequently in the (technology) news. And for a reason. The graph model represents a very flexible way of handling relationships in your data. And graph databases provide fast and efficient storage, retrieval and querying for it.

Neo4j, the most popular graph database, has proven that ability to deal with massive amount of high connected data in many use-cases.

@vuthaihoc
vuthaihoc / index.html
Created November 2, 2016 09:10 — forked from fcingolani/index.html
How to render a full PDF using Mozilla's pdf.js
<html>
<body>
<!-- really dirty! this is just a test drive ;) -->
<script type="text/javascript" src="https://raw.github.com/mozilla/pdf.js/gh-pages/build/pdf.js"></script>
<script type="text/javascript">
function renderPDF(url, canvasContainer, options) {
var options = options || { scale: 1 };