Skip to content

Instantly share code, notes, and snippets.

@smtm
smtm / gist:6375
Created August 20, 2008 14:32
ias ga
sel
day_date
,sum (xv_com_all.csb_subscriber_ga_disc.dly_gross_adds + xv_com_all.csb_subscriber_ga_disc.dly_reconnections)
from xv_com_all.csb_subscriber_ga_disc
where day_date between 1080801 and 1080818
and service_provider_id = 1
group by 1
a {
color: #3256B6;
}
a:visited {
color: #cc9;
}
a:hover, a:visited:hover {
color: #e00;
text-decoration: none;
}
#location controller
require 'csv'
web_method :csvimport do
def csvimport
unless params[:dump].nil?
@parsed_file=CSV::Reader.parse(params[:dump][:file])
n=0
@parsed_file.each do |row|
loc=Location.new
class LocationsController < ApplicationController
hobo_model_controller
auto_actions :all
require 'csv'
web_method :csvimport
def csvimport
#from application.dryml
<extend tag="new-page" for="Location">
<old-new-page merge>
<append-content-header:>
<div class="csvload">
<% form_for :dump, :url=>{:controller=>"locations", :action=>"create"}, :html => { :multipart => true } do |f| -%>
<%# form_tag '/upload', :html=>{:multipart =>true} %>
<label for="dump_file">CSV File:</label>
<%= file_field(:file, :file, :class => 'file_input')%>
<%= submit_tag 'Upload' -%> <br />
---A Method in Test_helper.rb
def login_pmtwo
u=User.new(:login =>"pmtwo",:password =>"secret",:administrator =>true)
post :login, :login=>'pmtwo', :password=>'secret'
end
---:projects_controller.rb
require File.dirname(__FILE__) + '/../test_helper'
class ProjectsControllerTest < ActionController::TestCase
@smtm
smtm / pk.sh
Created October 22, 2010 11:38
kills PeepOpen and TextMate, restarts Peepopen
#!/bin/bash
kill -9 `ps ax | grep PeepOpen | grep -v grep | awk '{print $1}'`
kill -9 `ps ax | grep TextMate | grep -v grep | awk '{print $1}'`
open /Applications/PeepOpen.app
echo restarted Peepopen, killed TextMate
@smtm
smtm / Mailchimp hominid playground
Created April 4, 2011 11:02
ruby person model to interface with mailchimp thru the hominid gem
person.rb methods
def self.initMailchimpList
#do the initial sync of all people in the DB for a customer with
#pushing it into one list
end
def syncMailchimpList
# we need the mailchimp api key on hotel level
# get the structure of the list
# see if we have the person in the mailchimp list
@smtm
smtm / prototype
Created April 13, 2011 16:41
What is the best way to do onload Script execution?
// onLoad Syntax with calling jQuery in "Person"
jQuery(function() {
var cheight=$("#content").height();
var nheight=$("#navbar").height();
if (cheight>nheight) {
$("#navbar").height(cheight);
}
});
// same as above, more terse, we assume jQuery loaded
@smtm
smtm / de.yml
Last active October 31, 2017 11:31
Parsing YAML in Rails i18n locale files to generate JSON for a javascript translation method
These are the code parts to grab related to this blog post.
Read more about it there
http://www.igumbi.com/en/blog/YAML-to-JSON-Rails-for-i18n-Language-Files
# The locale file structure de.yml
de:
obt: