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
require 'test_helper' | |
class Admin::DashboardControllerTest < ActionController::TestCase | |
test "should not get index without user" do | |
get :index | |
assert_redirected_to new_user_session_path | |
end | |
test "should not get index with regular user" do | |
sign_in_user |
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
from rest_framework import permissions | |
class IsOwnerOrReadOnly(permissions.BasePermission): | |
""" | |
Custom permission to only allow owners of an object to edit it. | |
""" | |
def has_object_permission(self, request, view, obj): | |
# Read permissions are allowed to any request, | |
# so we'll always allow GEt, HEAD or OPTIONS requests. |
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
If you didn't delete Snap Save at any point all the pictures/videos should still be there, not sure why they aren't showing up. Use this tool http://www.macroplant.com/iexplorer/ and click on Apps, find the Quick Save/Snap Save folder and go to documents. Copy all the files over to your computer. All the functionality you need is available in the trial version of the program so you don't have to pay anything. |
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
#ifdef DEBUG | |
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); | |
#else | |
# define DLog(...) | |
#endif |
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
DictionaryWord Load (536.0ms) SELECT word FROM `dictionary_words` WHERE `dictionary_words`.`dictionary_id` = 1 ORDER BY seed LIMIT 10 OFFSET 80112 | |
EXPLAIN (3.1ms) EXPLAIN SELECT word FROM `dictionary_words` WHERE `dictionary_words`.`dictionary_id` = 1 ORDER BY seed LIMIT 10 OFFSET 80112 | |
EXPLAIN for: SELECT word FROM `dictionary_words` WHERE `dictionary_words`.`dictionary_id` = 1 ORDER BY seed LIMIT 10 OFFSET 80112 | |
+----+-------------+------------------+------+-------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+---------+-------+-------+-------------+ | |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
+----+-------------+------------------+--- |
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
EXPLAIN (3.1ms) EXPLAIN SELECT word FROM `dictionary_words` WHERE `dictionary_words`.`dictionary_id` = 1 ORDER BY seed LIMIT 10 OFFSET 80112 | |
EXPLAIN for: SELECT word FROM `dictionary_words` WHERE `dictionary_words`.`dictionary_id` = 1 ORDER BY seed LIMIT 10 OFFSET 80112 | |
+----+-------------+------------------+------+-------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+---------+-------+-------+-------------+ | |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
+----+-------------+------------------+------+-------------------------------------------------------------------------------------------------------------------------------------------+------ |
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
I have a table for matchmaking where there may or may not be "games waiting for an opponent". I am planning to just use UPDATE tablename SET guid = [some GUID created by client], waiting_on_match_since = NULL WHERE waiting_on_match_since IS NOT NULL ORDER BY waiting_on_match_since LIMIT 1. Then querying for the GUID to see if we joined a game that was waiting for a match or if we should create one. Is this an ok approach for this or a complete hack? |
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
(0.3ms) UPDATE games SET 'matchmaking_uuid' = '329ed81d-5de2-4cc1-8022-1d7a2c095f30' WHERE 'waiting_on_match_since' IS NOT NULL ORDER BY waiting_on_match_since LIMIT 1 | |
ActiveRecord::StatementInvalid: SQLite3::SQLException: near "ORDER": syntax error: UPDATE games SET 'matchmaking_uuid' = '329ed81d-5de2-4cc1-8022-1d7a2c095f30' WHERE 'waiting_on_match_since' IS NOT NULL ORDER BY waiting_on_match_since LIMIT 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
# game_bardo_state.rb | |
# tile_state.rb is in model directory as well | |
require 'tile_state' | |
class GameBoardState < ActiveRecord::Base | |
belongs_to :game | |
serialize :board_state | |
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 has_word?(word) | |
matching_words = dictionary_words.where(:word => word.upcase).limit(1) | |
if matching_words.blank? | |
false | |
else | |
true | |
end | |
end | |