Skip to content

Instantly share code, notes, and snippets.

@chrisross
chrisross / haml_sass_compass_coffee.rb
Last active March 3, 2016 11:57
This guardfile configuration combined with haml_helpers to enhance haml are a basic means to generate a static website using preprocessor languages CoffeeScript, Haml, and Sass; and the Compass framework; and the uglifier compression tool.
# Config
root = File.expand_path(File.dirname(__FILE__))
input, output = %w{src site}
haml_ext = "\.haml"
all_on_start = true
# Validate
unless File.directory?(File.join(root, input))
abort('No source directory found, cannot continue')
end
@chrisross
chrisross / compile_haml_sass_rake_tasks_Rakefile
Created May 30, 2013 06:44
This pair of files are a crude attempt at providing a backup method of compiling static projects' source files (HAML and Sass) using the ease of rake tasking from the commandline.
#!/usr/bin/env ruby
require 'yaml'
# Load _config.yaml file
Conf = YAML.load_file File.join(Dir.pwd, 'rake_config.yaml')
# Paths
ROOT = Conf['root'] == '/' ? File.expand_path(File.dirname(__FILE__)) : Conf['root']
SRC_DIR = File.join ROOT, (Conf['source'] || 'src')
@chrisross
chrisross / git_utils.sh
Last active August 18, 2019 01:04
Functions to init/delete a remote repo using bitbucket or github, using cURL and respective APIs.
#!/usr/bin/env bash
function gitsetup {
# Collect parameters
local params=()
while [[ $# -gt 0 ]]; do
case "${1}" in
-h|-\?|--help)
echo "Usage: gitsetup -H bitbucket -u username -d 'A description' -t repo_title"
@chrisross
chrisross / static_haml_helpers.rb
Last active July 17, 2016 13:38
Custom helper methods to enhance Haml templating in non-Rails projects, ideally combined with guard or Sinatra applications (in this case the partial method would be simplified)
require 'haml' unless defined?(Haml)
module Haml::Helpers
def slugify(str)
str.sub(/[^\w]+/,'-').downcase
end
# Usage in haml document:
# = doc_root 6..10, :class => 'no-js', :lang => "en"
@chrisross
chrisross / curl_create_repo_bitbucket
Created April 28, 2013 05:06
This shell command is how you can remotely create a git repo on your bitbucket account using cURL (and Bitbucket's Repositories API v1)
curl -X POST -u <username_here> https://api.bitbucket.org/1.0/repositories -d "name=repo_example&description=testing+description&is_private=true&scm=git" --verbose
=> Enter passphrase:
@chrisross
chrisross / curl_delete_repo_bitbucket
Created April 28, 2013 05:01
A shell command for deleting a Bitbucket repository (using cURL and BitBucket's Repositories API v1)
curl -u <username_here> https://api.bitbucket.org/1.0/repositories/<username_here>/<repo_slug> -X DELETE
@chrisross
chrisross / curl_create_repo_github
Created April 28, 2013 04:57
A set of shell commands to quickly remotely create a github repo, init/add all/commit in the current directory and push to the aforementioned remote. (using Github's Repo API v3 and cURL)
curl -u <username_here> https://api.github.com/user/repos -d '{"name":"curltest", "description": "testing description"}'
=> Enter passphrase:
// Example test case(below):
cd <local_repo_dir_path>
mkdir curltest
cd curltest
git init
touch curltest.txt
subl& culrtest.txt