Skip to content

Instantly share code, notes, and snippets.

View Aeon's full-sized avatar
🦴

Anton Stroganov Aeon

🦴
View GitHub Profile
function fitStringToSize(str,len) {
var result = str;
var span = document.createElement("span");
span.style.visibility = 'hidden';
span.style.padding = '0px';
document.body.appendChild(span);
// on first run, check if string fits into the length already.
span.innerHTML = result;
if(span.offsetWidth > len) {
# forums_controller.rb
# in show:
@topic_pages, @topics = paginate(:topics, :per_page => 23, :conditions => ['forum_id = ?', @forum.id], :order => 'sticky desc, replied_at desc', :select => 'topics.*, IF(unread_user_topics.user_id IS NOT NULL,1,0) AS unread, users.display_name AS last_reply_author', :joins => "LEFT JOIN unread_user_topics ON topics.id = unread_user_topics.topic_id AND unread_user_topics.user_id = #{current_user.id} LEFT JOIN users ON topics.replied_by = users.id")
# application_helper.rb
# used to know if a topic has changed since we read it last
def recent_topic_activity(topic)
return false if not logged_in?
class Segment < ActiveRecord::Base
has_many :street_segments
has_many :streets, :through => :street_segments, :source => :street
after_save :ensure_primary
def ensure_primary
if self.streets.size > 0 && self.primary_street.nil?
# set the primary street attribute in association (in reality more criteria than just being 'first', but whatever)
primary_street = self.street_segments.first
package loganalysis;
import java.util.Map;
import java.util.Properties;
import cascading.cascade.Cascade;
import cascading.cascade.CascadeConnector;
import cascading.cascade.Cascades;
import cascading.flow.Flow;
import cascading.flow.FlowConnector;
@Aeon
Aeon / 960gs.less
Created March 1, 2010 07:41 — forked from Artanis/960gs.less
LessCSS and 960gs don't play well together normally. Here's the definitions for 960gs to let LessCSS work with it. Looks like we can pull all grid data out of the HTML.
/**
* A LessCSS version of the 960 Grid System
*
* http://lesscss.org/
* http://960.gs/
*/
/*********************************************************************
* Settings *
*********************************************************************/
@Aeon
Aeon / README.markdown
Created May 7, 2010 11:55 — forked from grosser/README.markdown
git-stats

Ever wondered how much who adds/removes, its time to find out :D (those are real stats, i just obfuscated the names )

###Results

Git scores (in LOC):
mr-add              :  +482273       -9466
justu               :  +286250       -159905
grosser             :  +152384       -323344

another : +121257 -82116

server {
listen *:80;
server_name nt.nyxcouture.com;
server_name nikatang.com;
location / {
root /var/www/vhosts/nikatang/current;
index index.php index.html index.htm;
}
Image.class_eval do
attachment_definitions[:attachment][:styles] = {
:thumb => '60x90',
:mini => '100x150',
:small => '220x330>',
:product => '340x510>',
:large => '860x860>' }
end
--------------------------------------------------------------
--- When filling out the review form please mind
--- the following rules:
--- (1) Lines beginning with "---" are comments.
--- Do not start lines in your review with ---
--- as they will be ignored. You can add comments to the
--- review form or remove them.
--- (2) Lines beginning with "***" are used by the system. Do not
--- remove or modify these lines or the review will become
--- unusable and will be rejected.
@Aeon
Aeon / convert.sh
Created October 6, 2011 01:15
convert file comments from cyrillic to unicode
mkdir conv;
find . -type f -name '*.php' -exec bash -c 'iconv -f windows-1251 -t utf-8 "{}" > ./conv/"{}"' \;