Skip to content

Instantly share code, notes, and snippets.

@waleedsamy
waleedsamy / db-data-config.xml
Last active April 22, 2021 19:54
solr delta import and deletedPkQuery example
<dataConfig>
<dataSource name="DATA_SOURCE" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://10.10.10.10:3306/rm" user="user" password="pass" />
<document name="DOC_NAMES">
<entity name="ENTITY_NAME" dataSource="DATA_SOURCE" pk="serial_no"
query = "SELECT nri.id id,
nri.name name
FROM rm.nri nri ;"
deltaImportQuery="SELECT nri.id id,
nri.name name
@waleedsamy
waleedsamy / subquery-performance.sql
Last active August 29, 2015 14:15
MySql subquery performance enhancment
-- enviroment : Mysql 5.5
-- worst peerformance frist
--explain query indicate it not depend on any index on partent query ( so it will full scan on table with 11M )
SELECT co_id FROM argo.v_r_p_master WHERE mn_code
IN (
SELECT pk_data FROM argo.s_r_d_l WHERE insert_date > (NOW() - INTERVAL 1 DAY)
AND table_name IN ('argo.mn_code') AND pk_data IS NOT NULL
);
@waleedsamy
waleedsamy / chlorum2014.py
Last active August 29, 2015 14:17
codaility chlorum2014 challenge
# https://codility.com/programmers/custom_challenge/chlorum2014
# not pass yet
# SAMPLE DATA
# C=[1, 3, 0, 3, 2, 4, 4]
# D=[6, 2, 7, 5, 6, 5, 2]
# K=5
C=[1,3,0,3,2,4,4]
D=[6,2,7,5,6,5,2]
K=2
@waleedsamy
waleedsamy / README.md
Last active August 5, 2021 19:19 — forked from vitkin/README.md
compile wstunnel for apache 2.2.15 on centos CentOS release 6.6 (Final)

Backport WebSocket to Apache 2.2

This is my variation from the original patch and that also includes the suggested correction for the bug with secure websocket 'wss://'.

The difference is that I avoid modifying the mod_utils.c and the mod_proxy.h so that if the mod_proxy module has been embedded in the main httpd binary then it will work and you won't get the

@waleedsamy
waleedsamy / virtual.cpp
Created April 27, 2015 08:39
c++ opp , virtual keyword
// virtual is all about binding , early binding in compliation so it will determine abject and so method to call
// as reference is or late binding shen method is virtual so binding determine in run time dynamically
// according to actual type of object and sall it's method
// depend on http://stackoverflow.com/questions/2391679/why-do-we-need-virtual-methods-in-c
#include <iostream>
using namespace std;
class Animal
{
@waleedsamy
waleedsamy / httpsclient.js
Last active March 22, 2018 06:47
express js https server and client with self signed certificate
const request = require('request'),
fs = require('fs'),
path = require('path'),
ca = fs.readFileSync(path.join(__dirname, 'root-ca.crt'));
const options = {
url: 'https://127.0.0.1:3443/', // any @alt_names will work
agentOptions: {
ca: ca
}
@waleedsamy
waleedsamy / nginx.conf
Last active April 5, 2017 14:25
my /var/nginx/nginx.conf
worker_processes 8;
events {
worker_connections 2048;
}
http {
gzip on;
@waleedsamy
waleedsamy / sri.bash
Created September 21, 2015 07:59
Subresource Integrity - SRI
## http://www.w3.org/TR/SRI
## modern browser chrome 45+ or firefix 43+ will check hash of javascript or css resource
## aginst new attribute 'integrity' and if not matched browser will not load this resources
alg=sha256
resource=resource.css;
integrity=$(cat $resource | openssl dgst -$alg -binary | openssl enc -base64 -A)
printf '<link rel="stylesheet" href="resource.css" integrity="%s%s">\n' "$alg-$integrity"
@waleedsamy
waleedsamy / instructions.md
Last active October 3, 2015 18:21
search for match between objects

Input Data Given json contains 20K articles. Each article contains set of attributes with one set value.

Recommendation Engine Requirements Calculate similarity of articles identified by sku based on their attributes values. Attributes with name higher in alphabet (a is higher than z) is weighted with heavier weight.

Absolute weighting values are up to engineer. Relative order as described above should be maintained.

This file has been truncated, but you can view the full file.
{"sku-1":{"att-a":"att-a-7","att-b":"att-b-3","att-c":"att-c-10","att-d":"att-d-10","att-e":"att-e-15","att-f":"att-f-11","att-g":"att-g-2","att-h":"att-h-7","att-i":"att-i-5","att-j":"att-j-14"},"sku-2":{"att-a":"att-a-9","att-b":"att-b-7","att-c":"att-c-12","att-d":"att-d-4","att-e":"att-e-10","att-f":"att-f-4","att-g":"att-g-13","att-h":"att-h-4","att-i":"att-i-1","att-j":"att-j-13"},"sku-3":{"att-a":"att-a-10","att-b":"att-b-6","att-c":"att-c-1","att-d":"att-d-1","att-e":"att-e-13","att-f":"att-f-12","att-g":"att-g-9","att-h":"att-h-6","att-i":"att-i-7","att-j":"att-j-4"},"sku-4":{"att-a":"att-a-9","att-b":"att-b-14","att-c":"att-c-7","att-d":"att-d-4","att-e":"att-e-8","att-f":"att-f-7","att-g":"att-g-14","att-h":"att-h-9","att-i":"att-i-13","att-j":"att-j-3"},"sku-5":{"att-a":"att-a-8","att-b":"att-b-7","att-c":"att-c-10","att-d":"att-d-4","att-e":"att-e-11","att-f":"att-f-4","att-g":"att-g-8","att-h":"att-h-8","att-i":"att-i-7","att-j":"att-j-8"},"sku-6":{"att-a":"att-a-6","att-b":"att-b-2","att-c":"at