Skip to content

Instantly share code, notes, and snippets.

View riethmayer's full-sized avatar

Jan Riethmayer riethmayer

View GitHub Profile
@riethmayer
riethmayer / html5.yasnippet
Created July 12, 2010 13:41
yasnippet expand-env example
# -*- mode: snippet -*-
# name: html5 document
# key: html5
# binding: "keybinding"
# expand-env: ((yas/indent-line 'auto) (yas/wrap-around-region 't))
# --
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
/*
* def.js: Простое наследование в стиле Ruby для Javascript
*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(global) {
// Используется, чтобы сохранить суперкласс и "плагины" ля
// дальнейшего использования
#!/usr/bin/env zsh
if [[ -s "${TM_PROJECT_DIRECTORY}/.rvmrc" ]]
then
source "${TM_PROJECT_DIRECTORY}/.rvmrc"
fi
`which ruby` $*
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.css" type="text/css" />
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAUXDSXET8IRGdgHP9FpGw5BT-fVzUWGS_eJ2ZLPBO_6yPqTi0vhQKAzahOrduDq0xQk09GR-UP3Jgcg'></script>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script src="http://www.google.com/jsapi?key=ABQIAAAAUXDSXET8IRGdgHP9FpGw5BT-fVzUWGS_eJ2ZLPBO_6yPqTi0vhQKAzahOrduDq0xQk09GR-UP3Jgcg"></script>
<script type="text/javascript">
google.load("jquery", '1.4');
google.load("maps", "2.x");
</script>
@riethmayer
riethmayer / factory_helper.rb
Created October 1, 2010 17:44
Create Factory unless model exists
# spec/support/factory_helper.rb
module FactoryHelper
def self.included(base)
base.send(:include, FactoryHelper::InstanceMethods)
end
module InstanceMethods
# Extracts a klass name and the attribute name out of a string
# like this: find_or_create_factory_KLASS_NAME_by_ATTRIBUTE
# WARNING: Unrefactored Proof of Concept
#
# Allows:
# [1,1,1].should all_be eq(1)
# [2,4,6].should all_be_even
# [2,3,5].should all_be { |n| prime?(n) } # for appropriate definition of prime?#
#
# Not Yet Implemented:
# [1,1,1].should all_be == 1
# [3,6,9].should all_be_divisible_by(3)
module Archives
module Callbacks
def self.included(base)
base.send :include, Archives::Callbacks::InstanceMethods
base.before_create :do_something_awesome
end
module InstanceMethods
private
RSpec::Matchers.define(:be_same_file_as) do |exected_file_path|
match do |actual_file_path|
md5_hash(actual_file_path).should == md5_hash(exected_file_path)
end
def md5_hash(file_path)
Digest::MD5.hexdigest(File.read(file_path))
end
end
@even4void
even4void / .emacs
Last active September 6, 2018 15:26
A basic previewer for R Markdown files edited with Emacs
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.Rmd\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.rmd\\'" . markdown-mode))
(add-hook 'markdown-mode-hook 'turn-on-outline-minor-mode)
(defun rmarkdown-new-chunk (name)
"Insert a new R chunk."
(interactive "sChunk name: ")
(insert "\n```{r " name "}\n")
(save-excursion
@thomaswitt
thomaswitt / deploy_to_opsworks.rake
Last active April 25, 2016 02:59
Deploy to opsworks via rake
# Put this into lib/tasks
require 'rubygems'
require 'bundler'
require 'aws-sdk'
require 'socket'
require 'os'
if Rails.env.development?