Skip to content

Instantly share code, notes, and snippets.

View jongacnik's full-sized avatar

Jon jongacnik

View GitHub Profile
form[data-drip-embedded-form] {
background: #fff url(data:image/gif;base64,R0lGODlhAQADAIABAMzMzP///yH/C1hNUCBEYXRhWE1QPD94cGFja…wbGhkYFxYVFBMSERAPDg0MCwoJCAcGBQQDAgEAACH5BAEAAAEALAAAAAABAAMAAAICRFIAOw==) repeat-y center top;
font-family: "Helvetica Neue", Helvetica, Arial, Verdana, sans-serif;
line-height: 1.5em;
overflow: hidden;
color: #666;
font-size: 16px;
border-top: solid 20px #3071b0;
border-top-color: #3071b0;
border-bottom: solid 10px #3d3d3d;
@jongacnik
jongacnik / ga-cross-domain-tracking.md
Created June 24, 2019 23:25 — forked from holmberd/ga-cross-domain-tracking.md
Google Analytics - Cross Domain Manual Link Tracking

Manually decorate a URL with the linker parameter for Google Tab Manager or Google Analytics

In the case where you manually want to decorate a link with the linker parameter, i.e. the link is not a valid anchor link, or the final tracking page is accessed by user in a non direct way: File Download, Extension Installation, ect...

Google Analytics

/**
 * Returns the Google Analytics tracker linker parameter.
<?php
function replace_fractions ($input) {
return str_replace(
['1/4', '1/2', '3/4', '1/3', '2/3', '1/8', '3/8', '5/8', '7/8', '1/5', '2/5', '3/5', '4/5', '1/6', '5/6', '1/7', '1/9', '1/10'],
['¼', '½', '¾', '⅓', '⅔', '⅛', '⅜', '⅝', '⅞', '⅕', '⅖', '⅗', '⅘', '⅙', '⅚', '⅐', '⅑', '⅒'],
$input
);
}
@jongacnik
jongacnik / functions.php
Created December 22, 2018 02:08 — forked from alokstha1/functions.php
WordPress custom pagination with $wpdb->get_results
<?php
$items_per_page = 2;
$page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;
$offset = ( $page * $items_per_page ) - $items_per_page;
$query = 'SELECT * FROM '.$table_name;
$total_query = "SELECT COUNT(1) FROM (${query}) AS combined_table";
$total = $wpdb->get_var( $total_query );
@jongacnik
jongacnik / create-swapfile.sh
Created December 6, 2018 21:54
vesta create 2gb swapfile
# http://web3us.com/drupal6/how-create-web-site-handbook/fedora-or-redhat-server-tips/adding-swap-space-linux-without-rebooting
dd if=/dev/zero of=/swapfile1 bs=1024 count=2097152
mkswap /swapfile1
swapon /swapfile1
free
@jongacnik
jongacnik / readme.md
Created December 2, 2018 20:22
shash: short hashes using php crc32 method

shash

I add this function to my .bash_profile so I can create short hashes from the command line. Not for anything serious, mainly when I want to generate a random username or something. There's of course many ways (likely better) to create short hashes, but I use the crc32 approach w/in my php code often, so I like the consistency.

usage

$ shash hello
@jongacnik
jongacnik / readme.md
Last active November 30, 2018 22:03
Constant Contact subscribe endpoint

Constant Contact subscribe endpoint

Rudimentary endpoint to subscribe a contact to a Constant Contact list. Responses could be better but hey, works. Relies on jetrouter and Constant Contact PHP SDK for v2 API.

POST to this from your app with an email and Constant Contact list id.

Should be pretty clear how you could yank out the business logic if you don't want this WP specific. Just putting this out there since hard to find a clear example of doing this online and was kinda pain in ass to dig through docs (esp since they deprecated the POST URL and v3 API has a very diff auth model).

@jongacnik
jongacnik / choo-cache.js
Last active November 7, 2018 22:19
Choo component cache plugin
var cache
exports.cache = function () {
return cache.apply(this, arguments)
}
exports.plugin = function (state, emitter) {
cache = state.cache
}
@jongacnik
jongacnik / valet.conf
Created November 2, 2018 01:42 — forked from poul-kg/valet.conf
CORS Rules for Laravel Valet Nginx
# To enable CORS you should add lines with CORS rules below to your valet.conf file
# Find the file /usr/local/etc/nginx/valet/valet.conf - this is Valet conf for Nginx
# of try to execute `locate valet.conf` and find the `valet.coinf` in `nginx` subdirectory
# after you edit your valet.conf do not forget to execute `valet restart`
server {
listen 80 default_server;
root /;
charset utf-8;
client_max_body_size 128M;
@jongacnik
jongacnik / lazy-nanocomponent.js
Last active October 24, 2018 19:07
lazy-nanocomponent
var Nanocomponent = require('nanocomponent')
var html = require('nanohtml')
var onIntersect = require('on-intersect')
module.exports = class LazyComponent extends Nanocomponent {
constructor (id, state, emit) {
super(id)
this.state = state || {components:{}}
this.local = this.state.components[id] = {
view: 'placeholder',