Skip to content

Instantly share code, notes, and snippets.

View m1kola's full-sized avatar

Mikalai Radchuk m1kola

  • Red Hat
  • 03:33 (UTC +02:00)
View GitHub Profile
@m1kola
m1kola / markAsViewd.js
Created June 14, 2022 16:03
GitHub code reviews: mark files as viewd by file path prefix
// Example call: markAsViewd("vendor/")
function markAsViewd(pathPrefix) {
elements = document.querySelectorAll(".js-toggle-user-reviewed-file-form")
elements = Array.prototype.filter.call(elements, (elem) => {
isVendor = elem.querySelector("input[name='path']").value.startsWith(pathPrefix)
isViewed = elem.querySelector("input[name='viewed']").checked
return isVendor && !isViewed
}).map((elem) => (elem.querySelector("input[name='viewed']")));
@m1kola
m1kola / upgrade_notification.html
Last active March 10, 2020 16:47
Display Wagtail's upgrade notification only to superusers
{% load wagtailcore_tags staticfiles %}
{% if request.user.is_superuser %}
<div class="panel nice-padding panel-upgrade-notification" style="display:none">
<div class="help-block help-warning">Wagtail upgrade available. Your version: <strong>{% wagtail_version %}</strong>. New version: <strong class="newversion"></strong>. <a class="releasenotes-link" href="">Read the release notes.</a></div>
<script>window.wagtailVersion = "{% wagtail_version %}";</script>
<script src="{% static 'wagtailadmin/js/upgrade_notify.js' %}" async="true"></script>
</div>
{% endif %}

Keybase proof

I hereby claim:

  • I am m1kola on github.
  • I am m1kola (https://keybase.io/m1kola) on keybase.
  • I have a public key ASAkSHN2YtgkEvfvvF6nUBQ-QWYXH0DiIEusfFAyo-nk8Qo

To claim this, I am signing this object:

@m1kola
m1kola / private.php
Last active March 1, 2016 13:49
How to get access to private and protected properties in PHP without Reflection
<?php
class Foo {
public $public_var = 'public value';
protected $protected_var = 'protected value';
private $private_var = 'private value';
}
$obj = new Foo();
$obj_array = (array) $obj;