Skip to content

Instantly share code, notes, and snippets.

import java.awt.geom.Line2D;
import java.util.ArrayList;
import java.util.Random;
public class Polygon {
private ArrayList<Point> points = new ArrayList<Point>();
public static void main(String[] args) {
Polygon poly = new Polygon();
poly.randomPolygon();
Document.find({user-id: 10, money: {$gt: 20}}, function() {
collection.on("add", function(item) {
console.log(item.money) //40
})
Document.create({user-id:10, money: 40}) //collection should call onAdd and contain the new document automagically
}
var http = require('http')
, io = require('socket.io') // for npm, otherwise use require('./path/to/socket.io')
, clients = {}
, server = http.createServer(function(req, res){
// your normal server code
})
server.listen(80)
function sendToClient(id, message) {

this erb

  <ul class = "blogPosts">
    <% blogPosts.each |blogPost| %>
    <li class = "blogPost">
      <div class = "title"><%= blogPost.title %></div>
      <div class = "content"><%= blogPost.content %></div>
      <ul class = "comments">
        <% blogPost.comments.each |comment| %>
require('fibers')
function sleep(ms) {
var fiber = Fiber.current;
setTimeout(function() {
fiber.run()
}, ms)
yield()
}
@xcoderzach
xcoderzach / recommender.coffee
Created December 20, 2011 23:15 — forked from malgorithms/recommender.coffee
Fake Recommender class for CoffeeScript/tame discussion
```coffeescript
class Recommender
getRecommendations: (search_params, cb) ->
# Do 2 things at once:
# - check if we have a logged in user, get their info
# - fire off distributed requests for search queries
# ------------------------------------------------------------------------
@xcoderzach
xcoderzach / awaitApples.coffee
Created December 23, 2011 23:56
Awaiting Apples
# this is what it would look like,
# Every language feature that isn't a function has to be turned into one :-(
awaitWhile {apples: []}, ({apples}) -> numThatAreTasty(apples) < 10
, (await) ->
await (defer) -> getAnApple defer "apples[]"
, ({apples}) ->
console.log apples
awaitWhile {apples: [], numTasty:0}, ({numTasty}) -> numTasty < 10
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="biranorvm"
# Example aliases
func! MoveWithTmux(keypressed,direction)
let k = a:keypressed
let d = a:direction
" get the old window number
let oldw = winnr()
exec "wincmd " . k
let neww = winnr()
" If we are in the same split, we must be at a boundary so tell tmux to switch split
select-left () {
tmux select-pane -L
}
select-right () {
tmux select-pane -R
}
select-up () {
tmux select-pane -U
}