Skip to content

Instantly share code, notes, and snippets.

/**
* @author Mahadir Ahmad
**/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
@mahadirz
mahadirz / 50Thread.php
Last active August 29, 2015 14:23
PHP Multithread
<?php
/**
* Created by PhpStorm.
* User: Mahadir
* Date: 6/22/2015
* Time: 7:23 AM
*
* Forking 50 threads which each thread
* have processing time within 0-3 seconds
* The Total Execution Time should be
@mahadirz
mahadirz / flood_status.php
Created April 4, 2016 14:13
River Water level and flood data in JSON example: https://apps.madet.my/banjir/river_level.php?state=perak
<?php
/**
* Created by PhpStorm.
* User: Mahadir
* Date: 2/6/2016
* Time: 10:04 PM
*/
date_default_timezone_set("Asia/Kuala_Lumpur");
set_time_limit ( 300);
error_reporting(E_ALL ^ E_NOTICE);
@mahadirz
mahadirz / game_dice.php
Created April 4, 2016 14:04
Your company would like to develop an online dice game. The game rules are as below: 1. The game contains 4 players. 2. Each player will have 6 dice in their dice up. 3. Each round all players will roll their dice at the same time. 4. All dice with number 1 on top side will be passed to player on his right hand (the right most player will pass t…
<?php
/**
* Created by PhpStorm.
* User: Mahadir
* Date: 3/15/2016
* Time: 2:12 PM
*/
class Dice {
@mahadirz
mahadirz / capture pixel.php
Last active September 4, 2017 15:12
Capture session_id into cookie
<?php
$offerId = intval($_GET['offer_id']);
$orderId = $_GET['adv_sub'];
$amount = floatval($_GET['amount']);
$transactionId = $_GET['transaction_id'];
//do whatever you want to do with the variables
//ie cross check database for clicks and save into database
@mahadirz
mahadirz / Digital Ocean API - Automate Cluster Creation.ipynb
Created June 17, 2018 07:07
Digital Ocean API - Automate Cluster Creation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mahadirz
mahadirz / test.csv
Last active January 8, 2019 06:48
Machine Learning Train and Test Example
x1 x2 y
0 2.3168004303372607 2.899064354233701 61.17221552432652
1 2.0237264103698185 2.1412428090988036 29.149660910376042
2 2.4835479882676395 2.81328188438866 61.75170142264721
3 2.0583352195322435 2.994135717555901 57.97075305521006
4 2.681822629278009 2.8698354246937043 69.38952395076802
5 2.4591808193357796 2.739151704330056 57.96588982491449
6 2.1624758562131063 2.114451893392963 30.373634154994257
7 2.8036711741614107 2.712502358656134 64.8062957132921
8 2.5257448771289788 2.186162614369698 37.92313916718973
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmKdQSV+JwuIQF+t1iISu
kHNffIDWMcr6v8L9CI1U+9LOF1xNPw7IlhubU+nLWUqGxKnFfadkB7lQCthoK+lb
wbVCUmUXx3vao8N61BWwWLJtlvZdp5Pz2oMQzadzIU4swzIZtTg3uPHtx+p3y5Yc
EKkDk3hMcEPWLzvIxSmgDTlI8HSehX7QCM29hXUpl9iXXnAAcipXQtOktmWaU731
X4SMs93XIFlW2ujyde7zvd3/XTmQWTwYPQhk+OyYIBRFWijOrXGp9q5Vbz5Z+XHY
1esaH64xfiZZON6xLAWqh3AadqXSEJy0gqmg2MOu0CD1RgPT+mAiVXbayHWe3GnY
bwIDAQAB
-----END PUBLIC KEY-----
@mahadirz
mahadirz / Finding User Sessions with SQL
Created February 13, 2020 02:51 — forked from bstancil/Finding User Sessions with SQL
These queries let you define find user sessions against event data logged to Segment SQL, Snowplow, or Google BigQuery.
-- These queries let you define find user sessions against event data
-- logged to Segment SQL, Snowplow, or Google BigQuery.
-- For more details, see the full post:
-- LINK
--- SEGMENT SQL
-- Finding the start of every session
SELECT *
FROM (
@mahadirz
mahadirz / web_traffic_sampling.php
Last active March 5, 2020 03:39
Web traffic allocation algorithm for A/B Test
<?php
/**
* @author Mahadir Ahmad
* http://madet.my
* Traffic Allocation Algorithm
*
*/
/**
* O(n) method of generating Binom(n,p) distributed random numbers