Skip to content

Instantly share code, notes, and snippets.

View axsuul's full-sized avatar

James Hu axsuul

View GitHub Profile
Animals.each do |letter, results|
10.times do
doc = Nokogiri::HTML(open("http://www.ocar.org/page.php?tut=realtor-affiliate-search-results&tid=802&pid=8&first_or_last_name=#{letter}&city=&office=&btc=&op=find_a_realtor&ftut=find-a-realtor&start=#{results_per_page}"))
realtors = {}
('a'..'z').each do |n|
realtors[n] = Realtor.create
end
doc.css('div.search_results_item').each do |number|
phone_number = /\(\d{3}\)\s\d{3}-\d{4}/.match("#{number.content}")
('a'..'z').each do |n|
<div style="line-height: 20px">
REP Code: <span style="color: #ff0000;"><strong><a href="http://www.promocodesforkarmaloop.com/action">ACTION</a></strong></span> - <strong>20% OFF ALL ITEMS</strong>
<small>No Minimum. No Restrictions. Doesn't expire.
OR Combine
Rep Code: <strong><a href="http://www.promocodesforkarmaloop.com/action">ACTION</a></strong> + ANY Karmaloop promo code for 21% OFF ALL ITEMS
</small></div>
@axsuul
axsuul / gist:1937145
Created February 29, 2012 02:41 — forked from azuby/gist:1937101

Method A: Carrier - Poor Location Precision, Secure

Method B: Client(phone) - High Location Precision, Insecure (Can be spoofed)

Option 1: Improve precision of Method A (Carrier Location)

  • Supports all phones on Tier 1 carriers
  • Find and correct for inaccuracy patterns

Option 2: Prevent spoofing of Method B (Client Location)

@axsuul
axsuul / index.html.erb
Created February 11, 2012 23:18 — forked from anirudhgaur/index.html.erb
sending values from javascript into ruby injection
<input type="button" onclick="myfunction()" value="NEWEdit" />
<script language="javascript" type="text/javascript">
$(function() {
$(document).on('click', '#edit', function() {
$('#he').text($('#posts').data('count'));
});
});
@shift_groups = @shifts.group_by(&:date).to_a.sort
2012-02-06
#<Shift:0x00000004b3f868>
2012-02-07
#<Shift:0x00000004a59b60>
#<Shift:0x00000004a59200>
#<Shift:0x00000004a58738>
2012-02-08
#<Shift:0x00000004a57db0>
@axsuul
axsuul / gist:1754674
Created February 6, 2012 20:38 — forked from vpamulap/gist:1754562
This is the code used to replace a recipe on a page using ajax.
______________________________________________
Link to Action in View:
______________________________________________
<%= link_to image_tag("refreshIcon.png"), replace_meal_queue_recipe_path(meal_queue_recipe), method: :post, remote: true %>
______________________________________________
Controller:
______________________________________________
class MealQueueRecipesController < ApplicationController
# GET /meal_queue_recipes
1: <ul>
2: <% Student.search("Jamie").each do |student| %>
3: <li><%= link_to Student.student_name,
4: :action => 'show', :id => Student.id %></li>
5: <td><%=h student.student_name %></td>
@axsuul
axsuul / student.rb
Created January 25, 2012 19:31 — forked from anonymous/search function
syntax error
class Student < ActiveRecord::Base
def self.search(query)
find(:all, :conditions => ['student_name LIKE ?', "%#{query}%"]) || []
end
end
$ ->
$(document).on 'click', '.sf-close a', ->
$(this).parent().parent().hide()
@axsuul
axsuul / gist:1294725
Created October 18, 2011 06:06 — forked from claudiolassala/gist:1294722
HTTParty parser
class Foo
include HTTParty
parser Proc.new {|data| ...}
end