Skip to content

Instantly share code, notes, and snippets.

View jongacnik's full-sized avatar

Jon jongacnik

View GitHub Profile
@jongacnik
jongacnik / wp-excerpt-outside-loop.php
Created January 13, 2017 19:45 — forked from facelordgists/wp-excerpt-outside-loop.php
WORDPRESS: get excerpt outside loop
<?
/* works pretty well */
function the_excerpt_max_charlength($id=false, $charlength=55) {
global $post;
$old_post = $post;
if ($id != $post->ID) {
$post = get_page($id);
}
@jongacnik
jongacnik / scrape.php
Created December 6, 2016 05:13
Tumblr image scrape
<?php
$offset = 0;
$count = 50;
$domain = $argv[1];
$tagged = isset($argv[2]) ? $argv[2] : false;
$api = 'http://' . $domain . '.tumblr.com/api/read/json?debug=1&num=' . $count . ($tagged ? '&tagged=' . $tagged : '');
function scrape ($api, $count, $offset) {
@jongacnik
jongacnik / easings.js
Created November 10, 2016 06:48 — forked from rezoner/easings.js
One argument easing equations
/*
A full list of simple easing equations inspired by GIST from greweb - https://gist.github.com/gre/1650294
Equations source - http://gsgd.co.uk/sandbox/jquery/easing/
*/
{
linear: function(t) {
return t
},
inQuad: function(t) {
@jongacnik
jongacnik / .htaccess
Created October 27, 2016 03:19
Root to subdir
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]
RewriteRule ^(/)?$ subdir/index.php [L]
module.exports = svgstring => {
const parser = new DOMParser()
return parser.parseFromString(svgstring, 'image/svg+xml').documentElement
}
const jsonp = require('jsonp')
const param = require('jquery-param')
module.exports = (shortname, apikey) => {
return elements => {
elements = elements || document.querySelectorAll('[data-disqus-identifier]')
if (!elements || !elements.length) return
const data = param({
@jongacnik
jongacnik / mailchimpform.js
Created October 22, 2016 21:37
Simple dom mailchimp form
const h = require('bel')
const x = require('xtend')
const jsonp = require('jsonp')
const param = require('jquery-param')
const Emitter = require('tiny-emitter')
const uniqueId = () => Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)
module.exports = opts => {
const options = x({
el: document.body,
@jongacnik
jongacnik / mailchimp.html
Created October 22, 2016 06:45 — forked from joeswann/mailchimp.html
Mailchimp ajax
<form class="newsletter" action="https://example.us2.list-manage.com/subscribe/post-json?u=xxxxxxx&id=xxxxxxxx&c=?" method="get" >
<div class="close"></div>
<div class="success">
Thankyou for signing up!
</div>
<div class="error">
Please check your email address is correct.
</div>
<input name="NAME" type="text" placeholder="Full Name" />
<input name="EMAIL" type="text" placeholder="Email Address" />
@jongacnik
jongacnik / redirect-wp-post.php
Created October 20, 2016 19:15 — forked from Bobz-zg/redirect-wp-post.php
Redirects wordpress posts to new url: site.com/blog/post-name
<?php
/**
* Add new rewrite rule
*/
function create_new_url_querystring() {
add_rewrite_rule(
'blog/([^/]*)$',
'index.php?name=$matches[1]',
'top'
);
@jongacnik
jongacnik / gistColaboration.md
Created October 12, 2016 06:09 — forked from maglietti/gistColaboration.md
How to collaborate on a gist

To colaborate on a gist:

  1. Clone your gist repo locally
  2. Add your friend’s fork as a remote e.g. if your friend is named Cindy: git remote add-url cindy https://gist.github.com/cindy/df03bdacaef75a80f310
  3. Fetch your friend’s commits: git fetch cindy/master
  4. Merge your friend’s changes into your repo: git merge cindy/master
  5. Push the changes back to GitHub: git push origin/master