Skip to content

Instantly share code, notes, and snippets.

View Sailias's full-sized avatar

Jonathan Salis Sailias

  • Bus Patrol
  • Toronto Canada
View GitHub Profile
schemaverse=> LISTEN jdcyekurqi;
LISTEN
schemaverse=> NOTIFY jdcyekurqi, 'some text';
NOTIFY
Asynchronous notification "jdcyekurqi" received from server process with PID 2931.
schemaverse=> SELECT 1;
?column?
----------
1
(1 row)
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
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
1 sailias 804 168 4
2 ☠ anewworth 165395 38 3
3 🌼 blossom 6176469 63 1
4 ☢ derpfish 4189098 62 1
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
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
class MainSiteDomain
def self.matches?(request)
if request.host == DOMAIN
true
else
# custom domain
false
end
end
end
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;
@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]
<div ng-controller='ChatCtrl'>
<div id='messages' ng-repeat="chat_message in chat_messages">
{{chat_message.text}}
</div>
</div>