Skip to content

Instantly share code, notes, and snippets.

View dylan-k's full-sized avatar

Dylan Kinnett dylan-k

View GitHub Profile
@dylan-k
dylan-k / git-subset-branch.log
Last active December 24, 2015 08:29 — forked from vasi/gist:6695286
This is one way to work with a subset of files, within a Git Branch. See also: http://ask.metafilter.com/249100/Can-a-Git-Branch-Contain-Only-a-Sub-Set-of-the-Repository#3617407
# (on master)
git checkout -b subset
git rm file1.txt file2.txt # (remove the files you don't want on this branch)
git commit -m 'removed some stuff'
git checkout master # (go back to master)
git merge --strategy ours subset # (record a merge from the subset branch, but make no actual changes to master)
git checkout subset
# (edit file3.txt)
git add file3.txt
git commit -m 'edited file3'
@dylan-k
dylan-k / html2md-with-pandoc.sh
Created February 12, 2014 04:20 — forked from bzerangue/html2md-with-pandoc.sh
RECURSIVELY Bash convert all your html to markdown files (with Pandoc)
find . -name "*.ht*" | while read i; do pandoc -f html -t markdown "$i" -o "${i%.*}.md"; done
# a simpler method
# e.g. convert all text files in the current directory into a single .html file
pandoc *.txt > _book2.html
#My 'palabra' project contains similar examples
#!/usr/bin/ruby
# Sifttter: An IFTTT-to-Day One Logger by Craig Eley 2014 <http://craigeley.com>
# Based on tp-dailylog.rb by Brett Terpstra 2012 <http://brettterpstra.com>
#
# Notes:
# * Uses `mdfind` to locate a specific folder of IFTTT-generated text files changed in the last day
# * The location of your folder should be hardcoded in line 53
# * Scans leading timestamps in each line matching today's date
# * Does not alter text files in any way
# * Changes ampersand ('&') to 'and' so the script keeps running
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Masonry Template</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans+Caption:400,700">
@dylan-k
dylan-k / crawler.sh
Last active October 13, 2017 19:00 — forked from nerdpanda/crawler.sh
wget crawler
#!/bin/bash
#
# Crawls a domain
# Retreives all visible URLs and their page titles
# Saves to CSV
# $1 = URL
# $2 = csv filename
#
# USAGE:
# save this script as, say, crawler.sh”.
@dylan-k
dylan-k / Importing posts from Wordpress into Jekyll.rb
Created November 17, 2016 19:44 — forked from vitobotta/Importing posts from Wordpress into Jekyll.rb
The script I used to import posts from my Wordpress blog into a new Jekyll one.
%w(rubygems sequel fileutils yaml active_support/inflector).each{|g| require g}
require File.join(File.dirname(__FILE__), "downmark_it")
module WordPress
def self.import(database, user, password, table_prefix = "wp", host = 'localhost')
db = Sequel.mysql(database, :user => user, :password => password, :host => host, :encoding => 'utf8')
%w(_posts _drafts images/posts/featured).each{|folder| FileUtils.mkdir_p folder}
@dylan-k
dylan-k / dev_setup.ps1
Created August 9, 2017 19:37 — forked from thitemple/dev_setup.ps1
A PowerShell script for installing a dev machine using Chocolatey.
function Add-Path() {
[Cmdletbinding()]
param([parameter(Mandatory=$True,ValueFromPipeline=$True,Position=0)][String[]]$AddedFolder)
# Get the current search path from the environment keys in the registry.
$OldPath=(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
# See if a new folder has been supplied.
if (!$AddedFolder) {
Return 'No Folder Supplied. $ENV:PATH Unchanged'
}
# See if the new folder exists on the file system.
@dylan-k
dylan-k / firstLast.sql
Created April 9, 2018 22:25 — forked from mrclay/firstLast.sql
MySQL: Extract last and first name(s) from a full "name" field (for Elgg)
SELECT
-- Assumed to be trimmed
name
-- Does name contain multiple words?
,(LOCATE(' ', name) = 0) AS hasMultipleWords
-- Returns the end of the string back until reaches a space.
-- E.g. "John Doe" => "Doe"
-- E.g. "Francis Scott Key" => "Key"
@dylan-k
dylan-k / .htaccess
Created March 20, 2019 19:57 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
<?php
function my_find_expired_events( $ids ) {
$args = array(
'post_type' => 'tribe_events',
'nopaging' => true,
'fields' => 'ids',
'meta_query' => array(
array(