Skip to content

Instantly share code, notes, and snippets.

@mark-d-holmberg
mark-d-holmberg / scraper-copy.sh
Created September 11, 2014 20:15
Copy files recursively
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
@kara-ryli
kara-ryli / email.regexp.js
Created March 25, 2010 17:17
The HTML5 e-mail address syntax.
/^(?:[a-z\d!#\$%&'\*\+\-\/=\?\^_`\{\|\}~]+|\.)+@[a-z\d\-]+(?:\.[a-z\d\-]+)*$/i
@mark-d-holmberg
mark-d-holmberg / bootstrap_and_overrides.css.less
Created January 12, 2013 03:48
How to fix Twitter Bootstrap Missing Icons
@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');
@mark-d-holmberg
mark-d-holmberg / simple_form.rb
Created January 22, 2016 00:22
Simple Form Bootstrap Ruby Engine Config
# 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
@ahoward
ahoward / tail-f.rb
Created March 7, 2012 16:44
completely k.i.s.s technique to do realtime log tailing in a live rails' app from the browser
### 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
@austra
austra / Largest Binary Gap
Last active December 14, 2017 21:23
Largest Binary Gap
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
@trigeorgis
trigeorgis / filter_through_command.py
Last active April 12, 2018 19:27 — forked from olifante/filter_through_command.py
Sublime Text 3: "Filter Through Command" plugin
#!/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
@srevenant
srevenant / .bashrc
Last active September 7, 2018 18:36
fast-forward git bash helpers
# 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!
@evg2108
evg2108 / string_as_slim_template.md
Last active February 4, 2019 06:41
render string as slim template

#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