Skip to content

Instantly share code, notes, and snippets.

@ridvanbaluyos
ridvanbaluyos / to_ordinal.php
Last active August 29, 2015 14:14
Converts a number into its Ordinal form.
/**
* This function converts a number into its ordinal format. If the input passed
* is not an integer, it will attempt to type cast it to integer.
* Note: check the edge case when the input is 0 (both for string and integer)
* Ref: http://stackoverflow.com/questions/3109978/php-display-number-with-ordinal-suffix
*
* @param Integer $number - the input. must be an integer
*
* @return String $abbreviation - the formatted number.
*
<?php
function generateMessageId()
{
return str_pad(rand(), 32, '0', STR_PAD_LEFT);
}
$mobile_number = '';
$client_id = '';
$secret_key = '';
$short_code = '';
private function checkQueryString()
{
if(!empty($_SERVER['QUERY_STRING']) && !preg_match('/^[\p{L}\p{P}\p{S}\p{N}\p{Z}\p{M}\p{Cyrillic}]+$/u', trim(urldecode($_SERVER['QUERY_STRING']))))
{
exit;
}
}
@ridvanbaluyos
ridvanbaluyos / regex-numbers.regex
Created August 11, 2015 10:38
Regex for Philippine Numbers
((\+[0-9]{2})|0)[.\- ]?9[0-9]{2}[.\- ]?[0-9]{3}[.\- ]?[0-9]{4}
or
((\+63)|0)[.\- ]?9[0-9]{2}[.\- ]?[0-9]{3}[.\- ]?[0-9]{4}
will match these:
+63.917.123.4567
+63-917-123-4567
+63 917 123 4567
+639171234567
<?php
$datetime = '2015-12-07 00:58:18';
$now = new DateTime;
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = [
@ridvanbaluyos
ridvanbaluyos / 0_reuse_code.js
Created April 28, 2017 08:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ridvanbaluyos
ridvanbaluyos / gist:57e92f1c05b673a1fd1f907602062fc6
Last active June 14, 2017 07:47
Kong Implementation for the MMDA API.
# See https://getkong.org
# Actual API Endpoint: http://rx-78-2.gundamserver.com/mmda-api/v1/traffic
# All Traffic Data
curl "http://ec2-52-77-210-176.ap-southeast-1.compute.amazonaws.com:8000/
-H "Host: rx-78-2.gundamserver.com" \
-H "apikey: ec5429707a7ac51cf0e66bbbd45ea88f"
# Traffic with Highway (eg. Ortigas Avenue)
@ridvanbaluyos
ridvanbaluyos / monitoring.php
Last active July 29, 2017 14:36
helping someone in laravelph
// Route
Route::get('/monitoring/{username}', 'MainCtr@monitoringView')->middleware('admin');
// Controller
public function monitoringView($username = null)
{
if (!is_null($username) || isset($username)) {
$data = Users::whereUsername($username)->first();
} elseif (request()->has('monitoring')) {
$data = ServiceRequest::where('status', request('monitoring'))
### Keybase proof
I hereby claim:
* I am ridvanbaluyos on github.
* I am ridvanbaluyos (https://keybase.io/ridvanbaluyos) on keybase.
* I have a public key ASAiZcFJ4XCAGc2wFlrSka26MlbdA1rezNyXUfbS3lr8hAo
To claim this, I am signing this object:
@ridvanbaluyos
ridvanbaluyos / f-to-c.lisp
Created March 30, 2018 16:48
Convert Fahrenheit to Celsius using Common Lisp
(defun f-to-c ()
(format t "~%Please enter Fahrenheit temperature: ")
(let*
(
(ftemp (read))
(ctemp (* (- ftemp 32) 5/9))
)
(format t
"~%~s degrees Fahrenheit is ~s degrees Celsius~%"
ftemp