Skip to content

Instantly share code, notes, and snippets.

@uyefe
uyefe / excel formulas.md
Created April 20, 2023 07:01 — forked from f-steff/excel formulas.md
Excel formulas to calculate IP values such as Netmask, IP range start, IP range end, Broadcast IP, Number of hosts.

Excel formulas to calculate IP values - Works in Excel and Google Sheet.

Updated March 16. 2023

Prerequisites:

  • A1 contains an IP address, such as 10.0.0.2
  • B1 contains the number of bits in the netmask (CIDR) such as 24

The below formulas then go into C1, D1 etc. to perform the various calculations. Some calculations depends on other calculations.

@uyefe
uyefe / block-java.bat
Created October 12, 2021 19:17 — forked from andy722/block-java.bat
Disables/enables incoming network connections for Java launcher using Windows Firewall.
@echo off
::
:: Disables/enables incoming network connections for Java launcher
:: using Windows Firewall. Requires administrative rights.
::
:: Edit JDK_PATH variable below to specify JDK/JRE installation to be blocked.
::
set JDK_PATH=C:\Program Files\Java\jdk1.6.0_30
@uyefe
uyefe / README.md
Created September 16, 2021 04:34 — forked from eric1234/README.md
Protect page with simple password

Purpose

Unauthorized access to a PHP page prompts the user for a password. Once the password is entered the original page will show.

Features

  • The access is recorded in the session so it only needs to be
@uyefe
uyefe / shorten.php
Created August 26, 2021 06:14 — forked from MikeRogers0/shorten.php
Shorten URLs using the Google URL Shortener and PHP
<?php
// Coded by Mike Rogers (http://www.fullondesign.co.uk/) 1st October 2010.
function shorten($url, $qr=NULL){
if(function_exists('curl_init')){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, 'http://goo.gl/api/shorten');
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'security_token=null&url='.urlencode($url));
@uyefe
uyefe / gist:e39ba865c41e245d6a74568fc043debf
Created August 23, 2021 07:15 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@uyefe
uyefe / gist:ca706835dd6500659702a1811f824ca5
Created June 5, 2019 17:15 — forked from sillage/gist:1336681
Save a file in UTF-8 encoding with Vim
:wq! ++enc=utf-8

Server side printing with Google Cloud Print API from a PHP application

It took me quite some time to figure out how to print properly from a web application. I will explain here how I did it, so you don't have to spend the same time.

Authorization

Google Cloud Print API uses OAuth 2.0 for authorization.

As explained [here][1] on the Google Developer page, the best way to use OAuth with the Google API is with a Google service account. Create a service account as explained on the Google Developer page.

To use OAuth a library is required. Google has published the [Google API PHP client library][2]. If you want to use the examples from the Developer pages, you need to use version 1 of the library. In this article I use version 2 of the library.