Monday, December 21, 2015

Backup and Restore MySQL Database

10:04 PM Posted by Unknown , No comments

The quick snippet of how backup and restore MySQL database using mysqldump:
Backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
Restore: # mysql -u root -p[root_password] [database_name] < dumpfilename.sql
Backup MySQL database 
1. Backup a single database:
# mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
2. Backup multiple databases:
# mysqldump -u root -p[root_password] --databases [database_1] [database_2] > database_1_and_2.sql
3. Backup all the databases:
# mysqldump -u root -p[root_password] --all-databases > /tmp/all-database.sql
4. Backup a specific table:
# mysqldump -u root -p[root_password] database_name table_name > /tmp/database_table.sql
Restore MySQL database 
1. Restore a database
# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
2. Backup a local database and restore to remote server using single command:
# mysqldump -u root -p[root_password] database_name | mysql -u root -p[root_password] --host=remote-server -C database_name1

Wednesday, December 16, 2015

Solr DataImporter using Mongodb

6:15 PM Posted by Unknown , No comments

1. Get required libraries
Download following .jar files:
- solr-mongo-importer-1.0.0.jar (https://github.com/downloads/james75/SolrMongoImporter/solr-mongo-importer-1.0.0.jar)
- mongo-2.10.1.jar (http://central.maven.org/maven2/org/mongodb/mongo-java-driver/2.10.1/mongo-java-driver-2.10.1.jar)
save these files into
solr/contrib/dataimporthandler/lib/
2. Configure solrconfig.xml
<lib dir="../../../contrib/dataimporthandler/lib/" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-dataimporthandler-.*\.jar" />
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">  
   <lst name="defaults">
      <str name="config">data-config.xml</str>
   </lst>
</requestHandler>
 3. Configure data-config.xml
 <?xml version="1.0"?>
 <dataConfig>
   <dataSource name="mymongodb" type="MongoDataSource" database="MongodbDatabaseName" />
   <document name="data">
   <!-- if query="" then it imports everything -->
    <entity name="users"
            processor="MongoEntityProcessor"
            query=""
            collection="users" 
            datasource="mymongodb"
            transformer="MongoMapperTransformer"> 
      <field column="id" name="id" mongoField="_id" /> 
      <!--<field column="_id" name="id" />-->

      <entity name="company"
              processor="MongoEntityProcessor"
              query="{'_id':'${users.id}'}"
              collection="company" 
              datasource="mymongodb"
              transformer="MongoMapperTransformer"> 
         <field column="company" name="company" mongoField="company"/> 
      </entity>

      <entity name="biodata"
              processor="MongoEntityProcessor"
              query="{'_id':'${users.id}'}"
              collection="users" 
              datasource="mymongodb"
              transformer="script:biodataTransformer">
      </entity>

    </entity> 
  </document> 
<script><![CDATA[
function biodataTransformer(row){
  if(row.get('biodata') !== null){
    var biodata = row.get('biodata')
    if(biodata.get("age") !== null){
      row.put("biodata_age", biodata.get("age").toString());
    }
    if(biodata.get("height") !== null){
      row.put("biodata_height", biodata.get("height").toString());
    }                
  }                 
  return row; 
}
]]></script>
</dataConfig>
4. Configure schema.xml
Define the fields you want to index in schema.xml
5. Import mongodb data into solr with outer join
Fire up solr and go to dataimport tab and execute data import.

Saturday, December 5, 2015

How to get long live access token from Facebook (60 days)

5:58 PM Posted by Unknown No comments
As of July 2015 you can now create a 60 day access token easily in Facebook

The first you need to grant permissions to your app to get an access token.

https://developers.facebook.com/tools/accesstoken/

Copy User Token and paste it to EXISTING_ACCESS_TOKEN and change your APP_ID and APP_SECRET


https://graph.facebook.com/oauth/access_token?             
    client_id=APP_ID&
    client_secret=APP_SECRET&
    grant_type=fb_exchange_token&
    fb_exchange_token=EXISTING_ACCESS_TOKEN 

Thursday, December 3, 2015

The best Material Design Frameworks for the Web

11:38 PM Posted by Unknown , No comments
In an attempt to bring Material design to the Web user interface, many third party (not from Google) web UI frameworks have come to existence recently. In this post I will be doing a roundup of these Material Design Web UI frameworks. Some of these frameworks are themes based on the popular web UI framework, Bootstrap.

1. Materialize

materialze-framework-material-design
Materialize is a modern responsive front-end framework based on Material Design. For use in your web projects, it provides an option of both CSS as well as source SCSS files, along with JavaScript, material design icons and Roboto font. Included components are basic ones such as grids, forms, buttons, navbar and cards. Materialize is available on GitHub as well.

2. Material UI

material-ui-css-framework
Material UI is a CSS Framework and a Set of React Components that implement Google’s Material Design. It provides support for components such as Buttons, Dialog, Dropwdown menu, Icon buttons, Inputs, Switches, Toolbar and more. You can find Material UI on GitHub too.

3. Paper Bootswatch for Bootstrap

paper-bootstrap-material-design-theme
Paper is a bootswatch theme for the Bootstrap framework. It includes all the components that Bootstrap provides but in a Material design skin.

4. Bootstrap Material

bootstrap-material-design
Similar to Paper, Bootstrap Material is another theme for Bootstrap framework and provides all the components included in Bootstrap. On top of that, it also includes support for 740 original Material design icons from the Google Material Design Icons repository.

5. Leaf BETA

leaf-meterial-css-framework
Leaf is CSS framework developed by Kim Korte based on the Google’s material design. While still in beta, it has extensive list of components such as buttons, cards, sliders, menu, tabs etc. It includes icons by Icomoon, instead of the original Material design icons. Leaf is also available onGitHub and is open for contributions and feedback.

6. MUI CSS Framework

mui-meterial-css-framework
MUI is a lightweight HTML, CSS and JS framework for building sites following Google’s Material Design guidelines. MUI is designed from the ground up to be fast, small and developer friendly. By design it only includes the basic components you need to build a site that follows Google’s Material Design guidelines. MUI CSS/JS has no external dependencies. MUI is also available onGitHub and is open for contributions.

7. Polymer Project

google-polymer-paper-material
Google’s Polymer Project is a web framework and their embodiment of material design for the web. While still in “developer preview”, most of the components (a very extensive set) are quite mature. Polymer aims to support all major modern browsers such as IE (10+), Chrome, Safari, and Firefox. Extensive set of documentation and getting started guide is available at the Polymer Project.