id stringlengths 34 124 | type stringclasses 4
values | prompt stringlengths 0 4.95k | response stringlengths 21 4.89k | source_lang stringclasses 3
values | target_lang stringclasses 2
values | repo stringclasses 75
values | path stringlengths 10 88 | license stringclasses 1
value | commit stringlengths 40 40 | stars int64 431 18.7k | source_url stringlengths 86 176 | line_start int64 1 214 | line_end int64 3 253 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gss/engine:src/domains/Linear.coffee:6:raw_corpus | raw_corpus | Linear.hack = ->
unless c.isUnordered?
obj = {9: 1, 10: 1}
for property of obj
break
if c.isUnordered = (property == 10)
set = c.HashTable.prototype.set
c.HashTable.prototype.set = ->
if !@_store.push
store = @_store
@_store = []
for property of stor... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | fbe4b4a9d1baf5edd4f1f809ed2b2824e3d23864 | 2,854 | https://github.com/gss/engine/blob/fbe4b4a9d1baf5edd4f1f809ed2b2824e3d23864/src/domains/Linear.coffee | 189 | 203 | ||
gss/engine:src/domains/Linear.coffee:6:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Linear.hack = ->
unless c.isUnordered?
obj = {9: 1, 10: 1}
for property of obj
break
if c.isUnordered = (property == 10)
set = c.HashTable.prototype.set
c.HashTable.prototype.set = ->
if !@_store.push
store = @_st... | Linear.hack = function() {
var obj, property, set;
if (c.isUnordered == null) {
obj = {
9: 1,
10: 1
};
for (property in obj) {
break;
}
if (c.isUnordered = property === 10) {
set = c.HashTable.prototype.set;
return c.HashTable.prototype.set = function() {
va... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | fbe4b4a9d1baf5edd4f1f809ed2b2824e3d23864 | 2,854 | https://github.com/gss/engine/blob/fbe4b4a9d1baf5edd4f1f809ed2b2824e3d23864/src/domains/Linear.coffee | 189 | 203 |
gss/engine:src/domains/Linear.coffee:6:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Linear.hack = function() {
var obj, property, set;
if (c.isUnordered == null) {
obj = {
9: 1,
10: 1
};
for (property in obj) {
break;
}
if (c.isUnordered = property === 10) {
set = c.HashTable.prototype.set;
ret... | Linear.hack = ->
unless c.isUnordered?
obj = {9: 1, 10: 1}
for property of obj
break
if c.isUnordered = (property == 10)
set = c.HashTable.prototype.set
c.HashTable.prototype.set = ->
if !@_store.push
store = @_store
@_store = []
for property of stor... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | fbe4b4a9d1baf5edd4f1f809ed2b2824e3d23864 | 2,854 | https://github.com/gss/engine/blob/fbe4b4a9d1baf5edd4f1f809ed2b2824e3d23864/src/domains/Linear.coffee | 189 | 203 |
gss/engine:src/domains/Linear.coffee:6:completion | completion | Linear.hack = ->
unless c.isUnordered?
obj = {9: 1, 10: 1}
for property of obj
break
if c.isUnordered = (property == 10)
set = c.HashTable.prototype.set | c.HashTable.prototype.set = ->
if !@_store.push
store = @_store
@_store = []
for property of store
@_store[property] = store[property]
return set.apply(@, arguments) | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | fbe4b4a9d1baf5edd4f1f809ed2b2824e3d23864 | 2,854 | https://github.com/gss/engine/blob/fbe4b4a9d1baf5edd4f1f809ed2b2824e3d23864/src/domains/Linear.coffee | 189 | 203 |
gss/engine:src/domains/Linear.coffee:1:raw_corpus | raw_corpus | class Linear extends Domain
priority: 0
Solver: require('cassowary')
setup: () ->
super
unless @solver
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 2
c.debug = true
c.trace = true
c.Strength.require = c.S... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6c90d732e4711634c0d3beaec9c42575179b585d | 2,854 | https://github.com/gss/engine/blob/6c90d732e4711634c0d3beaec9c42575179b585d/src/domains/Linear.coffee | 6 | 55 | ||
gss/engine:src/domains/Linear.coffee:1:completion | completion | class Linear extends Domain
priority: 0
Solver: require('cassowary')
setup: () ->
super
unless @solver
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 2
c.debug = true
c.trace = true
c.Strength.require = c.S... | @suggested = undefined
@solver.resolve()
return @solver._changed
unedit: (variable) ->
if constraint = @editing?['%' + (variable.name || variable)]
#@solver.removeConstraint(constraint)
cei = @solver._editVarMap.get(constraint.variable);
@solver.removeColumn(cei.editMinus);
@s... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6c90d732e4711634c0d3beaec9c42575179b585d | 2,854 | https://github.com/gss/engine/blob/6c90d732e4711634c0d3beaec9c42575179b585d/src/domains/Linear.coffee | 6 | 55 |
gss/engine:src/domains/Linear.coffee:4:raw_corpus | raw_corpus | Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6c90d732e4711634c0d3beaec9c42575179b585d | 2,854 | https://github.com/gss/engine/blob/6c90d732e4711634c0d3beaec9c42575179b585d/src/domains/Linear.coffee | 135 | 184 | ||
gss/engine:src/domains/Linear.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ... | var splice = [].splice;
Linear.prototype.Variable.Expression = Variable.Expression.extend(Linear.Mixin, {
'+': function(left, right) {
return c.plus(left, right);
},
'-': function(left, right) {
return c.minus(left, right);
},
'*': function(left, right) {
return c.times(left, right);
},
'/': ... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | 6c90d732e4711634c0d3beaec9c42575179b585d | 2,854 | https://github.com/gss/engine/blob/6c90d732e4711634c0d3beaec9c42575179b585d/src/domains/Linear.coffee | 135 | 184 |
gss/engine:src/domains/Linear.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var splice = [].splice;
Linear.prototype.Variable.Expression = Variable.Expression.extend(Linear.Mixin, {
'+': function(left, right) {
return c.plus(left, right);
},
'-': function(left, right) {
return c.minus(left, right);
},
'*': function(left,... | Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6c90d732e4711634c0d3beaec9c42575179b585d | 2,854 | https://github.com/gss/engine/blob/6c90d732e4711634c0d3beaec9c42575179b585d/src/domains/Linear.coffee | 135 | 184 |
gss/engine:src/domains/Linear.coffee:4:completion | completion | Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints... | [
operation[1].command.solve(engine, operation[1], '', undefined, undefined, operation[0])
engine,
operation
]
Linear::Stay = Command.extend {
signature: [
value: ['Variable']
]
},
stay: (value, engine, operation) ->
engine.suggested = true;
engine.solver.addStay(value)
... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6c90d732e4711634c0d3beaec9c42575179b585d | 2,854 | https://github.com/gss/engine/blob/6c90d732e4711634c0d3beaec9c42575179b585d/src/domains/Linear.coffee | 135 | 184 |
gss/engine:src/domains/Linear.coffee:1:raw_corpus | raw_corpus | class Linear extends Domain
priority: 0
Solver: require('cassowary')
setup: () ->
super
unless @solver
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.Strength.require = c.S... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 093139610e2d878a6ec4a8bd2fe6a2a417ac641a | 2,854 | https://github.com/gss/engine/blob/093139610e2d878a6ec4a8bd2fe6a2a417ac641a/src/domains/Linear.coffee | 6 | 55 | ||
gss/engine:src/domains/Linear.coffee:1:completion | completion | class Linear extends Domain
priority: 0
Solver: require('cassowary')
setup: () ->
super
unless @solver
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.Strength.require = c.S... | @suggested = undefined
@solver.resolve()
return @solver._changed
unedit: (variable) ->
if constraint = @editing?['%' + (variable.name || variable)]
#@solver.removeConstraint(constraint)
cei = @solver._editVarMap.get(constraint.variable);
@solver.removeColumn(cei.editMinus);
@s... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 093139610e2d878a6ec4a8bd2fe6a2a417ac641a | 2,854 | https://github.com/gss/engine/blob/093139610e2d878a6ec4a8bd2fe6a2a417ac641a/src/domains/Linear.coffee | 6 | 55 |
gss/engine:src/domains/Linear.coffee:2:raw_corpus | raw_corpus | variable.value = 0
#if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, con... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 699a88c41548542beea38760dba2ecf6deecec77 | 2,854 | https://github.com/gss/engine/blob/699a88c41548542beea38760dba2ecf6deecec77/src/domains/Linear.coffee | 56 | 84 | ||
gss/engine:src/domains/Linear.coffee:2:completion | completion | variable.value = 0
#if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, con... | @suggested = true
return variable
variable: (name) ->
return new c.Variable name: name
strength: (strength, byDefault = 'medium') ->
return strength && c.Strength[strength] || c.Strength[byDefault]
weight: (weight, operation) ->
if index = operation?.parent[0].index
return index / 1000
... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 699a88c41548542beea38760dba2ecf6deecec77 | 2,854 | https://github.com/gss/engine/blob/699a88c41548542beea38760dba2ecf6deecec77/src/domains/Linear.coffee | 56 | 84 |
gss/engine:src/domains/Linear.coffee:1:raw_corpus | raw_corpus | class Linear extends Domain
priority: 0
Solver: require('cassowary')
setup: () ->
super
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.Stre... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 4c4f57ebcdfafcfcd0452b69add4034e5dde3c21 | 2,854 | https://github.com/gss/engine/blob/4c4f57ebcdfafcfcd0452b69add4034e5dde3c21/src/domains/Linear.coffee | 6 | 55 | ||
gss/engine:src/domains/Linear.coffee:1:completion | completion | class Linear extends Domain
priority: 0
Solver: require('cassowary')
setup: () ->
super
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.Stre... | @suggested = undefined
@solver.resolve()
return @solver._changed
unedit: (variable) ->
if constraint = @editing?['%' + (variable.name || variable)]
#@solver.removeConstraint(constraint)
cei = @solver._editVarMap.get(constraint.variable);
@solver.removeColumn(cei.editMinus);
@s... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 4c4f57ebcdfafcfcd0452b69add4034e5dde3c21 | 2,854 | https://github.com/gss/engine/blob/4c4f57ebcdfafcfcd0452b69add4034e5dde3c21/src/domains/Linear.coffee | 6 | 55 |
gss/engine:src/domains/Linear.coffee:2:raw_corpus | raw_corpus | variable.value = 0
#if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, con... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 4c4f57ebcdfafcfcd0452b69add4034e5dde3c21 | 2,854 | https://github.com/gss/engine/blob/4c4f57ebcdfafcfcd0452b69add4034e5dde3c21/src/domains/Linear.coffee | 56 | 83 | ||
gss/engine:src/domains/Linear.coffee:2:completion | completion | variable.value = 0
#if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, con... | return variable
variable: (name) ->
return new c.Variable name: name
strength: (strength, byDefault = 'medium') ->
return strength && c.Strength[strength] || c.Strength[byDefault]
weight: (weight, operation) ->
if index = operation?.parent[0].index
return index / 1000
return weight
# Cap... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 4c4f57ebcdfafcfcd0452b69add4034e5dde3c21 | 2,854 | https://github.com/gss/engine/blob/4c4f57ebcdfafcfcd0452b69add4034e5dde3c21/src/domains/Linear.coffee | 56 | 83 |
gss/engine:src/domains/Linear.coffee:1:raw_corpus | raw_corpus | class Linear extends Domain
priority: 0
Solver: require('cassowary')
setup: () ->
super
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.Stre... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 54c3624b5e66b9bdb5546a5e34906df0fde1bbc6 | 2,854 | https://github.com/gss/engine/blob/54c3624b5e66b9bdb5546a5e34906df0fde1bbc6/src/domains/Linear.coffee | 6 | 55 | ||
gss/engine:src/domains/Linear.coffee:1:completion | completion | class Linear extends Domain
priority: 0
Solver: require('cassowary')
setup: () ->
super
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.Stre... | @suggested = undefined
@solver.resolve()
return @solver._changed
unedit: (variable) ->
if constraint = @editing?['%' + (variable.name || variable)]
#@solver.removeConstraint(constraint)
cei = @solver._editVarMap.get(constraint.variable);
@solver.removeColumn(cei.editMinus);
@s... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 54c3624b5e66b9bdb5546a5e34906df0fde1bbc6 | 2,854 | https://github.com/gss/engine/blob/54c3624b5e66b9bdb5546a5e34906df0fde1bbc6/src/domains/Linear.coffee | 6 | 55 |
gss/engine:src/domains/Linear.coffee:2:raw_corpus | raw_corpus | #if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, continuation)
@solver.... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 54c3624b5e66b9bdb5546a5e34906df0fde1bbc6 | 2,854 | https://github.com/gss/engine/blob/54c3624b5e66b9bdb5546a5e34906df0fde1bbc6/src/domains/Linear.coffee | 56 | 82 | ||
gss/engine:src/domains/Linear.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
#if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@ed... | //if full
//@solver.rows.delete(variable)
({
suggest: function(path, value, strength, weight, continuation) {
var variable;
if (typeof path === 'string') {
if (!(variable = this.variables[path])) {
variable = this.Variable.prototype.declare(this, path);
}
} else {
variable = path... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | 54c3624b5e66b9bdb5546a5e34906df0fde1bbc6 | 2,854 | https://github.com/gss/engine/blob/54c3624b5e66b9bdb5546a5e34906df0fde1bbc6/src/domains/Linear.coffee | 56 | 82 |
gss/engine:src/domains/Linear.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
//if full
//@solver.rows.delete(variable)
({
suggest: function(path, value, strength, weight, continuation) {
var variable;
if (typeof path === 'string') {
if (!(variable = this.variables[path])) {
variable = this.Variable.prototype.declare(... | #if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, continuation)
@solver.... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 54c3624b5e66b9bdb5546a5e34906df0fde1bbc6 | 2,854 | https://github.com/gss/engine/blob/54c3624b5e66b9bdb5546a5e34906df0fde1bbc6/src/domains/Linear.coffee | 56 | 82 |
gss/engine:src/domains/Linear.coffee:2:completion | completion | #if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, continuation)
@solver.... | return variable
variable: (name) ->
return new c.Variable name: name
strength: (strength, byDefault = 'medium') ->
return strength && c.Strength[strength] || c.Strength[byDefault]
weight: (weight, operation) ->
if index = operation?.parent[0].index
return index / 1000
return weight
# Cap... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 54c3624b5e66b9bdb5546a5e34906df0fde1bbc6 | 2,854 | https://github.com/gss/engine/blob/54c3624b5e66b9bdb5546a5e34906df0fde1bbc6/src/domains/Linear.coffee | 56 | 82 |
gss/engine:src/domains/Linear.coffee:2:raw_corpus | raw_corpus | #if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, continuation)
@solver.... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6a58b41bad01c4f4c7c64e670394ffd607937fc3 | 2,854 | https://github.com/gss/engine/blob/6a58b41bad01c4f4c7c64e670394ffd607937fc3/src/domains/Linear.coffee | 56 | 82 | ||
gss/engine:src/domains/Linear.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
#if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@ed... | //if full
//@solver.rows.delete(variable)
({
suggest: function(path, value, strength, weight, continuation) {
var variable;
if (typeof path === 'string') {
if (!(variable = this.variables[path])) {
variable = this.Variable.prototype.declare(this, path);
}
} else {
variable = path... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | 6a58b41bad01c4f4c7c64e670394ffd607937fc3 | 2,854 | https://github.com/gss/engine/blob/6a58b41bad01c4f4c7c64e670394ffd607937fc3/src/domains/Linear.coffee | 56 | 82 |
gss/engine:src/domains/Linear.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
//if full
//@solver.rows.delete(variable)
({
suggest: function(path, value, strength, weight, continuation) {
var variable;
if (typeof path === 'string') {
if (!(variable = this.variables[path])) {
variable = this.Variable.prototype.declare(... | #if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, continuation)
@solver.... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6a58b41bad01c4f4c7c64e670394ffd607937fc3 | 2,854 | https://github.com/gss/engine/blob/6a58b41bad01c4f4c7c64e670394ffd607937fc3/src/domains/Linear.coffee | 56 | 82 |
gss/engine:src/domains/Linear.coffee:2:completion | completion | #if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, continuation)
@solver.... | return variable
variable: (name) ->
return new c.Variable name: name
strength: (strength, byDefault = 'medium') ->
return strength && c.Strength[strength] || c.Strength[byDefault]
weight: (weight, operation) ->
if index = operation?.parent[0].index
return 1 - index / 1000
return weight
#... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6a58b41bad01c4f4c7c64e670394ffd607937fc3 | 2,854 | https://github.com/gss/engine/blob/6a58b41bad01c4f4c7c64e670394ffd607937fc3/src/domains/Linear.coffee | 56 | 82 |
gss/engine:src/domains/Linear.coffee:2:raw_corpus | raw_corpus | #if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, continuation)
@solver.... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6dae7b8e2f0918f6320f895965a8d2079eb0ce47 | 2,854 | https://github.com/gss/engine/blob/6dae7b8e2f0918f6320f895965a8d2079eb0ce47/src/domains/Linear.coffee | 56 | 80 | ||
gss/engine:src/domains/Linear.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
#if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@ed... | //if full
//@solver.rows.delete(variable)
({
suggest: function(path, value, strength, weight, continuation) {
var variable;
if (typeof path === 'string') {
if (!(variable = this.variables[path])) {
variable = this.Variable.prototype.declare(this, path);
}
} else {
variable = path... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | 6dae7b8e2f0918f6320f895965a8d2079eb0ce47 | 2,854 | https://github.com/gss/engine/blob/6dae7b8e2f0918f6320f895965a8d2079eb0ce47/src/domains/Linear.coffee | 56 | 80 |
gss/engine:src/domains/Linear.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
//if full
//@solver.rows.delete(variable)
({
suggest: function(path, value, strength, weight, continuation) {
var variable;
if (typeof path === 'string') {
if (!(variable = this.variables[path])) {
variable = this.Variable.prototype.declare(... | #if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, continuation)
@solver.... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6dae7b8e2f0918f6320f895965a8d2079eb0ce47 | 2,854 | https://github.com/gss/engine/blob/6dae7b8e2f0918f6320f895965a8d2079eb0ce47/src/domains/Linear.coffee | 56 | 80 |
gss/engine:src/domains/Linear.coffee:2:completion | completion | #if full
#@solver.rows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
unless variable = @variables[path]
variable = @Variable::declare(@, path)
else
variable = path
@edit(variable, strength, weight, continuation)
@solver.... | @suggested = true
return variable
variable: (name) ->
return new c.Variable name: name
strength: (strength, byDefault = 'medium') ->
return strength && c.Strength[strength] || c.Strength[byDefault]
weight: (weight) ->
return weight
# Capture values coming from other domains | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6dae7b8e2f0918f6320f895965a8d2079eb0ce47 | 2,854 | https://github.com/gss/engine/blob/6dae7b8e2f0918f6320f895965a8d2079eb0ce47/src/domains/Linear.coffee | 56 | 80 |
gss/engine:src/domains/Linear.coffee:3:raw_corpus | raw_corpus | Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constraint.extend {
before: (args, engine, operation, continua... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6dae7b8e2f0918f6320f895965a8d2079eb0ce47 | 2,854 | https://github.com/gss/engine/blob/6dae7b8e2f0918f6320f895965a8d2079eb0ce47/src/domains/Linear.coffee | 81 | 130 | ||
gss/engine:src/domains/Linear.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constrai... | Linear.Mixin = {
yield: function(result, engine, operation, continuation, scope, ascender) {
if (typeof result === 'number') {
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require');
}
}
};
Linear.prototype.Constraint = Constraint.extend({
before:... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | 6dae7b8e2f0918f6320f895965a8d2079eb0ce47 | 2,854 | https://github.com/gss/engine/blob/6dae7b8e2f0918f6320f895965a8d2079eb0ce47/src/domains/Linear.coffee | 81 | 130 |
gss/engine:src/domains/Linear.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Linear.Mixin = {
yield: function(result, engine, operation, continuation, scope, ascender) {
if (typeof result === 'number') {
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require');
}
}
};
Line... | Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constraint.extend {
before: (args, engine, operation, continua... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6dae7b8e2f0918f6320f895965a8d2079eb0ce47 | 2,854 | https://github.com/gss/engine/blob/6dae7b8e2f0918f6320f895965a8d2079eb0ce47/src/domains/Linear.coffee | 81 | 130 |
gss/engine:src/domains/Linear.coffee:3:completion | completion | Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constraint.extend {
before: (args, engine, operation, continua... | eject: (engine, constraint) ->
engine.solver.removeConstraint(constraint)
},
'==': (left, right, strength, weight, engine) ->
return new c.Equation(left, right, engine.strength(strength), engine.weight(weight))
'<=': (left, right, strength, weight, engine) ->
return new c.Inequality(left, c.LEQ, right... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 6dae7b8e2f0918f6320f895965a8d2079eb0ce47 | 2,854 | https://github.com/gss/engine/blob/6dae7b8e2f0918f6320f895965a8d2079eb0ce47/src/domains/Linear.coffee | 81 | 130 |
gss/engine:src/domains/Linear.coffee:1:raw_corpus | raw_corpus | class Linear extends Domain
priority: 0
Solver: require('cassowary')
setup: () ->
super
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.Stre... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 9bc92c72147758363e34d02c9ed4fbfe84e5afd6 | 2,854 | https://github.com/gss/engine/blob/9bc92c72147758363e34d02c9ed4fbfe84e5afd6/src/domains/Linear.coffee | 6 | 55 | ||
gss/engine:src/domains/Linear.coffee:1:completion | completion | class Linear extends Domain
priority: 0
Solver: require('cassowary')
setup: () ->
super
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.Stre... | @suggested = undefined
@solver.resolve()
return @solver._changed
unedit: (variable) ->
if constraint = @editing?['%' + variable.name]
cei = @solver._editVarMap.get(constraint.variable);
@solver.removeColumn(cei.editMinus);
@solver._editVarMap.delete(constraint.variable);
#@r... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 9bc92c72147758363e34d02c9ed4fbfe84e5afd6 | 2,854 | https://github.com/gss/engine/blob/9bc92c72147758363e34d02c9ed4fbfe84e5afd6/src/domains/Linear.coffee | 6 | 55 |
gss/engine:src/domains/Linear.coffee:4:raw_corpus | raw_corpus | Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 3295268d8e96e6444ab90dbd86e204d683af5345 | 2,854 | https://github.com/gss/engine/blob/3295268d8e96e6444ab90dbd86e204d683af5345/src/domains/Linear.coffee | 133 | 182 | ||
gss/engine:src/domains/Linear.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ... | var splice = [].splice;
Linear.prototype.Variable.Expression = Variable.Expression.extend(Linear.Mixin, {
'+': function(left, right) {
return c.plus(left, right);
},
'-': function(left, right) {
return c.minus(left, right);
},
'*': function(left, right) {
return c.times(left, right);
},
'/': ... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | 3295268d8e96e6444ab90dbd86e204d683af5345 | 2,854 | https://github.com/gss/engine/blob/3295268d8e96e6444ab90dbd86e204d683af5345/src/domains/Linear.coffee | 133 | 182 |
gss/engine:src/domains/Linear.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var splice = [].splice;
Linear.prototype.Variable.Expression = Variable.Expression.extend(Linear.Mixin, {
'+': function(left, right) {
return c.plus(left, right);
},
'-': function(left, right) {
return c.minus(left, right);
},
'*': function(left,... | Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 3295268d8e96e6444ab90dbd86e204d683af5345 | 2,854 | https://github.com/gss/engine/blob/3295268d8e96e6444ab90dbd86e204d683af5345/src/domains/Linear.coffee | 133 | 182 |
gss/engine:src/domains/Linear.coffee:4:completion | completion | Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints... | if constraint?.hashCode?
operation[1].command.add(constraint, engine, operation[1], operation[0].key)
descend: (engine, operation) ->
operation[1].parent = operation
[
operation[1].command.solve(engine, operation[1], '', undefined, undefined, operation[0])
engine,
operat... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 3295268d8e96e6444ab90dbd86e204d683af5345 | 2,854 | https://github.com/gss/engine/blob/3295268d8e96e6444ab90dbd86e204d683af5345/src/domains/Linear.coffee | 133 | 182 |
gss/engine:src/domains/Linear.coffee:1:raw_corpus | raw_corpus | class Linear extends Domain
priority: -100
Solver: require('cassowary')
setup: () ->
super
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.S... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 31938f86e04f67ada173275db8f0e673655a12e9 | 2,854 | https://github.com/gss/engine/blob/31938f86e04f67ada173275db8f0e673655a12e9/src/domains/Linear.coffee | 8 | 57 | ||
gss/engine:src/domains/Linear.coffee:1:completion | completion | class Linear extends Domain
priority: -100
Solver: require('cassowary')
setup: () ->
super
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.S... | @suggested = undefined
@solver.resolve()
return @solver._changed
unedit: (variable) ->
if constraint = @editing?['%' + variable.name]
cei = @solver._editVarMap.get(constraint.variable);
@solver.removeColumn(cei.editMinus);
@solver._editVarMap.delete(constraint.variable);
#@r... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 31938f86e04f67ada173275db8f0e673655a12e9 | 2,854 | https://github.com/gss/engine/blob/31938f86e04f67ada173275db8f0e673655a12e9/src/domains/Linear.coffee | 8 | 57 |
gss/engine:src/domains/Linear.coffee:4:raw_corpus | raw_corpus | Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | ca12495ce84271272bb93ed0afd03d6f8254daf5 | 2,854 | https://github.com/gss/engine/blob/ca12495ce84271272bb93ed0afd03d6f8254daf5/src/domains/Linear.coffee | 133 | 182 | ||
gss/engine:src/domains/Linear.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ... | var splice = [].splice;
Linear.prototype.Variable.Expression = Variable.Expression.extend(Linear.Mixin, {
'+': function(left, right) {
return c.plus(left, right);
},
'-': function(left, right) {
return c.minus(left, right);
},
'*': function(left, right) {
return c.times(left, right);
},
'/': ... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | ca12495ce84271272bb93ed0afd03d6f8254daf5 | 2,854 | https://github.com/gss/engine/blob/ca12495ce84271272bb93ed0afd03d6f8254daf5/src/domains/Linear.coffee | 133 | 182 |
gss/engine:src/domains/Linear.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var splice = [].splice;
Linear.prototype.Variable.Expression = Variable.Expression.extend(Linear.Mixin, {
'+': function(left, right) {
return c.plus(left, right);
},
'-': function(left, right) {
return c.minus(left, right);
},
'*': function(left,... | Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | ca12495ce84271272bb93ed0afd03d6f8254daf5 | 2,854 | https://github.com/gss/engine/blob/ca12495ce84271272bb93ed0afd03d6f8254daf5/src/domains/Linear.coffee | 133 | 182 |
gss/engine:src/domains/Linear.coffee:4:completion | completion | Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints... | if constraint?.hashCode?
operation[1].command.add(constraint, engine, operation[1], operation[0].key)
descend: (engine, operation) ->
operation[1].parent = operation
[
operation[1].command.solve(engine, operation[1], '', undefined, undefined, operation[0])
engine,
operat... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | ca12495ce84271272bb93ed0afd03d6f8254daf5 | 2,854 | https://github.com/gss/engine/blob/ca12495ce84271272bb93ed0afd03d6f8254daf5/src/domains/Linear.coffee | 133 | 182 |
gss/engine:src/domains/Linear.coffee:1:raw_corpus | raw_corpus | class Linear extends Domain
priority: -100
Solver: require('cassowary')
setup: () ->
super
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.S... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 8 | 57 | ||
gss/engine:src/domains/Linear.coffee:1:completion | completion | class Linear extends Domain
priority: -100
Solver: require('cassowary')
setup: () ->
super
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
c.trace = true
c.S... | @suggested = undefined
@solver.resolve()
return @solver._changed
addConstraint: (constraint) ->
#console.error('add constraint', constraint.operation?[1].hash, constraint.hashCode, constraint)
@solver.addConstraint(constraint)
removeConstraint: (constraint) ->
#console.error('remove constr... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 8 | 57 |
gss/engine:src/domains/Linear.coffee:2:raw_corpus | raw_corpus | @addConstraint constraint
(@editing ||= {})[variable.name] = constraint
return constraint
nullify: (variable, full) ->
@solver._externalParametricVars.delete(variable)
variable.value = 0
#if full
# @solver._externalRows.delete(variable)
suggest: (path, value, strength, weight, continua... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 58 | 90 | ||
gss/engine:src/domains/Linear.coffee:2:completion | completion | @addConstraint constraint
(@editing ||= {})[variable.name] = constraint
return constraint
nullify: (variable, full) ->
@solver._externalParametricVars.delete(variable)
variable.value = 0
#if full
# @solver._externalRows.delete(variable)
suggest: (path, value, strength, weight, continua... | variable = path
@edit(variable, strength, weight, continuation)
@solver.suggestValue(variable, value)
@suggested = true
return variable
variable: (name) ->
return new c.Variable name: name
strength: (strength, byDefault = 'medium') ->
return strength && c.Strength[strength] || c.Strength[... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 58 | 90 |
gss/engine:src/domains/Linear.coffee:3:raw_corpus | raw_corpus | Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constraint.extend {
before: (args, engine, operation, continua... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 91 | 140 | ||
gss/engine:src/domains/Linear.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constrai... | Linear.Mixin = {
yield: function(result, engine, operation, continuation, scope, ascender) {
if (typeof result === 'number') {
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require');
}
}
};
Linear.prototype.Constraint = Constraint.extend({
before:... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 91 | 140 |
gss/engine:src/domains/Linear.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Linear.Mixin = {
yield: function(result, engine, operation, continuation, scope, ascender) {
if (typeof result === 'number') {
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require');
}
}
};
Line... | Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constraint.extend {
before: (args, engine, operation, continua... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 91 | 140 |
gss/engine:src/domains/Linear.coffee:3:completion | completion | Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constraint.extend {
before: (args, engine, operation, continua... | '<=': (left, right, strength, weight, engine) ->
return new c.Inequality(left, c.LEQ, right, engine.strength(strength), engine.weight(weight))
'>=': (left, right, strength, weight, engine) ->
return new c.Inequality(left, c.GEQ, right, engine.strength(strength), engine.weight(weight))
'<': (left, right, s... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 91 | 140 |
gss/engine:src/domains/Linear.coffee:4:raw_corpus | raw_corpus | return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints wrapped into meta constructs provided by Abstract
Linear::Block = Block.extend()
Linear::Block.Meta = Block.Meta.extend {
signature: [
body: ['Any']
... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 141 | 186 | ||
gss/engine:src/domains/Linear.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints wrapped into meta constructs provided by Abstract
Linear::Block = Block.extend()
Linear::Block.Met... | var splice = [].splice;
return c.minus(left, right)({
'*': function(left, right) {
return c.times(left, right);
},
'/': function(left, right) {
return c.divide(left, right);
}
});
// Handle constraints wrapped into meta constructs provided by Abstract
Linear.prototype.Block = Block.extend();
Linear.p... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 141 | 186 |
gss/engine:src/domains/Linear.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var splice = [].splice;
return c.minus(left, right)({
'*': function(left, right) {
return c.times(left, right);
},
'/': function(left, right) {
return c.divide(left, right);
}
});
// Handle constraints wrapped into meta constructs provided by Abst... | return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints wrapped into meta constructs provided by Abstract
Linear::Block = Block.extend()
Linear::Block.Meta = Block.Meta.extend {
signature: [
body: ['Any']
... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 141 | 186 |
gss/engine:src/domains/Linear.coffee:4:completion | completion | return c.minus(left, right)
'*': (left, right) ->
return c.times(left, right)
'/': (left, right) ->
return c.divide(left, right)
# Handle constraints wrapped into meta constructs provided by Abstract
Linear::Block = Block.extend()
Linear::Block.Meta = Block.Meta.extend {
signature: [
body: ['Any']
... | operation[1].command.solve(engine, operation[1], '', undefined, undefined, operation[0])
engine,
operation
]
Linear::Call = Call.extend {},
'stay': (value, engine, operation) ->
engine.suggested = true;
engine.solver.addStay(value)
return
Linear::Call.Unsafe = Call.Unsafe.extend {
... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 5b9cdc8206e187bfd07869d3f159fc262c27b575 | 2,854 | https://github.com/gss/engine/blob/5b9cdc8206e187bfd07869d3f159fc262c27b575/src/domains/Linear.coffee | 141 | 186 |
gss/engine:src/domains/Linear.coffee:2:raw_corpus | raw_corpus | @addConstraint constraint
(@editing ||= {})[variable.name] = constraint
return constraint
nullify: (variable) ->
@solver._externalParametricVars.delete(variable)
#@solver._externalRows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | d3179d65e07f4c8b8a25cd5f21abb43650cd19b0 | 2,854 | https://github.com/gss/engine/blob/d3179d65e07f4c8b8a25cd5f21abb43650cd19b0/src/domains/Linear.coffee | 58 | 88 | ||
gss/engine:src/domains/Linear.coffee:2:completion | completion | @addConstraint constraint
(@editing ||= {})[variable.name] = constraint
return constraint
nullify: (variable) ->
@solver._externalParametricVars.delete(variable)
#@solver._externalRows.delete(variable)
suggest: (path, value, strength, weight, continuation) ->
if typeof path == 'string'
... | @edit(variable, strength, weight, continuation)
@solver.suggestValue(variable, value)
@suggested = true
return variable
variable: (name) ->
return new c.Variable name: name
strength: (strength, byDefault = 'medium') ->
return strength && c.Strength[strength] || c.Strength[byDefault]
weight:... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | d3179d65e07f4c8b8a25cd5f21abb43650cd19b0 | 2,854 | https://github.com/gss/engine/blob/d3179d65e07f4c8b8a25cd5f21abb43650cd19b0/src/domains/Linear.coffee | 58 | 88 |
gss/engine:src/domains/Linear.coffee:1:raw_corpus | raw_corpus | class Linear extends Domain
priority: -100
Solver: require('cassowary')
setup: () ->
super
@operations ||= []
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 8 | 57 | ||
gss/engine:src/domains/Linear.coffee:1:completion | completion | class Linear extends Domain
priority: -100
Solver: require('cassowary')
setup: () ->
super
@operations ||= []
unless @hasOwnProperty('solver')
@solver = new c.SimplexSolver()
@solver.autoSolve = false
@solver._store = []
if @console.level > 1
c.debug = true
... | @solver.solve()
return @solver._changed
else if @suggested
@suggested = undefined
@solver.resolve()
return @solver._changed
addConstraint: (constraint) ->
#console.error('add constraint', constraint.operation?[1].hash, constraint.hashCode, constraint)
@solver.addConstraint(const... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 8 | 57 |
gss/engine:src/domains/Linear.coffee:2:raw_corpus | raw_corpus | unless @editing?[variable.name]
constraint = new c.EditConstraint(variable, @strength(strength, 'strong'), @weight(weight))
constraint.variable = variable
@addConstraint constraint
(@editing ||= {})[variable.name] = constraint
return constraint
nullify: (variable) ->
@solver._externa... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 58 | 91 | ||
gss/engine:src/domains/Linear.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
unless @editing?[variable.name]
constraint = new c.EditConstraint(variable, @strength(strength, 'strong'), @weight(weight))
constraint.variable = variable
@addConstraint constraint
(@editing ||= {})[variable.name] = constraint
return ... | var constraint, ref;
if (!((ref = this.editing) != null ? ref[variable.name] : void 0)) {
constraint = new c.EditConstraint(variable, this.strength(strength, 'strong'), this.weight(weight));
constraint.variable = variable;
this.addConstraint(constraint);
(this.editing || (this.editing = {}))[variable.name] = c... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 58 | 91 |
gss/engine:src/domains/Linear.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var constraint, ref;
if (!((ref = this.editing) != null ? ref[variable.name] : void 0)) {
constraint = new c.EditConstraint(variable, this.strength(strength, 'strong'), this.weight(weight));
constraint.variable = variable;
this.addConstraint(constraint);
(... | unless @editing?[variable.name]
constraint = new c.EditConstraint(variable, @strength(strength, 'strong'), @weight(weight))
constraint.variable = variable
@addConstraint constraint
(@editing ||= {})[variable.name] = constraint
return constraint
nullify: (variable) ->
@solver._externa... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 58 | 91 |
gss/engine:src/domains/Linear.coffee:2:completion | completion | unless @editing?[variable.name]
constraint = new c.EditConstraint(variable, @strength(strength, 'strong'), @weight(weight))
constraint.variable = variable
@addConstraint constraint
(@editing ||= {})[variable.name] = constraint
return constraint
nullify: (variable) ->
@solver._externa... | variable = path
@edit(variable, strength, weight, continuation)
@solver.suggestValue(variable, value)
@suggested = true
return variable
variable: (name) ->
return new c.Variable name: name
strength: (strength, byDefault = 'medium') ->
return strength && c.Strength[strength] || c.Strength[... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 58 | 91 |
gss/engine:src/domains/Linear.coffee:3:raw_corpus | raw_corpus | Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constraint.extend Linear.Mixin,
'==': (left, right, strength, w... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 92 | 141 | ||
gss/engine:src/domains/Linear.coffee:3:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constrai... | Linear.Mixin = {
yield: function(result, engine, operation, continuation, scope, ascender) {
if (typeof result === 'number') {
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require');
}
}
};
Linear.prototype.Constraint = Constraint.extend(Linear.Mixi... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 92 | 141 |
gss/engine:src/domains/Linear.coffee:3:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
Linear.Mixin = {
yield: function(result, engine, operation, continuation, scope, ascender) {
if (typeof result === 'number') {
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require');
}
}
};
Line... | Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constraint.extend Linear.Mixin,
'==': (left, right, strength, w... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 92 | 141 |
gss/engine:src/domains/Linear.coffee:3:completion | completion | Linear.Mixin =
yield: (result, engine, operation, continuation, scope, ascender) ->
if typeof result == 'number'
return operation.parent.domain.suggest('%' + operation.command.toExpression(operation), result, 'require')
Linear::Constraint = Constraint.extend Linear.Mixin,
'==': (left, right, strength, w... | variable = @declare(engine, path)
engine.unedit(variable)
return variable
Linear::Variable.Expression = Variable.Expression.extend Linear.Mixin,
'+': (left, right) ->
return c.plus(left, right)
'-': (left, right) ->
return c.minus(left, right)
'*': (left, right) ->
return c.times(left, rig... | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 92 | 141 |
gss/engine:src/domains/Linear.coffee:4:raw_corpus | raw_corpus | 'object':
execute: (constraint, engine, operation) ->
#return unless constraint.hashCode?
operation[1].command.add(constraint, engine, operation[1], operation[0].key)
descend: (engine, operation) ->
operation[1].parent = operation
[
operation[1].command.solve(engine, operation[1... | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 142 | 172 | ||
gss/engine:src/domains/Linear.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
'object':
execute: (constraint, engine, operation) ->
#return unless constraint.hashCode?
operation[1].command.add(constraint, engine, operation[1], operation[0].key)
descend: (engine, operation) ->
operation[1].parent = operation
... | var splice = [].splice;
({
'object': {
execute: function(constraint, engine, operation) {
//return unless constraint.hashCode?
return operation[1].command.add(constraint, engine, operation[1], operation[0].key);
},
descend: function(engine, operation) {
operation[1].parent = operation;
... | CoffeeScript | JavaScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 142 | 172 |
gss/engine:src/domains/Linear.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var splice = [].splice;
({
'object': {
execute: function(constraint, engine, operation) {
//return unless constraint.hashCode?
return operation[1].command.add(constraint, engine, operation[1], operation[0].key);
},
descend: function(engin... | 'object':
execute: (constraint, engine, operation) ->
#return unless constraint.hashCode?
operation[1].command.add(constraint, engine, operation[1], operation[0].key)
descend: (engine, operation) ->
operation[1].parent = operation
[
operation[1].command.solve(engine, operation[1... | JavaScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 142 | 172 |
gss/engine:src/domains/Linear.coffee:4:completion | completion | 'object':
execute: (constraint, engine, operation) ->
#return unless constraint.hashCode?
operation[1].command.add(constraint, engine, operation[1], operation[0].key)
descend: (engine, operation) ->
operation[1].parent = operation
[
operation[1].command.solve(engine, operation[1... | engine.suggested = true;
engine.solver.addStay(value)
return
Linear::Call.Unsafe = Call.Unsafe.extend {
extras: 1
},
'remove': (args ..., engine) ->
engine.remove.apply(engine, args)
# Phantom js doesnt enforce order of numerical keys in plain objects.
# The hack enforces arrays as base structure. | CoffeeScript | CoffeeScript | gss/engine | src/domains/Linear.coffee | MIT | 527308fd09ab6b18a30ad7b6194f0fd00f872647 | 2,854 | https://github.com/gss/engine/blob/527308fd09ab6b18a30ad7b6194f0fd00f872647/src/domains/Linear.coffee | 142 | 172 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:1:raw_corpus | raw_corpus | ###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 1 | 41 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:1:completion | completion | ###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | exports = {
authEnabled: configService.authentication.enable
cachedUserId: null
cachedUsername: null
isLoggedIn: ->
return true unless configService.authentication.enable
loggedIn && currentSession?
isAdmin: -> currentSession?.user?.admin == true
... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 1 | 41 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:2:raw_corpus | raw_corpus | isNewUser: true
notNewUser: (update = true) ->
return unless exports.isNewUser
# Save flag indicating this is no longer a new user
$localForage.setItem('newUser', 0).then ->
# Change field accordingly
exports.isNewUser = false if update
... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 43 | 81 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:2:completion | completion | isNewUser: true
notNewUser: (update = true) ->
return unless exports.isNewUser
# Save flag indicating this is no longer a new user
$localForage.setItem('newUser', 0).then ->
# Change field accordingly
exports.isNewUser = false if update
... | $localForage.getItem('cachedUserId').then (userId) ->
if userId?
exports.cachedUserId = userId
# Load New User quality
$localForage.getItem('newUser').then (value) ->
if value == 0
logService.debug 'User is definitely not a New User'
exports.isNewUser = false... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 43 | 81 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:3:raw_corpus | raw_corpus | deferred = $q.defer()
post.success (session) ->
currentSession = session
# Store session and username in localstorage
$localForage.setItem 'session', session
$localForage.setItem 'username', username
$localForage.setItem 'cachedUserId', session.user.... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 83 | 124 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:3:completion | completion | deferred = $q.defer()
post.success (session) ->
currentSession = session
# Store session and username in localstorage
$localForage.setItem 'session', session
$localForage.setItem 'username', username
$localForage.setItem 'cachedUserId', session.user.... | deferred.reject(error)
return deferred.promise
exports.loadExistingSession = (hideAlerts = false) ->
return currentSession if currentSession?
deferred = $q.defer()
errorHandler = ->
exports.setLoggedOut()
deferred.resolve(null)
if configService.aut... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 83 | 124 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:4:raw_corpus | raw_corpus | alertify.log('Logged in as <strong>' + session.user.name + '</strong>', 2500) unless hideAlerts
deferred.resolve(session)
validator.error (error) ->
$localForage.removeItem('session')
alertify.log('Previous session expired', 25... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 126 | 169 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:4:completion | completion | alertify.log('Logged in as <strong>' + session.user.name + '</strong>', 2500) unless hideAlerts
deferred.resolve(session)
validator.error (error) ->
$localForage.removeItem('session')
alertify.log('Previous session expired', 25... | $localForage.removeItem('session')
$rootScope.$broadcast('logout')
alertify.log('Logged Out', 2500)
deferred.resolve()
promise.error (error) ->
alertify.error('Error during logout', 2500)
deferred.reject()
return defe... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 126 | 169 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:5:raw_corpus | raw_corpus | return deferred.promise
exports.hasEditPermission = (dashboard) ->
return true unless configService.authentication.enable
# Non-authenticated users cannot edit
return false unless exports.isLoggedIn()
# User is Admin
return true if exports.isAdmin()
# No edit perm... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 171 | 211 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:5:completion | completion | return deferred.promise
exports.hasEditPermission = (dashboard) ->
return true unless configService.authentication.enable
# Non-authenticated users cannot edit
return false unless exports.isLoggedIn()
# User is Admin
return true if exports.isAdmin()
# No edit perm... | return true unless configService.authentication.enable
# Assume non-authenticated users can view
return true unless exports.isLoggedIn()
# User is Admin
return true if exports.isAdmin()
# No view permissions defined
return true if _.isEmpty(dashboard?.viewers)
... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 171 | 211 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:6:raw_corpus | raw_corpus | # Must be logged in to like a dashboard
return false unless exports.isLoggedIn()
return _.contains dashboard.likes, currentSession.user._id
return exports | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 213 | 218 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:6:completion | completion | # Must be logged in to like a dashboard
return false unless exports.isLoggedIn() | return _.contains dashboard.likes, currentSession.user._id
return exports | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | df26fc48ea0296697e2755b7a1d9ce5cf50a4483 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/df26fc48ea0296697e2755b7a1d9ce5cf50a4483/cyclotron-site/app/scripts/common/services/services.userService.coffee | 213 | 218 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:1:raw_corpus | raw_corpus | ###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | aa249eacd2cdb7409ce6c4581e1cedf99c9471b7 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/aa249eacd2cdb7409ce6c4581e1cedf99c9471b7/cyclotron-site/app/scripts/common/services/services.userService.coffee | 1 | 41 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:1:completion | completion | ###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | exports = {
authEnabled: configService.authentication.enable
cachedUserId: null
cachedUsername: null
isLoggedIn: ->
return true unless configService.authentication.enable
loggedIn && currentSession?
isAdmin: -> currentSession?.user?.admin == true
... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | aa249eacd2cdb7409ce6c4581e1cedf99c9471b7 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/aa249eacd2cdb7409ce6c4581e1cedf99c9471b7/cyclotron-site/app/scripts/common/services/services.userService.coffee | 1 | 41 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:3:raw_corpus | raw_corpus | deferred = $q.defer()
post.success (session) ->
currentSession = session
# Store session and username in localstorage
$localForage.setItem 'session', session
$localForage.setItem 'username', username
$localForage.setItem 'cachedUserId', session.user.... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | aa249eacd2cdb7409ce6c4581e1cedf99c9471b7 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/aa249eacd2cdb7409ce6c4581e1cedf99c9471b7/cyclotron-site/app/scripts/common/services/services.userService.coffee | 83 | 122 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:3:completion | completion | deferred = $q.defer()
post.success (session) ->
currentSession = session
# Store session and username in localstorage
$localForage.setItem 'session', session
$localForage.setItem 'username', username
$localForage.setItem 'cachedUserId', session.user.... | return deferred.promise
exports.loadExistingSession = (hideAlerts = false) ->
return currentSession if currentSession?
deferred = $q.defer()
errorHandler = ->
exports.setLoggedOut()
deferred.resolve(null)
if configService.authentication.enable == true
... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | aa249eacd2cdb7409ce6c4581e1cedf99c9471b7 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/aa249eacd2cdb7409ce6c4581e1cedf99c9471b7/cyclotron-site/app/scripts/common/services/services.userService.coffee | 83 | 122 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:4:raw_corpus | raw_corpus | alertify.log('Logged in as <strong>' + session.user.name + '</strong>', 2500) unless hideAlerts
deferred.resolve(session)
validator.error (error) ->
$localForage.removeItem('session')
alertify.log('Previous session expired', 25... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | aa249eacd2cdb7409ce6c4581e1cedf99c9471b7 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/aa249eacd2cdb7409ce6c4581e1cedf99c9471b7/cyclotron-site/app/scripts/common/services/services.userService.coffee | 124 | 166 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:4:completion | completion | alertify.log('Logged in as <strong>' + session.user.name + '</strong>', 2500) unless hideAlerts
deferred.resolve(session)
validator.error (error) ->
$localForage.removeItem('session')
alertify.log('Previous session expired', 25... | exports.setLoggedOut()
$localForage.removeItem('session')
alertify.log('Logged Out', 2500)
deferred.resolve()
promise.error (error) ->
alertify.error('Error during logout', 2500)
deferred.reject()
return deferred.prom... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | aa249eacd2cdb7409ce6c4581e1cedf99c9471b7 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/aa249eacd2cdb7409ce6c4581e1cedf99c9471b7/cyclotron-site/app/scripts/common/services/services.userService.coffee | 124 | 166 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:4:raw_corpus | raw_corpus | alertify.log('Logged in as <strong>' + session.user.name + '</strong>', 2500) unless hideAlerts
deferred.resolve(session)
validator.error (error) ->
$localForage.removeItem('session')
alertify.log('Previous session expired', 25... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | 2c2eb7bc16616a8b1d9601b8307884f5f6be40de | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/2c2eb7bc16616a8b1d9601b8307884f5f6be40de/cyclotron-site/app/scripts/common/services/services.userService.coffee | 124 | 166 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:4:completion | completion | alertify.log('Logged in as <strong>' + session.user.name + '</strong>', 2500) unless hideAlerts
deferred.resolve(session)
validator.error (error) ->
$localForage.removeItem('session')
alertify.log('Previous session expired', 25... | exports.setLoggedOut()
$localForage.removeItem('session')
alertify.log('Logged Out', 2500)
deferred.resolve()
promise.error (error) ->
alertify.error('Error during logout', 2500)
deferred.reject()
return deferred.prom... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | 2c2eb7bc16616a8b1d9601b8307884f5f6be40de | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/2c2eb7bc16616a8b1d9601b8307884f5f6be40de/cyclotron-site/app/scripts/common/services/services.userService.coffee | 124 | 166 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:1:raw_corpus | raw_corpus | ###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 1 | 42 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licens... | /*
* Copyright (c) 2013-2015 the original author or authors.
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/mit-license.php
*
* Unless required by applica... | CoffeeScript | JavaScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 1 | 42 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
/*
* Copyright (c) 2013-2015 the original author or authors.
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/li... | ###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | JavaScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 1 | 42 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/common/services/services.userService.coffee:1:completion | completion | ###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | exports = {
authEnabled: configService.authentication.enable
cachedUserId: null
cachedUsername: null
isLoggedIn: ->
return true unless configService.authentication.enable
loggedIn && currentSession?
isAdmin: -> currentSession?.user?.admin == true
... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/common/services/services.userService.coffee | MIT | d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1 | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/d57e1ea8a1e73bb1b98d5b0d7b80dc356b595ce1/cyclotron-site/app/scripts/common/services/services.userService.coffee | 1 | 42 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.