Skip to content

Instantly share code, notes, and snippets.

@kjakub
kjakub / ZeeDo
Last active January 2, 2016 08:59
ZeeDo
Welcome to the our ZeeDo API documentation. To document and hold API documentation we will use this apiary.io
service. apiary.io can act as a mock-server or proxy to the real server. It also support comments to each request if any
if any of them needs improvement or fix. I am very open to provide any further information to mobile app team during development
Please contact me direct: jakub.kuchar@hotmail.com, skype: jakub.chorosh
General introduction to ZeeDo API:
1. All requests needs following 2 headers in order to have response successfully:
@kjakub
kjakub / Zeedo Authorization Overview
Last active August 29, 2015 13:56
Zeedo Authorization Overview
1. List of user's roles in Zeedo
tribe - everybody who sign up via social accounts or via form and who IS NOT in the list as admin in facebook app
brand - user will became brand user if first sing up and via facebook and he IS in the list as admin in facebook app
system - chosen user or users set up via seed or manually (behavior may change in future)
2. privileges
tribe
- can play N games (validation: game not suspend,game not expired time, game started time, game players exceeded, user not suspend, game is not playing, game is not completed )
@kjakub
kjakub / gist:be17d9439359d14e6f86
Last active November 14, 2019 17:33
Ruby Nested Hash each_pair
class Hash
def nested_each_pair
self.each_pair do |k,v|
if v.is_a?(Hash)
v.nested_each_pair {|k,v| yield k,v}
else
yield(k,v)
end
end
2.hours.ago # => Fri, 02 Mar 2012 20:04:47 JST +09:00
1.day.from_now # => Fri, 03 Mar 2012 22:04:47 JST +09:00
Date.today.to_time_in_current_zone # => Fri, 02 Mar 2012 22:04:47 JST +09:00
Date.current # => Fri, 02 Mar
Time.zone.parse("2012-03-02 16:05:37") # => Fri, 02 Mar 2012 16:05:37 JST +09:00
Time.zone.now # => Fri, 02 Mar 2012 22:04:47 JST +09:00
Time.current # Same thing but shorter. (Thank you Lukas Sarnacki pointing this out.)
Time.zone.today # If you really can't have a Time or DateTime for some reason
Time.zone.now.utc.iso8601 # When supliyng an API (you can actually skip .zone here, but I find it better to always use it, than miss it when it's needed)
Time.strptime(time_string, '%Y-%m-%dT%H:%M:%S%z').in_time_zone(Time.zone) # If you can't use Time#parse
@kjakub
kjakub / docker-mysql-dump-download.sh
Last active May 9, 2017 11:06
Export and download mysql dump from mysql docker container - sshpass
#!/bin/bash
machine=""
user=""
password=""
container=""
mysql_user=""
mysql_password=""
database=""