Vagrantfile example

Just an example of Vagrantfile in case I need it. you can also use it.

$ mkdir vagrant
~/vagrant:~$ touch Vagrantfile
~/vagrant:~$ vagrant up

Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"
  config.vm.network "private_network", ip: "192.168.56.11"
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "2048"
  end
  config.vm.provision :shell, :path => "gw.sh"
  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "playbook.yml"
    ansible.limit = "all"
    ansible.verbose = "vv"
    ansible.raw_arguments = [
      "--diff"
    ]
  end
end

My vim standard config

highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver100-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
set mouse=a

autocmd TextChanged,TextChangedI <buffer> silent write


set clipboard=unnamedplus
set paste
set nu
set tabstop=4

noremap <S-s> :w <Enter>


let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
augroup ProjectDrawer
  autocmd!
  autocmd VimEnter * :Vexplore
augroup END

function! NetrwOpenMultiTab(current_line,...) range
   " Get the number of lines.
   let n_lines =  a:lastline - a:firstline + 1

   " This is the command to be built up.
   let command = "normal "

   " Iterator.
   let i = 1

   " Virtually iterate over each line and build the command.
   while i < n_lines
      let command .= "tgT:" . ( a:firstline + i ) . "\<CR>:+tabmove\<CR>"
      let i += 1
   endwhile
   let command .= "tgT"

   " Restore the Explore tab position.
   if i != 1
      let command .= ":tabmove -" . ( n_lines - 1 ) . "\<CR>"
   endif

   " Restore the previous cursor line.
   let command .= ":" . a:current_line  . "\<CR>"

   " Check function arguments
   if a:0 > 0
      if a:1 > 0 && a:1 <= n_lines
         " The current tab is for the nth file.
         let command .= ( tabpagenr() + a:1 ) . "gt"
      else
         " The current tab is for the last selected file.
         let command .= (tabpagenr() + n_lines) . "gt"
      endif
   endif
   " The current tab is for the Explore tab by default.

   " Execute the custom command.
   execute command
endfunction

" Define mappings.
augroup NetrwOpenMultiTabGroup
   autocmd!
   autocmd Filetype netrw vnoremap <buffer> <silent> <expr> t ":call NetrwOpenMultiTab(" . line(".") . "," . "v:count)\<CR>"
   autocmd Filetype netrw vnoremap <buffer> <silent> <expr> T ":call NetrwOpenMultiTab(" . line(".") . "," . (( v:count == 0) ? '' : v:count) . ")\<CR>"
augroup END


"execute "set <M-j>=\e1"
"nnoremap <M-j> :tabnew

noremap <Esc>1 1gt
noremap <Esc>2 2gt
noremap <Esc>3 3gt
noremap <Esc>4 4gt
noremap <Esc>5 5gt
noremap <Esc>6 6gt
noremap <Esc>7 7gt
noremap <Esc>8 8gt
noremap <Esc>9 9gt
noremap <Esc>z :tabnext <Enter>
noremap <C-w> :close <Enter> <Esc>
noremap <C-Tab> gt
noremap <C-S-Tab> gT
noremap <C-t> :tabnew <Enter>
noremap <Esc>e :Vex <Enter>
noremap <Esc>q :qa! <Enter>
noremap <Space>d <C-w>l
noremap <Space>a <C-w>h
noremap <Space>w <C-w>k
noremap <Space>s <C-w>j
noremap <Esc>s <C-w>w
noremap <C-s> :w <Enter>

" CTRL-Tab is next tab
noremap <C-Tab> :<C-U>tabnext<CR>
inoremap <C-Tab> <C-\><C-N>:tabnext<CR>
cnoremap <C-Tab> <C-C>:tabnext<CR>
" CTRL-SHIFT-Tab is previous tab
noremap <C-S-Tab> :<C-U>tabprevious<CR>
inoremap <C-S-Tab> <C-\><C-N>:tabprevious<CR>
cnoremap <C-S-Tab> <C-C>:tabprevious<CR>

noremap <silent> <F12> touch ~/.uwsgi.ini<cr>

 

Jasa pembuatan website Pondok Kelapa

Bagi yang berminat untuk dibuatkan website baik itu berupa blog, eCommerce, company profile, private API,  toko online untuk umum, kerjaan atau tugas kuliah/sekolah, skripsi, silahkan hubungi saya di bawah ini :

Contact: 085814729385 (SMS/Whatsapp)

Alamat: Pondok Kelapa, Duren sawit – Jakarta Timur

Jasa pembuatan aplikasi android Pondok Kelapa

