Skip to content

Instantly share code, notes, and snippets.

View rn0's full-sized avatar
:bowtie:
testing

Piotr Kapera rn0

:bowtie:
testing
View GitHub Profile
@import "compass/utilities/sprites/base";
$toolbar-icon-sprites: sprite-map("icons/toolbar_*.png");
$sidebar-icon-sprites: sprite-map("icons/sidebar_*.png");
.toolbar-icon { background: $toolbar-icon-sprites; }
.sidebar-icon { background: $sidebar-icon-sprites; }
#toolbar {
@stengland
stengland / search.rb
Created January 24, 2011 12:41
Simple Mongo Mapper search using a map reduce for relevance ordering
module Noodall
module Search
STOPWORDS = ["about", "above", "above", "across", "after", "afterwards", "again", "against", "all", "almost", "alone", "along", "already", "also", "although", "always", "among", "amongst", "amoungst", "amount", "and", "another", "any", "anyhow", "anyone", "anything", "anyway", "anywhere", "are", "around", "back", "became", "because", "become", "becomes", "becoming", "been", "before", "beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "bill", "both", "bottom", "but", "call", "can", "cannot", "cant", "con", "could", "couldnt", "cry", "describe", "detail", "done", "down", "due", "during", "each", "eight", "either", "eleven", "else", "elsewhere", "empty", "enough", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly", "forty", "found", "four", "from", "front", "full", "further", "get", "give", "had", "has", "hasnt", "have",
@tekacs
tekacs / show
Created April 20, 2011 17:55
This does something essentially equivalent to showoff.io if you have a publicly facing server...
# Usage: show <local-port> <subdomain>
function show() {
DOMAIN=".tekacs.com"
REMOTE="$2$DOMAIN"
ssh -tR 1080:127.0.0.1:$1 vps "sudo ssh -Nl \$USER -L $REMOTE:80:127.0.0.1:1080 localhost"
}
@duarten
duarten / GetDuplicateAndMissing.cs
Created April 27, 2011 00:29
A solution to the mongoDB puzzle (http://goo.gl/A35lk)
//
// Given an array of N (can be very large) 64 bit integers where every integer 1-N
// appears once in the array, except there is one integer missing and one integer
// duplicated, find the missing and duplicated integers. The algorithm should run
// in linear time and in small constant space and leave the array untouched.
//
static void GetDuplicateAndMissing(long[] a, out long duplicate, out long missing)
{
long xor = 0; // duplicate ^ missing
# app/uploaders/avatar_uploader.rb
process :fix_exif_rotation
process :strip
process :resize_to_fill => [1024, 768]
process :quality => 90 # Percentage from 0 - 100
@karmi
karmi / percolated-twitter.rb
Created June 14, 2011 18:17
Reversed or “Real Time” Search in ElasticSearch
# Reversed or “Real Time” Search in ElasticSearch
# ====================================================================================
# You may have come across the term “realtime search” lately
# (eg. [here](http://engineering.socialcast.com/2011/05/realtime-search-solr-vs-elasticsearch/))
# and wondered what all the fuss is about.
#
# Well, the usual workflow with search engines goes like this:
#
# 1. You index some documents.
@alh3im
alh3im / gist:1053618
Created June 29, 2011 10:35
Ngram working sample
// Config
{
"index" : {
"analysis" : {
"filter" : {
"my_ngram" : {
"max_gram" : 20,
"min_gram" : 2,
"type" : "nGram"
}
@arian
arian / MoogPlus.js
Created July 1, 2011 20:15
A Google+ row selection effect with MooTools
var MoogPlus = new Class({
Extends: Fx.Morph,
options: {
rowSelector: '.row',
activeClass: 'active',
event: 'click',
'class': 'MoogPlus',
@timoxley
timoxley / js-bundler.coffee
Created July 20, 2011 05:42
Bundle all js files in ./scripts to ./application.js using Stitch
argv = process.argv.slice(2)
stitch = require('stitch')
fs = require('fs')
mode = argv[0] || "DEV"
package = stitch.createPackage
paths: [__dirname + '/scripts']
<?php
//... Product class code ...
public function addTags(\Khepin\ProductBundle\Entity\Tag $tags)
{
$this->tags[] = $tags;
$tags->setProduct($this);
}