Skip to content

Instantly share code, notes, and snippets.

View abuzarhamza's full-sized avatar
🎯
Focusing

abuzarhamza abuzarhamza

🎯
Focusing
View GitHub Profile
@abuzarhamza
abuzarhamza / test.js
Created October 29, 2018 23:43
async
let async = require('async');
async.autoInject({
a: test1.bind(null, 1),
b: test2.bind(null, 2),
c: ['b', (b , cb)=> {
test4.bind(null, 3)(cb);
@abuzarhamza
abuzarhamza / dbConnection.js
Created October 23, 2018 18:26
dbConnection
const mongoose = require('mongoose');
const errorResp = function (err) {
return {
message: 'Unable to connect to DB',
errorCode: 40
};
};
// Export DB Connection function
mongoose.Promise = global.Promise;
module.exports = function (options, callback) {
@abuzarhamza
abuzarhamza / InsertData.sql
Created December 31, 2017 00:40
Create dataentry in tables
Insert into CUSTOMER (CUSTOMER_ID,FIRST_NAME,LAST_NAME,MIDDLE_NAME,ADDRESS_LINE1,ADDRESS_LINE2,CITY, COUNTRY,DATE_ADDED,REGION) values (10,'JOHN','AMIRTHRAJ','T','2345 PETERDRIVE',null,'Atlanta','USA', to_date('12-JAN-15','DD-MON-YY'),'SOUTH');
Insert into CUSTOMER (CUSTOMER_ID,FIRST_NAME,LAST_NAME,MIDDLE_NAME,ADDRESS_LINE1,ADDRESS_LINE2,CITY, COUNTRY,DATE_ADDED,REGION) values (11,'TOM','JOSEPH','A','123SANDY DRIVE',null,'New York','USA', to_date('12-JAN-15','DD-MON-YY'),'SOUTH');
Insert into CUSTOMER (CUSTOMER_ID,FIRST_NAME,LAST_NAME,MIDDLE_NAME,ADDRESS_LINE1,ADDRESS_LINE2,CITY, COUNTRY,DATE_ADDED,REGION) values (12,'PETER','MANN','J','3456 GATES DRIVE',null,'Washington','USA', to_date('13-JAN-15','DD-MON-YY'),'NORTH');
COMMIT;
Insert into PRODUCT (PRODUCT_ID,PRODUCT_NAME,STANDARD_COST,COLOR,LIST_PRICE,PRODUCT_SIZE,WEIGHT, PRODUCT_CATEGORY) values (100,'Mobile Cover',30,null,35,10,100,'Mobile');
Insert into PRODUCT (PRODUCT_ID,PRODUCT_NAME,STANDARD_COST,COLOR,LIST_PRICE,PRODUCT_SIZE,WEIGHT, PRODUCT_CATEGORY)
@abuzarhamza
abuzarhamza / CreateTable.sql
Last active December 31, 2017 00:38
SQL script need to create tables.
CREATE TABLE CUSTOMER ( CUSTOMER_ID NUMBER, FIRST_NAME VARCHAR2(50), LAST_NAME VARCHAR2(50), MIDDLE_NAME VARCHAR2(50), ADDRESS_LINE1 VARCHAR2(80), ADDRESS_LINE2 VARCHAR2(80), CITY VARCHAR2(40), COUNTRY VARCHAR2(50), DATE_ADDED DATE, REGION VARCHAR2(10) );
CREATE TABLE PRODUCT ( PRODUCT_ID NUMBER, PRODUCT_NAME VARCHAR2(100), STANDARD_COST NUMBER(10,2), COLOR VARCHAR2(20), LIST_PRICE NUMBER(10,2), PRODUCT_SIZE NUMBER(8,2), WEIGHT NUMBER(10,2), PRODUCT_CATEGORY VARCHAR2(20) );
CREATE TABLE SALES ( SALES_DATE DATE, ORDER_ID NUMBER, PRODUCT_ID NUMBER, CUSTOMER_ID NUMBER(5,0), SALESPERSON_ID NUMBER(5,0), QUANTITY NUMBER(4,0), UNIT_PRICE NUMBER(10,2), SALES_AMOUNT NUMBER(10,2), TAX_AMOUNT NUMBER(10,2), TOTAL_AMOUNT NUMBER(10,2) );
CREATE TABLE SALES_HISTORY ( SALES_DATE DATE, ORDER_ID NUMBER, PRODUCT_ID NUMBER, CUSTOMER_ID NUMBER(5,0), SALESPERSON_ID NUMBER(5,0), QUANTITY NUMBER(4,0), UNIT_PRICE NUMBER(10,2), SALES_AMOUNT NUMBER(10,2), TAX_AMOUNT NUMBER(10,2), TOTAL_AMOUNT NUMBER(10,2) );
CREATE TABLE SALESPERSON (
@abuzarhamza
abuzarhamza / zmq_client2.js
Created May 27, 2017 20:49
client 2 subscriber dog
const zmq = require('/usr/local/lib/node_modules/zmq');
sub = zmq.socket('sub');
sub.subscribe("dat");
sub.on('message' , function(topic , data) {
let msg = JSON.parse(data),
date = new Date(msg.time);
@abuzarhamza
abuzarhamza / zmq_clent1.js
Created May 27, 2017 20:21
client 1 subscriber for cat
const zmq = require('/usr/local/lib/node_modules/zmq');
sub = zmq.socket('sub');
//subscribe to only cat topic
sub.subscribe("cat");
sub.on('message' , function(topic , data) {
let msg = JSON.parse(data),
@abuzarhamza
abuzarhamza / zmq-publisher.js
Last active May 27, 2017 20:20
zmq-publisher.js
const fs = require('fs'),
zmq = require('/usr/local/lib/node_modules/zmq'),
filename = 'pub.txt';
const pub = zmq.socket('pub');
//watch the change in the file.
//when you want to sned the message make change in pub.txt
module.exports = function(sequlize, DataType) {
return sequlize.define('todo', {
description: {
type: DataType.STRING,
allowNull: false,
validate: {
len: [1, 250]
}
},
completed: {
@abuzarhamza
abuzarhamza / interview.txt
Created July 15, 2016 13:08
Perl *nix developer interview
1. Can you get the process running for specific user
ps –u username
2. What is system call
In computing, a system call is the programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. This may include hardware-related services (for example, accessing a hard disk drive), creation and execution of new processes, and communication with integral kernel services such as process scheduling. System calls provide an essential interface between a process and the operating system
3. What is kernel panic
A kernel panic is a computer error from which the operating system (OS) cannot quickly or easily recover. The term applies primarily to Unix-based systems and to Mac OS X. In other systems, the equivalent of a kernel panic is known by slang terms such as blue screen of death, sad Mac or bomb
4. Can u tell me how to check system call are being made by one process
b(main):001:0> Problem.all
NoMethodError: undefined method `all' for Problem:Module
from (irb):1
from /home/abuzar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/console.rb:110:in `start'
from /home/abuzar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/console.rb:9:in `start'
from /home/abuzar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/abuzar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/abuzar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
from /home/abuzar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
from /home/abuzar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in