Skip to content

Instantly share code, notes, and snippets.

View OkoyaUsman's full-sized avatar
🏠
Available for freelance job

Okoya Usman OkoyaUsman

🏠
Available for freelance job
View GitHub Profile
@OkoyaUsman
OkoyaUsman / url2img.js
Created April 21, 2020 20:57
Simple, lightweight jQuery Program to get website screenshots using Google Page Insights API
//Import jQuery
var url = "https://nodetent.com/";
$.ajax({
url: 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=' + url + '&screenshot=true',
context: this,
type: 'GET',
dataType: 'json',
timeout: 60000,
success: function(result) {
@OkoyaUsman
OkoyaUsman / Office_kms
Created July 4, 2019 05:36 — forked from CHEF-KOCH/KMS_office.cmd
KMS server Windows
cd\Program Files\Microsoft Office\Office16
cd\Program Files (x86)\Microsoft Office\Office16
cscript OSPP.VBS /sethst:kms.digiboy.ir
cscript OSPP.VBS /actcscript OSPP.VBS /dstatus
slmgr.vbs /ckms
@OkoyaUsman
OkoyaUsman / ffmpeg-restream.txt
Last active May 23, 2021 14:27
Perfect FFMPEG Command For Stable Live Streaming
ffmpeg -re -i "http://example.com/live/username/password/1234.m3u8" -bsf:a aac_adtstoasc -r 30 -b:v 2048k -bufsize 2048k -maxrate 4296k -vf scale="1280:720" -vcodec libx264 -preset ultrafast -c:a copy -f flv "rtmp://freertmpserver.com/servername/keyname"
@OkoyaUsman
OkoyaUsman / .htaccess
Created August 9, 2018 12:48 — forked from voku/gist:d958041e7b1c19356e721de1eda1e6f8
.htaccess with many options + description
# Apache Server Configs v2.14 | MIT License
# https://github.com/h5bp/server-configs-apache
# (!) Using `.htaccess` files slows down Apache, therefore, if you have
# access to the main server configuration file (which is usually called
# `httpd.conf`), you should add this logic there.
#
# https://httpd.apache.org/docs/current/howto/htaccess.html.
# ----------------------------------------------------------------------
@OkoyaUsman
OkoyaUsman / links-extract.php
Created March 18, 2018 08:37
How to extract all links of any web page using PHP
@OkoyaUsman
OkoyaUsman / seconds-to-time.php
Created February 3, 2018 11:42
PHP Function to Convert Seconds into Years, Months, Days, Hours, Minutes and Seconds.
<?php
function convertSecToTime($sec){
$date1 = new DateTime("@0"); //starting seconds
$date2 = new DateTime("@$sec"); // ending seconds
$interval = date_diff($date1, $date2); //the time difference
return $interval->format('%y Years, %m months, %d days, %h hours, %i minutes and %s seconds'); // convert into Years, Months, Days, Hours, Minutes and Seconds
}
echo convertSecToTime(246395678);
//OUTPUT: 7 Years, 9 months, 21 days, 19 hours, 14 minutes and 38 seconds
?>
@OkoyaUsman
OkoyaUsman / nocopyjs.html
Created January 28, 2018 08:47
Disable Right Click In JavaScript
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Github</title>
</head>
<body>
<script language="javascript">
var message="";
function clickIE() {if (document.all) {(message);return false;}}
@OkoyaUsman
OkoyaUsman / advanced-mediaqueries.css
Created January 16, 2018 14:35
Advanced CSS Media Queries for All The Common Devices
/* ------ Large screens ----------- */
@media only screen and (min-width : 1824px) {
/* Styles go here.. */
}
/* ------ Desktops and laptops ----------- */
@media only screen and (min-width : 1224px) {
/* Styles go here.. */
}
/* ------ Smartphones (portrait and landscape) ----- */
@OkoyaUsman
OkoyaUsman / php-regex-meta-description.php
Created January 5, 2018 10:08
How to PHP regex match an HTML document's meta description
<?php
function parseDescription($html) {
// Get the 'content' attribute value in a <meta name="description" ... />
$matches = array();
// Search for <meta name="description" content="Buy my stuff" />
preg_match('/<meta.*?name=("|\')description("|\').*?content=("|\')(.*?)("|\')/i', $html, $matches);
if (count($matches) > 4) {
return trim($matches[4]);
}
@OkoyaUsman
OkoyaUsman / cc-validate.php
Created January 4, 2018 13:21
Credit card validation script in PHP
<?php
function CCValidate($type, $cNum) {
switch ($type) {
case "American":
$pattern = "/^([34|37]{2})([0-9]{13})$/";//American Express
return (preg_match($pattern,$cNum)) ? true : false;
break;
case "Dinners":
$pattern = "/^([30|36|38]{2})([0-9]{12})$/";//Diner's Club
return (preg_match($pattern,$cNum)) ? true : false;