Skip to content

Instantly share code, notes, and snippets.

View phillro's full-sized avatar

Phillip Rosen phillro

View GitHub Profile
@phillro
phillro / gist:1316827
Created October 26, 2011 16:07
Synonym file format
# blank lines and lines starting with pound are comments.
#Explicit mappings match any token sequence on the LHS of "=>"
#and replace with all alternatives on the RHS. These types of mappings
#ignore the expand parameter in the schema.
#Examples:
i-pod, i pod => ipod,
sea biscuit, sea biscit => seabiscuit
#Equivalent synonyms may be separated with commas and give
@phillro
phillro / gist:1317411
Created October 26, 2011 18:56
popup
<!-- BOTTOM POPUP -->
<div class="bottom-popup">
<span class="close" onclick="bottomClose();"></span>
<div class="top"></div>
<div class="center">
<div class="form">
<p class="notext">Subscribe to <strong>Portero Luxury</strong> for special offers plus an extra $50 off your first luxury purchase*</p>
<form action="" method="post" id="IBNSubscribeForm" class="bottom-subscribe-form">
<sample>
<test>asd</test>
<testtwo>asd</testtwo>
</sample>
var updateScore = function(count){
db.articles.find().sort({createdAt:-1}).limit(count).forEach(function (article) {
var referencing_tweets = 0
var oneDayAgo = new Date();
oneDayAgo.setDate(oneDayAgo.getDate() - 1);
var score = 0
if (article.referencing_tweets) {
for (var i = 0; i < article.referencing_tweets.length; i++) {
if (article.referencing_tweets[i].createdAt > oneDayAgo) {
referencing_tweets++
@phillro
phillro / gist:3724373
Created September 14, 2012 20:04
Problem with eval and server stored functions.
From mongo db console:
> db.system.js.save({_id:'_testFunc',value:function(a,b){db.testCol.save({a:a,b:b}); return 'hello world';}});
> db.system.js.find();
{ "_id" : "_testFunc", "value" : function cf__16__f_(a, b) {
db.testCol.save({a:a, b:b});
return "hello world";
} }
> db.eval("_testFunc(1,2)");
hello world
@phillro
phillro / gist:3829655
Created October 3, 2012 20:30
fuzzy_versus_bool_custom_score_with_geo
//Works
{ query:
{ custom_score:
{ query: {"match_all":{}},
params: {lat:43,lon:73},
script: '(1-(doc["geo"].distanceInKm(lat,lon)/maxDistance))*distanceWeight+scoreWeight*_score' } },
script_fields: { distance: { params:{lat:43,lon:73}, script: 'doc["geo"].distanceInKm(lat,lon)' } },
fields:
[ '_id',
'name',
@phillro
phillro / gist:3877832
Created October 12, 2012 07:43
pub cmd
conn.send(" V2");
var cmd = new Buffer("PUB test\n");
var body = new Buffer('hello world.');
var size = new Buffer(4)
size.writeInt16BE(body.length,0)
var msg = Buffer.concat([cmd, body,size]);
conn.send(msg);
/**
* User: philliprosen
* Date: 8/29/12
* Time: 3:35 PM
*/
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
var http = require('request')
, assert = require("assert")
, config = require('../../../common/config');
describe('api', function () {
describe('GET /api/users', function () {
it('should not return an error', function (done) {
http.get(config.distributor.routerPrefix + '/ping', function (err, res) {
@phillro
phillro / gist:4588595
Created January 21, 2013 19:33
Phillip Rosen public key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAry4dQzJut6BbxuCOEFdog6a6Si7SlGSw5qkSNRXS9I6iiadftsYHcAEk+M5fNWPK17RtMBilJpOA32NdjK8HLakXcDs0BWgAZcPsap3E9VCfxUKgRIYNLbThJwFwudXZLyfVF0MfRsRpvgZpYZ0ixPJCxAtCadQFFMj9aKeHk5QvcfJd4+VQ/cXzRKRe89qs6Po7SMBUHxXgISBORWfCQN/CESHh12e9CQCfd5MuYcUlKIRPfCpIDk6UjjADr3IrFUQE0ChUeSSp0ycmgSDGH/xHTp0k1NsTNgWjhLh8U7/YkG2z005mnRGza5ntFacjyk9XMzA92K3j4MvxY2lf2Q== phillro3