Skip to content

Instantly share code, notes, and snippets.

@mrcwinn
mrcwinn / RaceSearchLive.ex
Created May 27, 2023 16:13
RaceSearchLive.ex
defmodule OutandbackWeb.RaceSearchLive do
use OutandbackWeb, :live_view
import Ecto.Query
alias Outandback.Events.Race
@per_page 9
def render(assigns) do
#!/usr/bin/env python
# encoding: utf-8
"""
captchasolver.py
This module provides mathematic captcha solvers.
Created by Pradeep Gowda on 2008-04-22.
Copyright (c) 2008 Watchdog.net. All rights reserved.
"""
def to_csv(options={})
header_row = [
'Response ID',
'Timestamp (MM/dd/yyyy)',
'Time Taken to Complete (Seconds)',
]
self.questions.each_with_index do |q, i|
header_row << "Q#{i+1}"
end
module RssHelper
def rss_links
body = HTTParty.get('http://blog.slimsurveys.com/feeds/posts/default?alt=rss')
items = []
begin
Nokogiri::XML(body).xpath('//item').slice(0, 5).each do |item|
items << content_tag(:a, item.xpath('title').inner_text, href: item.xpath('link').inner_text.to_s )
end
Mod.ChartView = Ember.View.extend({
tagName: 'canvas',
attributeBindings: ['width', 'height'],
width: '200px',
height: '200px',
didInsertElement: function() {
var project = this.get('context');
var issues = project.get('issues').toArray();
var data = [];
var closed = 0;
version :medium, :if => :is_landscape? do
process :resize_to_fit => [270, 0]
end
version :medium, :if => :is_landscape? do
process :resize_to_fit => [0, 270]
end
def is_landscape? picture
image = ::Magick::Image.read(picture.path).first
Template.project_issues.events = {
'keydown input[name="issue[title]"]': function(event) {
if(event.which == 13) {
Issues.insert({
title: event.target.value,
projectId: Session.get('currentProjectId'),
milestoneId: ''
});
event.target.value = '';
Template.project_issues.milestones = function() {
milestones = Milestones.find({projectId: Session.get('currentProjectId')}).fetch();
milestones.forEach(function(milestone) {
issues = Issues.find({projectId: Session.get('currentProjectId')}).fetch();
milestone.issues = [];
milestone.issues.push(issues);
});
return milestones;
# Controller
def publish
trip = Trip.find(params[:id])
trip.status = 'published'
trip.save!
redirect_to account_trips_path, notice: 'Your trip is now live!'
end
# Routes
@mrcwinn
mrcwinn / recurly.rb
Created March 13, 2013 16:27
Recurly
def coupon
begin
coupon = Recurly::Coupon.find(params[:code])
rescue
head 404
return
end
render json: coupon
end