Skip to content

Instantly share code, notes, and snippets.

View martinthenext's full-sized avatar

Martin martinthenext

View GitHub Profile
@martinthenext
martinthenext / dufft
Created September 1, 2011 08:01
what.py
>>> class ca11able(object):
def __init__(self):
a = 2
def __call__(self):
a += 1
>>> c = ca11able
>>> c()
<__main__.ca11able object at 0x0000000002C949E8>
@martinthenext
martinthenext / gist:1214925
Created September 13, 2011 19:55
Такой вот код
AssemblyProperty (x1, x2, x3, x4, x5) <->
ClassOfIndividual(x1) &
ClassOfIndividual(x2) &
ClassOfIndirectProperty(x3)&
Scale(x4) &
ArithmeticNumber(x5) &
exists z (
ClassOfIndividual(z) &
SpecializationTemplate(x2, z) &
>>> def g(**d):
print d['argname']
>>> g(argname='argval')
argval
>>> def b(*z):
print z[0]
>>> b('Renata')
Renata
@martinthenext
martinthenext / gist:1300113
Created October 20, 2011 00:40
feature.m
X_norm = X;
mu = zeros(1, size(X, 2));
sigma = zeros(1, size(X, 2));
for featureIndex = 1:size(X, 2)
mu(1, featureIndex) = mean(X(:, featureIndex));
sigma(1, featureIndex) = std(X(:, featureIndex));
X_norm(:, featureIndex) = (X(:, featureIndex) .- mu(1, featureIndex)) ./ sigma(1, featureIndex)
end
J = 1 / m * (sum(-1 * y .* log(sigmoid(X * theta)) - (1 - y) .* log(sigmoid(X * theta)))) + lambda / (2 * m) * sum(theta(2:length(theta),:));
grad = X' * (sigmoid(X * theta) - y);
temp = theta;
temp(1) = 0;
grad = grad + (lambda / m) * temp;
J = 1 / m * (sum(-1 * y .* log(sigmoid(X * theta)) - (1 - y) .* log(sigmoid(X * theta)))) + lambda / (2 * m) * sum(theta(2:length(theta),:));
grad = 1 / m * X' * (sigmoid(X * theta) - y);
temp = theta;
temp(1) = 0;
grad = grad + (lambda / m) * temp;
J = 1 / m * (sum(-1 * y .* log(sigmoid(X * theta)) - (1 - y) .* log(sigmoid(X * theta)))) + lambda / (2 * m) * sum(theta(2:length(theta),:));
grad = 1 / m * X' * (sigmoid(X * theta) - y);
temp = theta;
temp(1) = 0;
grad = grad + (lambda / m) * temp;
D:\Projects\couch-jquery\pairs>node "C:\Program Files (x86)\nodejs\node_modules\
couchapp\bin.js" push D:\Projects\couch-jquery\pairs\app.js
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'couchapp'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
<!DOCTYPE html>
<html>
<head>
<style>
p { color:red; margin:5px; cursor:pointer; }
p.hilite { background:yellow; }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="/_utils/script/sha1.js"></script>
<script src="/_utils/script/json2.js"></script>
# -*- coding: utf8 -*-
import random
class Game(object):
def __init__(self):
self.options = [
'7 - counts',
'9 - theme',
'10 - question',
'J - condition',