Skip to content

Instantly share code, notes, and snippets.

View sammdec's full-sized avatar

Sam Mason de Caires sammdec

View GitHub Profile
@sammdec
sammdec / custom_excerpt_wp.php
Last active August 15, 2018 12:39
Wordpress Custom Excerpt function
<?php
function get_excerpt($count, $post_id){
$permalink = get_permalink($post_id);
$excerpt = get_post($post_id);
$excerpt = $excerpt->post_content;
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, $count);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = $excerpt;
// Want a read more link and ellipsis, remove the line above this and replace it with the one below.
@sammdec
sammdec / post-receive
Created December 21, 2012 15:03
Statamic git push deploy
#!/bin/sh
GIT_WORK_TREE=/path/to/webroot/of/mywebsite git checkout -f
@sammdec
sammdec / Bundle env
Created March 20, 2013 09:04
Bundler issue with installing bcrypt-ruby
Bundler 1.3.1
Ruby 1.9.3 (2013-02-22 patchlevel 392) [x86_64-darwin12.2.1]
Rubygems 2.0.2
GEM_HOME
Bundler settings
path
Set for your local app (/Users/sam/Sites/sample/.bundle/config): "./vendor/bundle"
disable_shared_gems
Set for your local app (/Users/sam/Sites/sample/.bundle/config): "1"
@sammdec
sammdec / before-header.html
Created May 7, 2013 21:51
Header.html Markup for Meteor Book
<template name="header">
<header class="navbar">
<div class="navbar-inner">
<a class="brand" href="/">Microscope</a>
<ul class="nav pull-right">
<li>{{loginButtons}}</li>
</ul>
</div>
</header>
</template>
@sammdec
sammdec / hash.rb
Created August 1, 2013 09:32
the hash return from using psd.rb gem
{:children=>
[{:type=>:group,
:visible=>true,
:opacity=>1.0,
:blending_mode=>"normal",
:name=>"Layer 1",
:left=>-4,
:right=>1206,
:top=>-5,
:bottom=>1051,
@sammdec
sammdec / alfred-stack-search.md
Last active May 19, 2020 02:47
Add StackOverflow search to Alfred

To search Stack Overflow from alfred app, simply copy and paste below into the alfred search box, when you press enter you shoudl see a dialog asking you to install this custom Search.

alfred://customsearch/Search%20StackOverflow%3A%20%7Bquery%7D/stack/utf8/noplus/http://stackoverflow.com/search?q={query}

Then to use it in alfred simply up the search box and type in stack and the question your asking.

var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-sass'),
imagemin = require('gulp-imagemin');
var paths = {
css: 'css/style.css',
img: 'img/**/*''
};
@sammdec
sammdec / gist:10645922
Created April 14, 2014 13:03
Link Detecttion Regex
var regEx = /(\b(https?|ftp|file):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z0-9+&@#\/%=~_|])/img;
create_table "project_files", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "project_id"
t.integer "user_id"
end
create_table "projects", force: true do |t|
t.string "name"
@sammdec
sammdec / keybase.md
Last active November 25, 2019 15:46

Keybase proof

I hereby claim:

  • I am samjbmason on github.
  • I am samjbmason (https://keybase.io/samjbmason) on keybase.
  • I have a public key ASDneB6f5DSZyXY7-pL61i1qtd1FFIBMz4E3f059GOz8Two

To claim this, I am signing this object: