Skip to content

Instantly share code, notes, and snippets.

@efreed
efreed / ApnsPushService.php
Last active September 1, 2023 06:11
PHP NotificationPusher to mobile devices (namespace is ready to work with Symfony)
<?php
namespace App\Service\Notification\PushNotification;
use Exception;
// composer require edamov/pushok
// https://github.com/edamov/pushok
use Pushok\AuthProvider;
use Pushok\Client;
use Pushok\Notification;
@efreed
efreed / HTML App.hta
Created January 26, 2018 21:27
Hypertext application demo
<HTML XMLNS:HTA><HEAD>
<TITLE>App Without A Cool Acronym</TITLE>
<HTA:APPLICATION id=oApp APPLICATIONNAME="IDHERE"
BORDER="thick" CAPTION="yes"
icon="http://dkcoin8.com/images/whatsapp-cool-clipart-9.vnd.microsoft.icon"
SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes"
WINDOWSTATE="normal" SCROLL="yes" SCROLLFLAT="yes" VERSION="1.0">
</HTA:APPLICATION>
<SCRIPT language=JScript>
function WriteFile(FilePath, Content) {
@efreed
efreed / kov.js
Created November 20, 2017 16:03
Knockout Helpers
/**
* Lookup the observable object or value of a field safely no matter if it is static or observable or even exists
* @syntax kov([scope,]period_delimited_lookup_string[,ifmissing])
* @returns value or ifmissing
* @author Eric Freed
*/
function kov(a, b, c, orig_f, orig_scope) {
try {
@efreed
efreed / AWS Account Init.txt
Last active September 22, 2018 06:13
AWS Web Server
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/get-set-up-for-amazon-ec2.html
(in the IAM section)
Create New Group called "Administrators" (with the AdministratorAccess policy)
Create IAM users and add to the group
In the "dashboard" section, edit the account alias to make *alias*.signin.aws.amazon.com/console
On the IAM homepage, finish the 5 security steps
(in the EC2 section)
@efreed
efreed / put_sample
Created June 29, 2015 17:16
S3 REST
class OdysysCache {
protected $_key = 'abc';
protected $_secret = 'abc123xyz';
protected $_bucket = 'odysyscache';
/**
* Write a file to the S3 Bucket
* @param String $file_name
* @param mixed $file_data
* @param String $file_type Optional MIME type, or will be auto set from the file extention
@efreed
efreed / doxygen_integration
Last active June 20, 2016 18:01
Wordpress plugin to read zip'd website into a shortcode
<?php
/**
* Plugin Name: DoxyGen Integration
* Plugin URI: http://www.fivetalent.com/
* Description: Enables shortcodes to embed a doxygen site into a page
* Version: 1.0
* Author: Eric Freed / Five Talent
*/
@efreed
efreed / AsFraction.js
Created September 1, 2014 05:41
Javascript decimal-to-fraction
/*
* Will convert a float to an html fraction, guessing denominators up to 16. Handles errors from rounding to 2 decimals.
*/
function AsFraction(num) {
if (num == "" || isNaN(num)) // sanity check
return num;
var int = Math.floor(num)
, decimal = num - int;
if (decimal < 0.005) // whole number, don't show fraction
return int;
@efreed
efreed / account-t1.php
Last active August 29, 2015 14:05 — forked from kyfreed/account-t1.php
File-based PHP login system
<?php
include 'accountfunctions.php';
requireUser('t1');
?>
@efreed
efreed / errorlog.php
Created June 9, 2014 18:27
Apache error log UI
// No configuration needed, will automatically find the Apache log folder and read error.log
// Initialy displays the last 2k of contents and auto updates (and auto scrolls) as new lines show up
// Can enter a search phrase in the UI to ignore any new lines that do (or don't) contain the phrase
$tail = new PHPTail(GetApacheLogPath());
if(isset($_GET['ajax'])) { //We're getting an AJAX call
echo $tail->getNewLines($_GET['lastsize'], $_GET['grep'], $_GET['invert']);
exit();
}
// Regular GET/POST call, print out the GUI
@efreed
efreed / prd.php
Last active November 1, 2017 16:35
print_r; die;
/**
* print_r and die. Pass any number of params, each one will be separated by an hr
**/
function prd() {
while(ob_get_level())
ob_end_flush();
foreach (func_get_args() as $i => $arg) {
echo $i?'<hr>':'<pre>';
if ($arg === null) echo '<span style="background-color:#333;color:#FFF;">null</span>';
else if ($arg === true) echo '<span style="background-color:#333;color:#FFF;">true</span>';