Dump entire photos in Facebook album with Python

Simple dumping photos from albums in facebook by python. in this case, we must got an authorization before dump the albums. first of all, we have to login to the facebook required user and password. afterwards we have to fetching a couples of line called token key which that it’s an authorization key for grab the data.

#!/usr/bin/python
# -*- coding: utf-8 -*-
#   This library is free software; you can redistribute it and/or
#   modify it under the terms of the GNU Lesser General Public
#   License as published by the Free Software Foundation; either
#   version 2.1 of the License, or (at your option) any later version.
#
#   This library is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   Lesser General Public License for more details.
#
#   You should have received a copy of the GNU Lesser General Public
#   License along with this library; if not, write to the 
#      Free Software Foundation, Inc., 
#      59 Temple Place, Suite 330, 
#      Boston, MA  02111-1307  USA
#
#   by pulpn.com

import json, random, re
import urllib, urllib2
import sys, os
import cookielib

# Random user-agents
user_agents = [
    'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11',
    'Opera/9.25 (Windows NT 5.1; U; en)',
    'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
    'Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Kubuntu)',
    'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070731 Ubuntu/dapper-security Firefox/1.5.0.12',
    'Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/1.2.9'
]

# Facebook photo dumper
class _fbphotosdumper_(object):
  def __init__(self, user, pswd, album_name):
    self.dictid 	= {}
    self.count 	= {}
    self.user 	= user
    self.pswd 	= pswd
    self.album_name = album_name
    self.value 	= {'post_form_id' : '42d7f2c5ff3976d42ead29cbda1561ec',
                   'email':user,
                   'pass' :pswd}
    self.home 	= 'http://m.facebook.com/home.php'
    self.url 	= 'https://www.facebook.com/login.php?m=m&refsrc=http%3A%2F%2Fm.facebook.com%2F&refid=8'
    self.cj 	= cookielib.CookieJar()
    self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
  def login(self):
    login_data 	= urllib.urlencode(self.value)
    self.opener.addheaders = [('User-agent', random.choice(user_agents))]
    self.opener.open(self.url,login_data)

    # Get token key from developers.facebook.com
  def get_token(self):
    url_api = self.opener.open('https://developers.facebook.com/docs/reference/api/')
    rurl_api = url_api.read()
    get = re.search(r'access_token=(.*)">',rurl_api)
    if get:
      return get.group(1)
  def get_albums(self):
    url_album 	= self.opener.open('https://graph.facebook.com/me/albums?access_token=%s&limit=99'%(self.get_token()))
    rurl_album 	= url_album.read()
    _albumfilter_ = json.loads(rurl_album)
    for i in _albumfilter_['data']:
      try:
        name = i['name']
        albumid = i['id']
        psum = i['count']
        self.dictid[name] = albumid
        self.count[name] = psum
        #return name,psum
      except:
        pass
  def get_photos(self):
    self.get_albums()
    sys.stdout.write('Downloading %s photos from "%s" album\n'%(self.count[self.album_name],self.album_name))
 	   	url_photos = self.opener.open('https://graph.facebook.com/%s/photos?access_token=%s&limit=99'%(self.dictid[self.album_name],self.get_token()))
    rurl_photos = url_photos.read()
    _photosfilter_ = json.loads(rurl_photos)
    image = urllib.URLopener()
    for x in _photosfilter_['data']:
      try:
        link = x['source']
      	os.chdir(current)
      	image.retrieve(link,'%s'%link.split('/')[-1])
      	print link.split('/')[-1],'Saved in "%s"'%(current)
      except KeyboardInterrupt:
        sys.stdout.write('Download interrupted\n')
def main():
  global current
  if len(sys.argv) == 4:
    # Create a directory for fetched images from facebook album
    folder = 'Facebook Album - %s'%(sys.argv[3])
    current = os.getcwd()+'/%s'%folder
    os.system('mkdir "%s"'%folder)#"%s"'%folder
    facebook = _fbphotosdumper_(sys.argv[1],sys.argv[2],sys.argv[3])
    try:
      facebook.login()
    except:
      print 'Login Error'
    try:
      facebook.get_photos()
    except:
      print 'No album named "%s"'%(sys.argv[3])
  else:
    print 'Facebook Photos dumper'
    print '----------------------------------------'
    print 'Usage\t: %s user pswd "Album name"'%sys.argv[0]
    print 'Example\t: %s foo@bar.com fubar "Foo Bar"'%sys.argv[0]
    sys.exit(1)
if __name__ == '__main__':
  main()