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
pragma solidity >=0.7.0 <0.9.0; | |
contract Chat { | |
struct Message { | |
uint id; | |
address from; | |
string message; | |
} |
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
pragma solidity >=0.7.0 <0.9.0; | |
contract Chat { | |
struct Message { | |
uint id; | |
address from; | |
string text; | |
} | |
} |
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 PriceBandit: | |
def __init__(self, price: float, beta_a: float = 1.0, beta_b: float = 1.0): | |
self.price = price | |
# default params imply a uniform random prior | |
self.beta_a = beta_a | |
self.beta_b = beta_b | |
def sample(self) -> int: | |
return round(np.random.beta(self.beta_a, self.beta_b)) |
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 GymTask(Task): | |
# ... | |
def _fit(self, proxy_env: ProxyEnv, nb_steps: int) -> None: | |
"""Fit the RL agent.""" | |
self._rl_agent.fit(proxy_env, nb_steps) | |
# ... | |
class MyRLAgent(RLAgent): |
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
Action = Any | |
Observation = Any | |
Reward = float | |
Done = bool | |
Info = dict | |
Feedback = Tuple[Observation, Reward, Done, Info] | |
NB_STEPS = 500 | |
class ProxyEnv(gym.Env): |
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 GymTask(Task): | |
# ... | |
def execute(self, *args: Any, **kwargs: Any) -> None: | |
if not self._proxy_env.is_rl_agent_trained and not self.is_rl_agent_training: | |
self._start_training() | |
if self._proxy_env.is_rl_agent_trained and self.is_rl_agent_training: | |
self._stop_training() | |
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 GymHandler(Handler): | |
# ... | |
def setup(self) -> None: | |
self._task_id = self.context.task_manager.enqueue_task(self.task) | |
# ... | |
class GymTask(Task): |
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
... | |
import 'package:dio/dio.dart'; | |
import 'package:open_file/open_file.dart'; | |
import 'package:path_provider/path_provider.dart'; | |
import 'package:permission_handler/permission_handler.dart'; | |
... | |
class MobileDownloadService implements DownloadService { |
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
import 'package:universal_html/html.dart' as html; | |
... | |
class WebDownloadService implements DownloadService { | |
@override | |
Future<void> download({required String url}) async { | |
html.window.open(url, "_blank"); | |
} | |
} |