Skip to content

Instantly share code, notes, and snippets.

View yelvert's full-sized avatar

Taylor Yelverton yelvert

  • VitalEngine
  • Alabama
View GitHub Profile
tweet = "What a great night, awesome drinks. :-)"
emoticon_list = ['\:\)', '\:\-\)']
emoticon_regex = Regexp.new("(#{emoticon_list.join('|')})")
tweet.gsub!(emoticon_regex, ' \1 ')
tokens = tweet.split
tokens.compact!
tokens.each do |token|
puts token
is_emoticon = !!(token =~ emoticon_regex)
puts is_emoticon
tweet = "What a great night, awesome drinks. :-)"
punctuation_regex = Regexp.new('([^\w\d\s]+)')
tweet.gsub!(punctuation_regex, ' \1 ')
tokens = tweet.split
tokens.compact!
tokens.each do |token|
is_punctuation = !!(token =~ punctuation_regex)
end
@yelvert
yelvert / yelvert.zsh-theme
Created April 17, 2012 22:18
yelvert ZSH Theme
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[cyan]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_bold[red]%}✗%{$fg_bold[cyan]%}]"
ZSH_THEME_GIT_PROMPT_CLEAN="]"
function yelvert_prompt {
rvm_info="%{$fg_bold[blue]%}($(rvm-prompt i v g s))"
git_info="$(git_prompt_info)"
d="%{$fg_bold[yellow]%}[$(date)]"
<textarea data-attribute="antibiotics" class="ui-autocomplete-input" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem" style="z-index: 102; top: 0px; left: 0px; display: none; "></ul>
</textarea>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.0</real>
<key>Green Component</key>
<real>0.0</real>
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int min = 0;
int max;
while (max < 1) {
cout << "Table from 0 through (enter 1-10): ";
<%= semantic_form_for @facility, :html => {:multipart => true} do |form| %>
<%= form.semantic_errors %>
<%= form.inputs do %>
<%= form.inputs :for => :facility_logo do |flform| %>
<%= flform.input :uploaded_data, :as => :file %>
<% end %>
<%= form.inputs "Settings", :for => :facility_setting do |settings| %>
<%= form.inputs "Facility Information" do %>
<%= settings.input :time_zone, :as => :select, :collection => TimeZone.us_zones.collect {|x| x.name} %>
<% end %>
Parameters: {"query"=>{"searchable_columns"=>["id", "name", "content", "test_1"], "search"=>"w"}}
x = []
query[:searchable_columns].each do |column|
x << Widget.arel_table[column.to_sym].matches("%#{query[:search]}%")
end
@widgets = Widget.where(x.inject(&:or))
Widget Load (2.5ms) SELECT "widgets".* FROM "widgets" WHERE (((("widgets"."id" LIKE 0 OR "widgets"."name" LIKE '%w%') OR "widgets"."content" LIKE '%w%') OR "widgets"."test_1" LIKE '%w%'))
@yelvert
yelvert / mongoid embedded build fail
Created October 20, 2010 06:16
mongoid building an embedded many document with a references_many in it saves when it shouldn't
class Formula
include Mongoid::Document
referenced_in :formula_category
field :quantities, :type => Array, :default => []
field :directions, :type => String
embeds_many :formula_medications
end
re_date_char = /^(?:((((J|j)an(uary)?|(M|m)a(r(ch)?|y)|(J|j)ul(y)?|(A|a)ug(ust)?|(O|o)ct(ober)?|(D|d)ec(ember)?)\ 31)|(((J|j)an(uary)?|(M|m)a(r(ch)?|y)|(A|a)pr(il)?|(J|j)u((ly?)|(ne?))|(A|a)ug(ust)?|(O|o)ct(ober)?|((S|s)ept|(N|n)ov|(D|d)ec)(ember)?)\ (0?[1-9]|([12]\d)|30))|((F|f)eb(ruary)?\ (0?[1-9]|1\d|2[0-8]|(29(?=,\ ((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))))\,\ ((1[6-9]|[2-9]\d)\d{2}))/