Skip to content

Instantly share code, notes, and snippets.

View cowgill's full-sized avatar

David Cowgill cowgill

View GitHub Profile
@MikeRogers0
MikeRogers0 / simple-hit-counter.php
Created June 10, 2012 22:33
Simple hit counter
<?php # File created on 25th April 2009 by Mike Rogers (http://www.fullondesign.co.uk/).
## Start defining constants ##
define(LOG_URL, '/home/user/download_logs/'); // Put the location of where you want to put the logs. Make sure this is absolute
# $_GET['ID'] – this is the ID of the file we want. It gets the value from the URL.
## Now set the data you wish to use – this can be moved to an include if you want ##
$file[0] = 'http://www.example.com/file.pdf';
## Define the functions required to update the file.
@truth3
truth3 / SlackOpportunityPublisher.cls
Created June 4, 2018 00:45
Publishing financial data to Slack from Salesforce
public with sharing class SlackOpportunityPublisher {
// Production business channel
// private static final String slackURL = 'https://hooks.slack.com/services/######';
// Private channel for testing
// private static final String slackURL = 'https://hooks.slack.com/services/#####';
public class Oppty {
@mickm
mickm / update-pingdom-iptables.sh
Created November 21, 2012 20:21
Whitelist Pingdom probe-servers in iptables.
#!/bin/bash
#
# Whitelist Pingdom probe-servers in iptables.
#
# Create a chain called "PINGDOM" and jump to it somewhere before
# the final REJECT/DROP, e.g.
#
# # New chain for Pingdom rules
# :PINGDOM - [0:0]
#
@mkdizajn
mkdizajn / function.php
Last active May 6, 2020 15:59
Wordpress Bootstrap 3 responsive images
<?php
//----------------------------------------------------------/
// responsive images [ 1) add img-responsive class 2) remove dimensions ]
//----------------------------------------------------------/
function bootstrap_responsive_images( $html ){
$classes = 'img-responsive'; // separated by spaces, e.g. 'img image-link'
// check if there are already classes assigned to the anchor
if ( preg_match('/<img.*? class="/', $html) ) {
@lukenm
lukenm / update_geoip_databases.sh
Last active December 13, 2020 12:03
Shell script to update global Maxmind GeoIP databases. This script can be run via cron.
#!/bin/bash
DAT_DIR=/usr/share/GeoIP
DAT_URLS="http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"
for FILE in $DAT_DIR/*.dat; do
cp $FILE $FILE.bak
done;
for URL in $DAT_URLS; do
@devhero
devhero / flask_tips
Last active August 16, 2021 09:50
flask tips
# from http://flask.pocoo.org/docs/1.0/cli/
# Setting Command Options
# Click is configured to load default values for command options from environment variables. The variables use the pattern FLASK_COMMAND_OPTION. For example, to set the port for the run command, instead of flask run --port 8000:
export FLASK_RUN_PORT=8000
flask run
* Running on http://127.0.0.1:8000/
@kirang89
kirang89 / model_relation_ex.py
Created April 7, 2014 18:59
Example for many-to-many relationship with extra columns in SQLAlchemy
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship
engine = sqlalchemy.create_engine('sqlite:///:memory:')
Base = declarative_base()
@jhjguxin
jhjguxin / creating-nested-resources-in-ruby-on-rails-3-and-updating-scaffolding-links-and-redirection.markdown
Created July 9, 2012 03:32
Creating nested resources in ruby on rails 3 and updating scaffolding links and redirection
@yefim
yefim / Dockerrun.aws.json
Last active April 7, 2023 16:11
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<NAME>:<TAG>",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "443"
}
// Pass Tracking Parameters to a Form on Another Page Using GTM
// https://zackphilipps.dev/posts/store-gclid-cookie-send-to-hubspot/
/**
* Assigns the supplied URL parameter to a cookie and each form field with a name that matches.
* You can keep calling this function multiple times for each URL parameter you want to pass along, e.g.
*
* window.onload = function () {
* assignTrackingParameterToCookie("gclid", "hubspot");
* assignTrackingParameterToCookie("utm_source", "gform");