Skip to content

Instantly share code, notes, and snippets.

@jhjguxin
jhjguxin / content.markdown
Created August 14, 2012 07:06
AJAX Cross Domain Call - OK 200 but still getting Firebug / JQuery.js error

I trying to make a call to an external domain using $.ajax() and it WORKS, the server receives the call, but the response in firebug errors out in jquery.js line 7760. I've been beating my head at this all day and don't feel like I've made it much further.

I suspect it has something to do with the dataType or type of the request. But I've tried all kinds of things from POST to GET to JSONP in the type. For dataType, I've also tried "html", "text", "xml", "json", and even some combos of "text html" but no success.

cross-domain requests are only allowed for dataTypes "script" and "jsonp".

If your request is either of those, add the proper dataType option:

dataType: "jsonp" or

@jhjguxin
jhjguxin / new.html.erb
Created August 17, 2012 06:50
form verify base on bbtang.com
<!-- container S -->
<% content_for :shared_head do %>
<!--shared_head><shared_head-->
<% end %>
<div class="regist_box">
<div class="regist_header">
<h1 class="logo"><%= link_to "棒棒糖亲子问答社区", root_path %></h1>
<div class="login_nav">
<%= link_to "登录", new_user_session_path, :id => "login", class: "login_link" %><b class="line">|</b>
<span class="other_login">
@jhjguxin
jhjguxin / application.html.erb
Created August 20, 2012 08:23
seo and breadcrumbs defined demo base on bbtang.com
<% if title = get_seo_info("title") %>
<title><%= "#{title} #{ @default_title}" %></title>
<% else %>
<title><%= "#{ @default_title}" %></title>
<% end %>
<% if keywords = get_seo_info("keywords") %>
<meta name="keywords" content="<%= keywords %>">
<% else %>
<meta name="keywords" content="<%= Askjane::MetaCache.get_config_data("default_meta_keywords") %>" />
@jhjguxin
jhjguxin / demo.html
Created August 23, 2012 14:21
jquery autocomplete email input基于jQuery的input输入框下拉提示层,方便用户输入邮箱时的提示信息,需要的朋友可以参考下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://demo.jb51.net/js/2012/myinputMail/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="inputmail.js"></script>
<script type="text/javascript">
$(function(){
$("#loginName").changeTips({
divTip:".on_changes"
@jhjguxin
jhjguxin / smser.rb
Created August 27, 2012 00:40 — forked from mimosz/smser.rb
短信宝
# -*- encoding: utf-8 -*-
require 'digest/md5'
require 'nestful'
class Smsbao
attr_accessor :login, :passwd
def initialize(login, passwd)
@login = login
@passwd = Digest::MD5.hexdigest(passwd)
@jhjguxin
jhjguxin / common.js
Created August 27, 2012 07:33
bootstrap tooltips and popover demo base on BBTangCMS
// link Tooltips
$(document).ready(function() {
var $links;
$links = $('body').find('a[rel=tooltip]');
$links.each(function(i, e) {
var $e;
$e = $(e);
var title = $links[i].getAttribute("title");
if (title == "" || title == null ){
@jhjguxin
jhjguxin / deploy.rb
Created August 31, 2012 10:38 — forked from andruby/deploy.rb
Start and Stop tasks for resque workers, with capistrano deploy hook (without God)
after "deploy:symlink", "deploy:restart_workers"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
cmd = "cd #{fetch(:latest_release)} && #{fetch(:rake, "rake")} RAILS_ENV=#{fetch(:rails_env, "production")} #{rake_cmd}"
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
@jhjguxin
jhjguxin / Capistrano-Deployment-Recipe.rb
Created September 3, 2012 06:39 — forked from mrrooijen/Capistrano-Deployment-Recipe.rb
a "base" Capistrano Rails Deployment Recipe. Use it to deploy your Rails application. It is also easily expandable. So feel free to grab this Recipe and add your own tasks/customization!
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
@jhjguxin
jhjguxin / class_eval.rb
Created September 11, 2012 09:55
try class eval on rails model
#(Ruby - Using class_eval to define methods)[http://stackoverflow.com/questions/9561072/ruby-using-class-eval-to-define-methods]
class Class
def attr_accessor_with_history(attr_name)
attr_name = attr_name.to_s # make sure it's a string
attr_reader attr_name
attr_reader attr_name+"_history"
class_eval %Q"
def #{attr_name}=(value)
if !defined? @#{attr_name}_history
@#{attr_name}_history = [@#{attr_name}]