Skip to content

Instantly share code, notes, and snippets.

>>> test
'\n\t\t\tCLG saintvicious\n League of Legends\n
\n 13,364 '
>>> test.split()[0] + ' | ' + test.split()[1]
'CLG | saintvicious'
>>> test.rsplit()[0] + ' | ' + test.rsplit()[1]
'CLG | saintvicious'
for i, result in enumerate(results):
result["rank"] = i
return results
@yedi
yedi / gist:1806444
Created February 12, 2012 04:57
mongokit document
class User(Document):
__collection__ = 'users'
structure = {
'name': unicode,
'email': unicode,
'password': unicode,
'date_registered': datetime,
'acc_activated': bool,
'votes': [{
"rel": ObjectId,
(ns gamble.core)
(defn coin-toss []
(= 1 (rand-int 2)))
(defn toss-score [toss]
(if toss 1 -1))
(defn t [] 1)
================ <tapp/__init__.py> =======================
from __future__ import with_statement
from contextlib import closing
from sqlite3 import dbapi2 as sqlite3
from flask import Flask, request, session, g, redirect, url_for, abort, \
render_template, flash, jsonify
# configuration
DATABASE = 'tmp/my.db'
require 'sinatra'
get '/' do
# "Hello, world"
slim :email
end
@@email
doctype html
html
require 'sinatra'
require 'slim'
get '/' do
slim :email
end
__END__
@@email
!doctype html
define([
'use!underscore',
'use!backbone',
'modules/models/rel'
],
function(_, Backbone, RelModel){
var RelsCollection = Backbone.Collection.extend({
// Reference to this collection's model.
model: RelModel,
(defn my-mult [a b]
(if (<= b 0)
0
(+ a (my-mult [a (- b 1)]))))
(my-mult 28 28)
(ns clojeuler.q1)
(defn sum-if-divisible [num1 num2]
(if (or (== (mod num2 3) 0) (== (mod num2 5) 0))
(+ num1 num2)
num1))
(println (reduce sum-if-divisible (range 1 1000)))
(println (reduce + (range 1 1000)))