Skip to content

Instantly share code, notes, and snippets.

View Paxa's full-sized avatar

Pavel Evstigneev Paxa

View GitHub Profile
#model
class Comment < ActiveRecord::Base
belongs_to :podcast
validates_presence_of :content
validates_presence_of :author_name
validates_presence_of :podcast_id
validates_length_of :author_name, :within => 2..40
validates_length_of :author_url, :within => 5..200, :allow_blank => true
validates_format_of :author_url, :with => /^[^\"\'\\]*$/,
:message => "can't include backslash or bracket"
class CommentsController < ApplicationController
def create
@podcast = Podcast.find params[:comment][:podcast_id]
params[:comment][:podcast_id] = nil
@comment = @podcast.comments.new params[:comment]
if @comment.save
flash[:notice] = "Comment writen"
redirect_to @podcast
else
@podcast = Podcast.find params[:comment][:podcast_id]
<?
#controller
$bdks = $this->db->select('distinct year as name')->where('site', $_REQUEST['siteid'])->get('pers_to_date')->result();
$this->my_view->view('admin/mailer/filter', array(
'users' => $users,
'total_rows' => $users_num,
'branches' => $this->db->get('branch')->result(), // бля, почему не branches ?
$$('.to_frame').each(function (el) {
var html = el.get('html');
var myIFrame = new IFrame({
src: '',
styles: {
width: el.getStyle('width'),
height: el.getStyle('height').toInt() + 3,
border: 0,
padding: 0
}
def file_tree files, sub = nil, &proc
res = "<ul #{'class="subdir"' if sub }>"
files.each do |file, value|
subdir = (value.class == Hash) ? file_tree(value, 1) { |a, b| proc.call a, b } : nil
res += proc.call file, subdir
end
res + '</ul>'
end
name: "QuickBox"
assets:
css:
- "css/quickbox.css"
js:
quickbox.js: general
a.js: "simple"
b.js: "simple, advaced"
c.js: "specific, advanced"
root@server-2:~/vertexdb# ./bin/compile2
source/basekit/source/UArray_character.c: In function ‘UArray_isalpha’:
source/basekit/source/UArray_character.c:16: warning: overflow in implicit constant conversion
source/basekit/source/UArray_character.c:16: warning: overflow in implicit constant conversion
source/basekit/source/UArray_character.c: In function ‘UArray_isdigit’:
source/basekit/source/UArray_character.c:18: warning: overflow in implicit constant conversion
source/basekit/source/UArray_character.c:18: warning: overflow in implicit constant conversion
source/basekit/source/UArray_character.c: In function ‘UArray_isgraph’:
source/basekit/source/UArray_character.c:19: warning: overflow in implicit constant conversion
source/basekit/source/UArray_character.c:19: warning: overflow in implicit constant conversion
/*
Script: mJSON.js
JSON encoder and decoder.
License:
MIT-style license.
See Also:
<http://www.json.org/>
#!/usr/bin/env ruby
# send request on website every 10 seconds
# checks request time and show growl notify and tell you by `say` if response time is more then 2 seconds
require 'rubygems'
require 'httparty'
require 'growl'
...
# including fix manualy, becouse loading lib/**/*.rb happends in Padrino.load!
require "lib/reloader_fix"
Padrino::Reloader::Stat.skip_folders = %W{photos utilites vertex-lib importers}
Padrino.load!