Skip to content

Instantly share code, notes, and snippets.

View capitalist's full-sized avatar
🎯
Focusing

Joe Martinez capitalist

🎯
Focusing
View GitHub Profile
class MyView < Mustache
def cache_by_user_id
lambda do |text|
cache_key = "user:#{current_user.id}"
if value = $cache.get(cache_key)
value
else
rendered = render(text)
$cache.set(cache_key, rendered)
@capitalist
capitalist / this_works.rb
Created December 22, 2010 21:38
View specs for controllers that use decent_exposure
#in my spec helper
def expose(name, &block)
exhibitionist = Module.new
exhibitionist.send(:define_method, name, &block)
view.extend exhibitionist
end
# in my view spec
describe "dashboard/index.html.haml" do
it 'renders' do
Mustache.to_javascript("Hello {{planet}}")
@capitalist
capitalist / rocco.css
Created July 11, 2011 20:20
Rocco CSS
/*--------------------- Layout and Typography ----------------------------*/
body {
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
font-size: 15px;
line-height: 22px;
color: #252519;
margin: 0; padding: 0;
}
a {
color: #261a3b;
@capitalist
capitalist / gist:1259854
Created October 3, 2011 18:33
Ensure wresize
(function(a){a.fn.wresize=function(b){function c(){if(a.browser.msie)if(!wresize.fired)wresize.fired=!0;else{var b=parseInt(a.browser.version,10);wresize.fired=!1;if(b<7)return!1;if(b==7){var c=a(window).width();if(c!=wresize.width)return wresize.width=c,!1}}return!0}function d(a){if(c())return b.apply(this,[a])}return version="1.1",wresize={fired:!1,width:0},this.each(function(){this==window?a(this).resize(d):a(this).resize(b)}),this}})(jQuery)
(defvar rotate-text-rotations
'(
("true" "false")
("def" "defp")
("if" "else" "unless")
("yes" "no"))
"List of text rotation sets.")
(defun rotate-region (beg end)
"Rotate all matches in `rotate-text-rotations' between point and mark."
@capitalist
capitalist / julia-env.sh
Last active May 13, 2017 01:25 — forked from moisespsena/julia-env.sh
Install Latest Julia Stable enviroment on Debian
#!/bin/bash
SD=$(dirname $(realpath "$0")) || exit 1
[ `arch` = 'x86_64' ] && url='https://julialang.s3.amazonaws.com/bin/linux/x64/0.5/julia-0.5.2-linux-x86_64.tar.gz' \
|| url='https://julialang.s3.amazonaws.com/bin/linux/x86/0.5/julia-0.5.2-linux-i686.tar.gz'
echo $url
tmpd="$SD/tmp"
#!/usr/bin/env ruby
def Inherits(*classes)
klass = Class.new classes.shift # inherit from the last clas
while refine_with = classes.shift # include the others as module refinements just so we can turn them into modules
klass.include Module.new { include refine(refine_with) { } }
end
klass
end
@capitalist
capitalist / heroicons_with_surface.ex
Created October 17, 2020 13:05 — forked from lnr0626/heroicons_with_surface.ex
A module for handling svg icons both with and without surface
defmodule HeroiconWithSurface do
@moduledoc """
This assumes https://github.com/tailwindlabs/heroicons has been cloned as a submodule to svgs/heroicons
Examples:
<#HeroiconWithSurface variant="outline" icon="phone" class="w-5 h-5" />
<%= HeroiconWithSurface.svg({"outline", "phone"}, class: "w-5 h-5") %>
"""
use SvgIcons,
@capitalist
capitalist / Dockerfile
Created June 8, 2021 14:42
Phoenix Docker
FROM elixir:latest
ENV HOME /opt/my_app
RUN mkdir -p $HOME
WORKDIR $HOME
ENV MIX_ENV dev
ENV PORT ${PORT:-4000}
EXPOSE $PORT