Skip to content

Instantly share code, notes, and snippets.

View noogen's full-sized avatar
¯\_(ツ)_/¯

Tom Noogen noogen

¯\_(ツ)_/¯
View GitHub Profile
@noogen
noogen / recipe.js
Last active May 19, 2021 16:33
Recipe Schema with validation rules, nutrition, and FDA recommended daily values
// based on schema.org basic recipe and nutrition definition.
// see jsonld example here: https://gist.github.com/patrickcoombe/48d4ad1eca1b22f6c5ae
// see schema markup example here: https://gist.github.com/jessotron/28f3b87d50ecb1c6aad2
// for nutrition, see: https://www.fda.gov/Food/GuidanceRegulation/GuidanceDocumentsRegulatoryInformation/LabelingNutrition/ucm385663.htm
// vitamin dv: https://www.fda.gov/Food/GuidanceRegulation/GuidanceDocumentsRegulatoryInformation/ucm535371.htm
// formula for daily value percentage is: (nutrition / recommended_dv) * 100 = dv_percentage
// reverse formula: (dv_percentage / 100) * recommended_dv = nutrition
export default {
name: 'recipe',
@noogen
noogen / patch.sh
Last active February 27, 2018 18:18
Flexible Vesta php-fpm nginx.conf
#!/bin/bash
echo 'checking for patch'
if ! grep -q "\/private\/ngin" /usr/local/vesta/data/templates/web/nginx/php-fpm/*.tpl; then
echo 'patch does not exists, applyiing patch...'
sed -ie "s/ location \/ {/ location \/ {\n include \%home\%\/\%user\%\/web\/\%domain\%\/private\/ngin*.conf;\n/g" /usr/local/vesta/data/templates/web/nginx/php-fpm/*.tpl
sed -ie "s/ location \/ {/ location \/ {\n include \%home\%\/\%user\%\/web\/\%domain\%\/private\/sngin*.conf;\n/g" /usr/local/vesta/data/templates/web/nginx/php-fpm/*.stpl
else
echo 'patch exists, exiting...'
fi
@noogen
noogen / safe
Last active November 27, 2017 20:17
my-startup.sh
#!/bin/sh
# re-enable phpmyadmin and phppgadmin
# rsync -a /etc/apache2/conf-d/php*.conf /etc/apache2/conf.d
# required startup and of course vesta
cd /etc/init.d/
./disable-transparent-hugepages defaults
# the 5 services below are enabled to support mininum default backup job
@noogen
noogen / testconnection.ps1
Last active October 17, 2017 20:02
Powershell test connection to sql server
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Data Source=mssqlprod01;Initial Catalog=master;User Id=youruser;Password=yourpassword"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = 'SELECT @@SERVERNAME AS ServerName'
$SqlCmd.Connection = $SqlConnection
$SqlConnection.Open()
$rdr = $SqlCmd.ExecuteReader()
while($rdr.Read())
{
$rdr["ServerName"].ToString()
@noogen
noogen / changes.html
Last active October 27, 2017 19:25
Change L&B
<div class="wrap">
<link href="//cdn.brickinc.net/asset/common/styles/print.css?nocache=89" rel="stylesheet" type="text/css" media="print">
<div class="layout-container" data-ng-include="'//clientapi.brickinc.net/api/v1/content/meta/401/?name=home page&meta=template&type=text/html&nocache=89'"></div>
<!-- above the fold scripts -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.29/angular.min.js"></script>
<script src="//clientapi.brickinc.net/api/v1/store/sitecontentscript/401?nocache=89"></script>
@noogen
noogen / .htaccess
Created July 7, 2017 22:14
https redirect .htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
@noogen
noogen / hmac-auth.js
Created July 6, 2017 23:12
simple hmac auth nodejs
var crypto = require('crypto');
function getAuth() {
var secureKey = 'yourkey';
var yourData = 'hmac';
var yourTtl = 3600; // in seconds
var timeInSeconds = Math.floor(today.getTime() / 1000);
var stringToSign = `${timeInSeconds}:${yourTtl}:${yourData}`;
var shahmac = crypto.createHmac('SHA256', secureKey);
@noogen
noogen / Concrete5.7 .htaccess
Last active June 12, 2017 05:15
Concrete5.7+ in subfolder with hidden subfolder
# BEGIN Concrete5 rewrite
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/c5/
# exclude other sub-directories if necessary
RewriteCond %{REQUEST_URI} !^/dev/
RewriteCond %{REQUEST_URI} !^/dev2/
@noogen
noogen / Concrete5.6 .htaccess
Last active June 12, 2017 05:02
Concrete5.6 and below in subfolder with hidden subfolder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/c5/
# exclude other sub-directories if necessary
RewriteCond %{REQUEST_URI} !^/dev
RewriteCond %{REQUEST_URI} !^/dev2
@noogen
noogen / image-proxy-test.conf
Last active September 7, 2018 13:02
image-proxy-test.conf
proxy_cache_path /tmp/nginx/cache levels=1:2 keys_zone=cdn_diskcached:10m max_size=5g inactive=45m;
server {
listen 81;
listen [::]:81 ipv6only=on;
resolver 8.8.8.8 8.8.4.4;
merge_slashes off;