Skip to content

Instantly share code, notes, and snippets.

View cmltaWt0's full-sized avatar
🏠
Rustify

Max Sokolski cmltaWt0

🏠
Rustify
  • Raccoon Gang
  • Ukraine, Kharkiv
View GitHub Profile
@cmltaWt0
cmltaWt0 / memoize
Created September 14, 2014 10:31
Memoize from ActiveState Code by Daniel Miller
from functools import partial
class memoize(object):
"""cache the return value of a method
This class is meant to be used as a decorator of methods. The return value
from a given method invocation will be cached on the instance whose method
was invoked. All arguments passed to a method decorated with memoize must
be hashable.
@cmltaWt0
cmltaWt0 / diff.py
Created June 27, 2015 12:06
Issue #46 patch
diff --git a/mysite/psa/views.py b/mysite/psa/views.py
index 37d49d5..66de578 100644
--- a/mysite/psa/views.py
+++ b/mysite/psa/views.py
@@ -63,12 +63,13 @@ def custom_login(request):
if user is not None:
if user.is_active:
login(request, user)
- return redirect(request.POST.get('next', '/ct/'))
+ return redirect(request.POST.get('next', '/ct/'))
@cmltaWt0
cmltaWt0 / patch2.diff
Created June 27, 2015 19:30
Patch for issue #46 part 2
diff --git a/mysite/psa/views.py b/mysite/psa/views.py
index 3b8847a..51ea9ca 100644
--- a/mysite/psa/views.py
+++ b/mysite/psa/views.py
@@ -65,7 +65,7 @@ def custom_login(request):
if user is not None:
if user.is_active:
login(request, user)
- return redirect(request.POST.get('next', '/ct/'))
+ return redirect(request.POST.get('next', '/ct/'))
-def get_plugin(funcName, prefix='fsm.fsm_plugin.'):
+def get_plugin(funcName, prefix='.fsm_plugin.'):
"""
Import and call plugin func for this object.
"""
@@ -150,7 +151,18 @@ def get_plugin(funcName, prefix='fsm.fsm_plugin.'):
if not funcName:
raise ValueError('invalid call_plugin() with no funcName!')
i = funcName.rindex('.')
- modName = prefix + funcName[:i]
def deploy(modname, username, app_name, prefix='.fsm_plugin.'):
"""
Load FSM specifications found in the specified plugin module.
"""
import importlib
mod = importlib.import_module(app_name + prefix + modname)
l = []
for fsmSpec in mod.get_specs():
l.append(fsmSpec.save_graph(username))
return l
@cmltaWt0
cmltaWt0 / dropdown.html
Created November 24, 2020 12:31
Gamification Dropdown Menu
show_gamification = settings.FEATURES.get('RG_GAMIFICATION', {}).get('ENABLED')
% if show_gamification and gamma_site_settings and check_gamma_enabled_with_cohorts_settings(self.real_user):
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${reverse('gamma_dashboard:gamma-dashboard')}" role="menuitem">${_("Performance")}</a></div>
<div class="mobile-nav-item dropdown-item dropdown-nav-item"><a href="${reverse('gamma_dashboard:gamma-leaderboard')}" role="menuitem">${_("Leaderboard")}</a></div>
% endif
@cmltaWt0
cmltaWt0 / devstack_docker.py
Last active November 26, 2022 17:16
Gamification ENABLE FEATURE FLAGS
FEATURES.update({
"RG_GAMIFICATION": {
"ENABLED": True,
"RG_GAMIFICATION_ENDPOINT": "https://gamma.domain.in/",
"KEY": "key",
"SECRET": "secret",
"IGNORED_EVENT_TYPES": []
}
})
@cmltaWt0
cmltaWt0 / edx.yml
Created November 24, 2020 12:43
Deployment hints
RG_GAMIFICATION:
ENABLED: True
RG_GAMIFICATION_ENDPOINT: "https://ist-domain"
KEY: "{{ RG_GAMIFICATION_KEY }}"
SECRET: "{{ RG_GAMIFICATION_SECRET }}"
IGNORED_EVENT_TYPES: []
diff --git a/playbooks/openedx_native.yml b/playbooks/openedx_native.yml
index 9d7a04793..a97839f27 100644
--- a/playbooks/openedx_native.yml
+++ b/playbooks/openedx_native.yml
@@ -67,7 +67,7 @@
ECOMMERCE_CORS_ALLOW_CREDENTIALS: true
# For the mfe role.
COMMON_ECOMMERCE_BASE_URL: '{{ ECOMMERCE_ECOMMERCE_URL_ROOT }}'
- COMMON_ENABLE_PAYMENT_MFE: true
+ ECOMMERCE_ENABLE_PAYMENT_MFE: true
@cmltaWt0
cmltaWt0 / user_dropdown.html
Created September 28, 2021 08:26
Gamification navbar
<%
...
show_gamification = settings.FEATURES.get('RG_GAMIFICATION', {}).get('ENABLED')
...
%>
...
<div class="nav-item hidden-mobile nav-item-dropdown" tabindex="-1">
...
<div class="dropdown-user-menu hidden" aria-label=${_("More Options")} role="menu" id="user-menu" tabindex="-1">
...