Posts

Showing posts from 2016

Enable gzip compression on Elastic Beanstalk with nginx

Create nginx_gzip_configuration.config file into .ebextensions directory and then put the following script. files:   "/etc/nginx/conf.d/gzip.conf":       mode: "644"       owner: "root"       group: "root"       content: |         # enable gzip compression         gzip on;         gzip_min_length  1100;         gzip_buffers  4 32k;         gzip_types    text/plain text/html text/xml text/css application/javascript application/json;         gzip_vary on;         # end gzip configuration container_commands:   02_restart_nginx:     command: service nginx restart

Enable gzip configuration in nginx web server on VPS

To change the Nginx  gzip  configuration, open the main Nginx configuration file in  nano  or your favorite text editor. sudo nano /etc/nginx/nginx.conf Find the  gzip  settings section, which looks like this: ## # `gzip` Settings # # gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_min_length 256; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon; .. Save and close the file to exit. To enable the new configuration, restart Nginx. sudo service nginx restart

Install SQL sever on Ubuntu

Install SQL Server To install the mssql-server Package on Ubuntu, follow these steps: Enter superuser mode. Copy bash sudo su Import the public repository GPG keys: Copy bash curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - Register the Microsoft SQL Server Ubuntu repository: Copy bash curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list > /etc/apt/sources.list.d/mssql-server.list Exit superuser mode. Copy bash exit Run the following commands to install SQL Server: Copy bash sudo apt-get update sudo apt-get install -y mssql-server After the package installation finishes, run the configuration script and follow the prompts. Copy bash sudo /opt/mssql/bin/sqlservr-setup Once the configuration is done, verify that the service is running: Copy bash systemctl status mssql-server Next steps Install tools If you already have SQL Server tools,  connect to the SQL Se

Upwork Desktop app not working on Ubuntu

Download (64 bit) wget http : //launchpadlibrarian.net/233346181/libnss3_3.19.2.1-0ubuntu0.14.04.2_amd64.deb (32 bit) wget http : //launchpadlibrarian.net/233346229/libnss3_3.19.2.1-0ubuntu0.14.04.2_i386.deb Install sudo dpkg - i libnss3_3 . 19.2 . 1 - 0ubuntu0.14 . 04.2 _amd64 . deb Upwork app should work by now (Tested).

Angular filter with select tag and input value

