Skip to content

Instantly share code, notes, and snippets.

View shahril96's full-sized avatar
🐢

Mohd Shahril shahril96

🐢
View GitHub Profile
@shahril96
shahril96 / montecarlo-pi.cpp
Last active December 22, 2015 16:27
Calculate approximation of π using Monte Carlo simulation
#include <iostream> // cout, cin
#include <cmath> // sqrt, pow
#include <random> // random_device, mt19937, uniform_real_distribution
#include <iomanip> // setprecision
#include <ctime> // time
#include <cstdint> // uint64_t
uint64_t s[2] = {(uint64_t)time(NULL) % 100, (uint64_t)time(NULL) % 10000};
int xorshift128(int start, int end) {
@shahril96
shahril96 / 24-to-minute.php
Created October 7, 2013 13:36
24-hour format range to minutes
<?php
echo twentyfourminute('2000', '2200'); // input in string
function twentyfourminute($first, $end){
$total = 0;
if($first[0] == '0') $first = substr($first, 1);
if($end[0] == '0') $end = substr($end, 1);
if((intval($first) % 100) != 0){
$total += 60 - (intval($first) % 100);
@shahril96
shahril96 / bulk_file_rename.php
Created October 26, 2013 14:00
Rename multiple files using regex match and string replacement.
<?php
echo "\n Bulk File Renamer @ Shahril";
$help_text = "
\r {$argv[0]} --dir C:\Music --pattern \"/\d{2} \-/\" --rename \"Change\"
\r Options :-
\r --dir <directory> : Directory of bulk file.
\r --pattern <regex> : Regex pattern to match.
@shahril96
shahril96 / hex-viewer.php
Last active December 27, 2015 03:59
I was trying to make a PHP script that can output result same as HxD so I created this file.
<?php
hex_viewer('./test_file', 8);
function hex_viewer($File, $Length = 16) {
$handle = @fopen($File, 'r');
if(!$handle) {
return 0;
@shahril96
shahril96 / mp3-rename-back.php
Created November 1, 2013 16:13
Rename back your unknown MP3 files using GETID3
<?php
// require getid3
require_once('../getid3/getid3.php');
$getID3 = new getID3;
echo "\n MP3 File Renamer @ Shahril";
$help_text = "
@shahril96
shahril96 / riger_brute.php
Last active December 30, 2015 19:49
Brute force TM Riger router using PHP script
<?php
date_default_timezone_set('Asia/Kuala_Lumpur'); // Here is important for new PHP version.
define('size', 10); // multithread
define('ip', NULL);
define('start', 0x0); // what hex to start
define('sleept', 10); // sleep time if failed
define('attempt', 10000); // how many attempts
define('usleept', 100000); // micro sleep after current attempt
define('timeout', 10); // timeout for each multi request
@shahril96
shahril96 / saps-fetcher.php
Last active January 1, 2016 13:18
Simple SAPS data fetcher
<?php
$get = file_get_contents("https://sapsnkra.moe.gov.my/ibubapa2/semak.php?txtIC=010610101490&Semak=Semak+Laporan&jenissek=2&tahun_semasa=2015");
// build up custom header + cookie
preg_match_all('#Set-Cookie: (.*?);#', implode('', $http_response_header), $out);
$opts = array('http'=>array('header'=> "Cookie: " . implode('; ', $out[1]) . "\r\n"));
$get = file_get_contents("https://sapsnkra.moe.gov.my/ibubapa2/menu.php", false, stream_context_create($opts));
preg_match_all('#<strong>(.*?)&nbsp;</strong>#', $get, $out);
@shahril96
shahril96 / chess.cpp
Last active January 18, 2016 04:37
Naive coded chess program written as my mini project for second semester (not working inside Window$)
// if using OOP, this program is actually not so pain in the ass to write..
/* shahril : 18-jan-2016
piece of advises to those "forces" who want to read my code
- code very mess up (this was written 1 year ago)
- this game isn't "computer vs human", it's "human vs human", the reason is my internal implementation
isn't compatible with chess engines that available online
@shahril96
shahril96 / percolate_threshold.cpp
Created January 22, 2016 16:57
Calculate percolation threshold using Monte Carlo simulation
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* Author: shahril
*
* Created on January 22, 2016, 5:21 PM
@shahril96
shahril96 / int2basen.c
Last active April 6, 2016 13:23
Convert base-10 integer to any base-N (base 2 until base 10) presentation
#include <stdio.h>
void int2bin(int n, int base) {
if(n > 0) {
int2bin(n / base, base);
printf("%d ", n % base);
}
}
int main() {