This file contains hidden or 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
window.startVisualization = () -> | |
$('#tic_value').html("0") | |
$('#tic_planets').html("0") | |
$('#total_planets').html("0") | |
# Initialize the map | |
visualizer.map.init() | |
schemaverse.getPlayers () -> |
This file contains hidden or 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
@students = Student | |
@students = @students.where(name: params[:name]) unless params[:name].blank? | |
@students = @students.where(age: params[:age]) unless params[:age].blank? | |
@students.page params[:page] |
This file contains hidden or 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
create temporary table games (id integer, dt DateTime, name varchar(255)); | |
insert into games values | |
(1, '2010-01-01 00:00:00', 'Game 1'), | |
(2, '2010-01-02 00:00:00', 'Game 2'), | |
(3, '2010-01-03 00:00:00', 'Game 3'), | |
(4, '2010-01-04 00:00:00', 'Game 4'), | |
(5, '2010-01-05 00:00:00', 'Game 5'); | |
CREATE TEMPORARY TABLE games2 SELECT * FROM games; | |
This file contains hidden or 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 MainSiteDomain | |
def self.matches?(request) | |
if request.host == DOMAIN | |
true | |
else | |
# custom domain | |
false | |
end | |
end | |
end |
This file contains hidden or 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
def distance_between(obj_a, obj_b) | |
p1 = GeoRuby::SimpleFeatures::Point.from_x_y(get_x(obj_a), get_y(obj_a)) | |
p2 = GeoRuby::SimpleFeatures::Point.from_x_y(get_x(obj_b), get_y(obj_b)) | |
p1.euclidian_distance(p2) | |
end |
This file contains hidden or 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
def upgrade(attribute, amount) | |
val = self.class.select("UPGRADE(#{self.id}, '#{attribute}', #{amount})").where(:id => self.id).first.attributes | |
if val["upgrade"] == 't' | |
self.send("#{attribute.downcase}=", self.send("#{attribute.downcase}") + amount) | |
return true | |
end | |
return false | |
end |
This file contains hidden or 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
1 sailias 804 168 4 | |
2 ☠ anewworth 165395 38 3 | |
3 🌼 blossom 6176469 63 1 | |
4 ☢ derpfish 4189098 62 1 |
This file contains hidden or 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
def get_all_assets(course) | |
assets = [] | |
assets += course.assets | |
course.prerequisite_courses.each do |p_c| | |
assets += get_all_assets(p_c) | |
end | |
return assets | |
end |
This file contains hidden or 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
PG::Error: ERROR: deadlock detected | |
DETAIL: Process 3929 waits for RowExclusiveLock on relation 18025 of database 17637; blocked by process 3955. | |
Process 3955 waits for ShareLock on transaction 43569483; blocked by process 3929. | |
HINT: See server log for query details. | |
CONTEXT: SQL statement "UPDATE ship SET prospecting=(prospecting+quantity) WHERE id=reference_id" | |
PL/pgSQL function "upgrade" line 103 at SQL statement | |
: SELECT UPGRADE(5619, 'PROSPECTING', 100) FROM "my_ships" WHERE "my_ships"."id" = 5619 LIMIT 1 |