This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i, result in enumerate(results): | |
result["rank"] = i | |
return results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User(Document): | |
__collection__ = 'users' | |
structure = { | |
'name': unicode, | |
'email': unicode, | |
'password': unicode, | |
'date_registered': datetime, | |
'acc_activated': bool, | |
'votes': [{ | |
"rel": ObjectId, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns gamble.core) | |
(defn coin-toss [] | |
(= 1 (rand-int 2))) | |
(defn toss-score [toss] | |
(if toss 1 -1)) | |
(defn t [] 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
================ <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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
get '/' do | |
# "Hello, world" | |
slim :email | |
end | |
doctype html | |
html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'slim' | |
get '/' do | |
slim :email | |
end | |
__END__ | |
!doctype html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'use!underscore', | |
'use!backbone', | |
'modules/models/rel' | |
], | |
function(_, Backbone, RelModel){ | |
var RelsCollection = Backbone.Collection.extend({ | |
// Reference to this collection's model. | |
model: RelModel, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn my-mult [a b] | |
(if (<= b 0) | |
0 | |
(+ a (my-mult [a (- b 1)])))) | |
(my-mult 28 28) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
OlderNewer