Skip to content

Instantly share code, notes, and snippets.

View Muhammad-Altabba's full-sized avatar

Muhammad Altabba Muhammad-Altabba

View GitHub Profile
@Muhammad-Altabba
Muhammad-Altabba / VrpTimeWindows.cs
Created February 6, 2019 14:01
Sample Time Window Constraints backward compatible with Google OR-Tools 7.0.6150-beta
// This file is cloned from https://github.com/google/or-tools/blob/master/ortools/constraint_solver/samples/VrpTimeWindows.cs
// It is just modified to work with 7.0.6150-beta
// Copyright 2010-2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
@Muhammad-Altabba
Muhammad-Altabba / vrpsolver.py
Last active February 4, 2019 06:43 — forked from ilaif/vrpsolver.py
VRP (Vehicle Routing Problem) Solver using OR-Tools library in python
from ortools.constraint_solver import pywrapcp
from ortools.constraint_solver import routing_enums_pb2
import argparse
import json
import sys
is_debug = False
class CreateDistanceCallback(object):
@Muhammad-Altabba
Muhammad-Altabba / timepan.ts
Last active January 23, 2019 23:32 — forked from ranwahle/timepan.ts
.Net-like timespan class in TypeScript
const MILLISECONDS_IN_A_SECOND = 1000;
const SECONDS_IN_A_MINUTE = 60;
const MINUTES_IN_AN_HOUR = 60;
const HOURS_IN_A_DAY = 24;
const DAYS_IN_A_WEEK = 7;
const MILLISECONDS_IN_A_MINUTE = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;
const MILLISECONDS_IN_AN_HOUR = MILLISECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR;
const MILLISECONDS_IN_A_DAY = MILLISECONDS_IN_AN_HOUR * HOURS_IN_A_DAY;
const MILLISECONDS_IN_A_WEEK = MILLISECONDS_IN_A_DAY * DAYS_IN_A_WEEK;
@Muhammad-Altabba
Muhammad-Altabba / Contract_calls.sol
Last active February 20, 2024 10:45 — forked from critesjosh/Contract_calls.sol
CALL vs CALLCODE vs DELEGATECALL in Solidity
pragma solidity ^0.5.0;
contract C1 {
uint public num;
address public sender;
function callSetNum(address c2, uint _num) public {
(bool res,) = c2.call(abi.encodePacked(bytes4(keccak256("setNum(uint256)")), _num));
if(!res) revert(); // C2's num is set
}
@Muhammad-Altabba
Muhammad-Altabba / SoliditySampleDivideLogicFromData.sol
Created December 22, 2017 17:58
Solidity Sample: Separation of Rules & Logic from Data Structure
contract ManagableAuthorization{
//Simplified in a way that all readers can read all data. In real case scenario you will have more complex logic.
mapping(address => bool) readers;
modifier canRead(){
//your logic for example:
require(readers[msg.sender]);
_;
}
//........ the rest of the class code.........
}
Verifying my Blockstack ID is secured with the address 1HX9ZVMxMHtxxeEzUFs9VVwRVseCyvaEfS https://explorer.blockstack.org/address/1HX9ZVMxMHtxxeEzUFs9VVwRVseCyvaEfS