#render string as slim template
example:
module WelcomeHelper
def tile_link_to(title, href, icon_content = nil, &block)
icon_content = capture { block.call }.strip.squish if block_given?
content = <<-slim
.tile
for i in `find . -name "feature-*" -type d`; do | |
nice=`echo $i | sed 's!^\.\/!\/!g'`; | |
pushd /Users/mark/Desktop/test$nice; | |
mv *.html ~/dev/stuff/app/views/feature/; | |
mv *.js ~/dev/stuff/app/assets/javascripts/; | |
mv css *.css ~/dev/stuff/app/assets/stylesheets/; | |
mv *.jpg *.png *.gif ~/dev/stuff/app/assets/images/; | |
popd; | |
done |
/^(?:[a-z\d!#\$%&'\*\+\-\/=\?\^_`\{\|\}~]+|\.)+@[a-z\d\-]+(?:\.[a-z\d\-]+)*$/i |
@import "twitter/bootstrap/bootstrap"; | |
body { | |
padding-top: 60px; | |
} | |
@import "twitter/bootstrap/responsive"; | |
// Set the correct sprite paths | |
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png'); | |
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png'); |
# lib/my-engine/simple-form.rb | |
require 'simple_form' | |
# https://gist.github.com/mark-d-holmberg/78f2909de5b59a09329c | |
# Use this setup block to configure all options available in SimpleForm. | |
SimpleForm.setup do |config| | |
# Wrappers are used by the form builder to generate a | |
# complete input. You can remove any component from the | |
# wrapper, change the order or even add your own to the |
### blogged @ http://dojo4.com/blog/easy-cheasy-realtime-log-tailing-in-a-rails-admin-view | |
### the su controller action | |
def logs | |
log = File.join(Rails.root, "log", "#{ Rails.env }.log") | |
@lines = `tail -1024 #{ log }`.split(/\n/).reverse |
I read about this problem and thought I would try it. Later I found it is a question here too: | |
https://codility.com/programmers/lessons/1-iterations/binary_gap/ | |
My first instinct was, "I know regex can do this, but I hate regex" (Which is also a good reason to get better at regex). | |
I couldn't quite hoop the syntax so I moved on. Here is what I came up with: | |
def max_binary_gap(n) | |
max_gap = 0 | |
arr = n.to_s(2).chars | |
while arr.size > 2 do |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
## based on https://gist.github.com/1910413 updated for Sublime Text 3 | |
import sublime | |
import sublime_plugin | |
import subprocess | |
class PromptRunExternalCommand(sublime_plugin.WindowCommand): |
/* bring in configs, and backends, like db */ | |
/* const config = require('config') */ | |
let healthy = true | |
setInterval(() => { | |
// check db pools, maybe run a query, etc. | |
try { | |
if (db.check_health()) { // but do this with a timelimit that is less than check interval seconds | |
healthy = true |
# When working on a project with multiple developers master will get ahead of your work. | |
# To come in sync should you rebase? merge? what is a fast-forward? Lots of discussion | |
# is available on this, here are a few: | |
# https://hackernoon.com/git-merge-vs-rebase-whats-the-diff-76413c117333 | |
# https://www.atlassian.com/git/tutorials/merging-vs-rebasing | |
# | |
# I prefer a merge/fast-forward, rather than rebase. These helpers assist in that process. | |
# LMK your thoughts and if you know of a better way! Enjoy! |
#render string as slim template
example:
module WelcomeHelper
def tile_link_to(title, href, icon_content = nil, &block)
icon_content = capture { block.call }.strip.squish if block_given?
content = <<-slim
.tile