Skip to content

Instantly share code, notes, and snippets.

View milinmestry's full-sized avatar

Milin Mestry milinmestry

View GitHub Profile
@milinmestry
milinmestry / AsyncCallDvcsApi.java
Last active December 18, 2017 11:21
automatic update by aTOM editor
public class AsyncCallDvcsApi extends AsyncTask<String, Void, String> {
private Activity mActivity;
public AsyncCallDvcsApi(Activity activity) {
this.mActivity = activity;
}
protected void onPreExecute() {
dialog = ProgressDialog.show(this.mActivity,
DvcsConstant.MSG_TITLE_LOADING_DIALOG,
@milinmestry
milinmestry / django-mysqlclient.txt
Last active April 18, 2017 18:47
Using Mysql database for Django 1.10
Ensure that you have installed library as given below; this will solve error "OSError: mysql_config not found".
sudo apt-get install libmysqlclient-dev
Thanks: http://stackoverflow.com/questions/5178292/pip-install-mysql-python-fails-with-environmenterror-mysql-config-not-found
In your python environment install mysqlclient as shown below-
pip install mysqlclient
@milinmestry
milinmestry / extract_new_array.php
Created April 24, 2017 10:23
Get new array with specific columns from existing 2d array
$api_records = getDataFromAPI(); // Fetchh data from DB/ or from another API
$keys = array('productID' => '', 'code' => '', 'parentProductID' => '');
$product_ids = getArrayFrom2dArray($api_records, $keys);
/**
*
* @param array $records [2 dimensional associative array]
* @param array $keys
<?php
// File: module/Tld/src/Tld/Module.php
namespace Tld;
use ZF\Apigility\Provider\ApigilityProviderInterface;
use classes\TldMaster; // this class is simple class outside ZF2
class Module implements ApigilityProviderInterface
{
@milinmestry
milinmestry / max-date-rows-with-if.sql
Last active June 9, 2017 07:12
In the table we have duplicate rows for data to be processed by cron script. Base on latest date(s) from the table values; the script needs to process rows as either add it into another table or delete it.
Problem Scenerio:
================
A) System add new records to be processed for futher into another database table.
B) System update exiting records to be deleted from the current database table.
The process A and/or B can be happened any number of times. So system needs to
process each record for an entity depending on it is recently added or deleted.
SQL:
====
@milinmestry
milinmestry / django_admin_form_showhide_div
Created August 17, 2017 13:11
Django Admin Form - show/hide div based on option selected
I am using Django version 1.11
In the created app, add directory to store (static) JavaScript file(s) in it.
In my case I have created "div_showhide.js" file in this location-
MY_APP_NAME/static/MY_APP_NAME/js/admin/div_showhide.js
New directories are:
static/
MY_APP_NAME/
@milinmestry
milinmestry / genre.js
Created September 21, 2017 09:25
Handle unique column validation in ExpressJs
// Filepath: models/genre.js
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var GenreSchema = Schema({
name: {type: String, required: true, min:3, max: 100, unique: true},
description: {type: String, max: 500},
});
@milinmestry
milinmestry / create_properties_table-v0.php
Created March 20, 2018 09:14
laravel 5.6 Illuminate\Database\QueryException : SQLSTATE[42000]
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePropertiesTable extends Migration {
const TABLE_NAME = 'properties';
### Keybase proof
I hereby claim:
* I am milinmestry on github.
* I am milin (https://keybase.io/milin) on keybase.
* I have a public key ASBeqgawcFynYMSmH2_N85vtgTSxShj2vaznvC_RaQ8Pego
To claim this, I am signing this object:
@milinmestry
milinmestry / OfferStatusCodeClass.php
Created July 11, 2018 10:47
Use of Interface, Abstract class and Inheritance example
<?php
namespace classes;
use interfaces\OfferStatusCode as interfaceOSC;
/**
* Abstract class Offers Status Code
*
*