Skip to content

Instantly share code, notes, and snippets.

View redlotus's full-sized avatar
💭
YOLO!!! 🚀

redlotus redlotus

💭
YOLO!!! 🚀
View GitHub Profile
" enable plugins
filetype on
syntax enable
" basic settings
set laststatus=2 " Always show the statusline
"set term=$TERM
set encoding=utf-8 " Necessary to show unicode glyphs
" if $TERM!="linux" " if we are not in tty
" set t_Co=256 " Tell that terminal supports 256 colors
@redlotus
redlotus / demo.html
Created July 11, 2016 08:31
html file to test with wkhtmltopdf
<html>
<head>
<style>
tr {
page-break-inside: auto !important;
}
</style>
</head>
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Public Holidays 2016
X-WR-TIMEZONE:Asia/Singapore
X-WR-CALDESC:
BEGIN:VEVENT
DTSTART;VALUE=DATE:20161226
@redlotus
redlotus / postgres-cheatsheet.md
Created March 2, 2016 14:44 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

If run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@redlotus
redlotus / hallo
Last active August 29, 2015 14:24
About me
## Hallo
My name is Doan Luong Van and I am currently a back-end developer at FPT Telecom.
I am just a lazy and simple man who is a readaholic, a cyclist and a backpacker. I am interested in taking photo (photography enthusiast, maybe), making funny things (robot, paper models, etc...), backpacking and enjoying my life every moment.
Volunteering is an important part of my life. Sharing is happiness.
I always keep in mind the following quote.
"Keep it simple, stupid"
@redlotus
redlotus / bookmark
Last active August 29, 2015 14:23
get subtitles from subscene.com
javascript: (function() { var subs = []; var base = "http://subscene.com"; var find = "http://subscene.com/subtitles/title?q="; var langs = ['vietnamese', 'english']; var url; var rq = prompt("input: ", "name"); var xhr = new XMLHttpRequest(); var parser = new DOMParser(); xhr.open("GET", find + rq.split(" ").join("+") + "&l=", false); xhr.send(); var rPage = parser.parseFromString(xhr.response, "text/html"); var result = (rPage.getElementsByClassName("search-result")[0]).getElementsByTagName("h2")[0].innerHTML; if (result == "No results found") { return "no results"; } else { var lsFilm = (rPage.getElementsByClassName("search-result")[0]).getElementsByTagName("li"); var lsFilm_2 = []; for (var f = 0; f < lsFilm.length; f++) { lsFilm_2[f] = f + ". " + lsFilm[f].getElementsByTagName("a")[0].innerHTML; } alert(lsFilm_2.join("\n")); var choice = prompt("your choice: ", "0"); if
@redlotus
redlotus / app.js
Created March 24, 2015 07:57
bootstrap combobox
$(".dropdown-menu li a").click(function(){
var selText = $(this).text();
$(this).parents('.btn-group').find('.dropdown-toggle').html(selText+' <span class="caret"></span>');
});
$("#btnSearch").click(function(){
alert($('.btn-select').text()+", "+$('.btn-select2').text());
});
@redlotus
redlotus / about.txt
Last active August 29, 2015 14:16 — forked from jessejlt/about.txt
downloading file - flask
Okay so here's the setup:
[-] The primary server API is exposed via Flask (Python) and all static files, including all html, css, js is served by nginx.
[-] Python is exposing an API at url http://domain.com/api/download/<file_id>, where file_id is a database id for the file that we're interested in downloading.
1. User wants to download a file, so we spawn a new window with the url '/api/download/<file_id>'
2. Nginx intercepts the request, sees that it starts with /api/, and then forwards the request to Flask, which is being served on port 5000.
3. Flask routes the request to its download method, retrieves the pertinent data from the file_id, and constructs additional header settings to make nginx happy and to force the browser to see the file stream as a download request instead of the browser just trying to open the file in a new window. Flask then returns the modified header stream to nginx
4. Nginx is finally ready to do some work. While parsing the headers for the incoming request, it encounters "X
@redlotus
redlotus / client.py
Last active August 29, 2015 14:16 — forked from EyalAr/client.py
from subprocess import Popen, PIPE
from time import sleep
# run the shell as a subprocess:
p = Popen(['python', 'shell.py'],
stdin = PIPE, stdout = PIPE, stderr = PIPE, shell = False)
# issue command:
p.stdin.write('command\n')
# let the shell output the result:
sleep(0.1)