javascript: var app = angular . module ( 'appX' , []); app . controller ( 'ctrlX' , function ( $scope ) { $scope . dataSet = [{ firstname : 'first 1' , lastname : 'last 1' , age : '24' , sex : 'F' }, { firstname : 'first 2' , lastname : 'last 2' , age : '21' , sex : 'M' }, { firstname : 'first 3' , lastname : 'last 3' , age : '24' , sex : 'M' }, { firstname : 'first 4' , lastname : 'last 4' , age : '26' , sex : 'F' }]; $scope . keyList = []; angular . forEach ( $scope . dataSet , function ( val , key ) { angular . forEach ( val , function ( v , k ) { if ( $scope . keyList . indexOf ( k ) < 0 ) { $scope . keyList . push ( k ); } }) }) }) app . filter ( 'mycust

integrate paypal into sharetribe market palce

First you have to create Papal Setting: PaymentSettings .create( community_id: 1 , active: true , payment_gateway: " paypal " , payment_process: " preauthorize " , commission_from_seller: 3 , minimum_price_cents: 50 , minimum_transaction_fee_cents: 12 , confirmation_after_days: 1 ) After added this you will be able to see Connect paypal account button in Admin (http://arvind.lvh.me:3000/en/admin/paypal_preferences) Update you paypal credentials into config.yml

Drag and drop image and store base 64 string then display

<form method="post" action="/upload">     <input type="file"><input id="fileDragName" name="file_name"><input id="fileDragSize"><input id="fileDragType"><input id="fileDragData" name="image_base64">     <div id="holder" style="width:200px; height:200px; border: 10px dashed #ccc" id="holder"></div>     <input type="submit" value="Submit"></input>   </form>     <script type="text/javascript">     function readfiles(files) {       for (var i = 0; i < files.length; i++) {         document.getElementById('fileDragName').value = files[i].name         document.getElementById('fileDragSize').value = files[i].size         document.getElementById('fileDragType').value = files[i].type         document.getElementById('fileDragData'

Drag and drop ordering in rails

Add order_number column into news table:-  rails g migration add_order_number_to_news order_number:integer In config/routes.rb     get '/news_ordering/(:id)' => 'news#news_ordering', as: :news_ordering    post  '/re_order_news'                              => 'news#re_order_news' In app/views/news/news_ordering.html.erb   <style>   #sortable {      list-style-type: none;     margin: 0;      width: 60%;     cursor: pointer;   }   .pic_box {     border: 1px #cccccc solid;      padding: 2%;     margin: 1%;      width: 50%;   }   .img_box{     height: 60px;     width: 60px;   } </style> <div class="wrapper wrapper-content animated fadeInRight">     <p id="notice"><%= notice %></p>     <div class="row">         <div class="col-lg-12">             <div class="ibox float-e-margins">    

Order items by Drag and drop in ruby on rails

Add order_number column into news table:-  rails g migration add_order_number_to_news order_number:integer In config/routes.rb    get '/news_ordering/(:id)' => 'news#news_ordering', as: :news_ordering    post  '/re_order_news'                              => 'news#re_order_news' In app/views/news/news_ordering.html.erb   <style>   #sortable {      list-style-type: none;     margin: 0;      width: 60%;     cursor: pointer;   }   .pic_box {     border: 1px #cccccc solid;      padding: 2%;     margin: 1%;      width: 50%;   }   .img_box{     height: 60px;     width: 60px;   } </style> <div class="wrapper wrapper-content animated fadeInRight">     <p id="notice"><%= notice %></p>     <div class="row">         <div class="col-lg-12">             <div class="ibox float-e-margins">      

Drag and drop ordering in rails

Add order_number column into news table:-  rails g migration add_order_number_to_news order_number:integer In config/routes.rb     get '/news_ordering/(:id)' => 'news#news_ordering', as: :news_ordering    post  '/re_order_news'                              => 'news#re_order_news' In app/views/news/news_ordering.html.erb   <style>   #sortable {      list-style-type: none;     margin: 0;      width: 60%;     cursor: pointer;   }   .pic_box {     border: 1px #cccccc solid;      padding: 2%;     margin: 1%;      width: 50%;   }   .img_box{     height: 60px;     width: 60px;   } </style> <div class="wrapper wrapper-content animated fadeInRight">     <p id="notice"><%= notice %></p>     <div class="row">         <div class="col-lg-12">             <div class="ibox float-e-margins">      

Get Fitibt Access token bu oauth2 authentication.

Get the code by setting up omniauth callback URL:- redirect_to "https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=#{ENV['FITBIT_CLIENT_ID']}&redirect_uri=#{$URL}%2Fauth%2Ffitbit_oauth2%2Fcallback%2F&scope=activity%20heartrate%20location%20nutrition%20profile%20settings%20sleep%20social%20weight&expires_in=604800" You will get code in params[:code], then use this code in following script;- uri = URI.parse("https://api.fitbit.com/oauth2/token")         http = Net::HTTP.new(uri.host, uri.port)         http.use_ssl = true         request = Net::HTTP::Post.new(uri.request_uri)         header_string =  Base64.encode64(("#{ENV['FITBIT_CLIENT_ID']}:#{ ENV['FITBIT_CONSUMER_SECRET']}"))         request.set_form_data('clientId' => ENV['FITBIT_CLIENT_ID'], 'grant_type' => 'authorization_code', 'redirect_uri' => $URL + '/auth/fitbit_oauth2/c

Add Ruby slim package into Sublime text editor

The simplest method of installation is through the Sublime Text console. The console is accessed via the  ctrl + `  shortcut or the  View  >  Show Console  menu. Once open, paste the appropriate Python code for your version of Sublime Text into the console. Sublime-3 import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by) Sublime- 2 import urllib2,os,hashlib; h = '2915d1851351e5ee549c20394736b442'