Skip to content

Instantly share code, notes, and snippets.

f = request.files['file']
original_filename = f.filename
unique_filename = str(uuid.uuid4())
save_location = os.path.join(UPLOAD_FOLDER, unique_filename)
f.save(save_location)
mime = magic.from_file(save_location, mime=True)
f_info = {
'original_filename': original_filename,
'mime': mime,
export NVM_DIR="/home/gianfebrian/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:$(go env GOPATH)/bin
export GOPATH=$(go env GOPATH)
git diff-tree --no-commit-id --name-only -r bd61ad98
@gianfebrian
gianfebrian / doc.md
Created April 6, 2017 05:44
Manual Fix Grub from Windows 10 (UEFI mode)

Run these commands using cmd (Administrator):

  • this will list all stored boot configuration
bcdedit /enum all /v
  • locate our beloved linux efi bootloader from the list. I use linux mint and I found this \EFI\ubuntu\grubx64.efi. next thing, you need to set it:
bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi
@gianfebrian
gianfebrian / README.md
Created June 16, 2016 04:29 — forked from exupero/README.md
Alias a domain to a local port (Mac)

I run a lot of web servers for different projects, all of them on different ports. Generally I start with port 8000 and increment from there as I spin up new servers, but it became tiresome to remember what projects were running on which ports and what the next available port was.

/etc/hosts won't let you specify a port, but a combination of aliasing 127.0.0.1 to 127.0.0.X, forwarding ports from 8000 to 80, and adding the 127.0.0.X IP under an alias in /etc/hosts did work.

This script finds the next available value of X, aliases it with ifconfig, forwards the given port to port 80 with ipfw, and adds a new entry to /etc/hosts that aliases the IP to the domain you want.

Now I can add a server alias with sudo domain-alias funproject 8000, run the web server at 127.0.0.X:8000, and load up http://funproject/ in my browser.

(Because I needed it to work on a Mac, I couldn't use iptables. ipfw seems to work, though its manpage claims it's deprecated and pfctl is the way to go. I wasn't able to figure

mysql -u username -p database_name < file.sql
@gianfebrian
gianfebrian / Laravel setting
Created May 19, 2015 09:44
Deploy to User Dir Apache2
Modify /etc/apache2/sites-available/sites-name:
directory to expected directory
Modify /etc/apache2/apache2.conf:
directory to expected directory
sudo chown -R www-data:www-data storage
@gianfebrian
gianfebrian / php-stack
Created April 16, 2015 16:43
Webfaction PHP Stack (Freedts)
phpver=5.5.24
apcver=3.1.9
imagickver=3.1.2
freetds=stable
mkdir -p /home/${USER}/src/php
wget http://us2.php.net/get/php-${phpver}.tar.gz/from/this/mirror
tar xvf php-${phpver}.tar.gz
cd php-${phpver}
./configure