Skip to content

Instantly share code, notes, and snippets.

View MurzNN's full-sized avatar
🎯
Focusing

Alexey Murz Korepov MurzNN

🎯
Focusing
View GitHub Profile
@fomigo
fomigo / gist:2382775
Created April 14, 2012 07:59
Russian Plural Form in PHP
<?php
/*
echo plural_form(42, array('арбуз', 'арбуза', 'арбузов'));
*/
function plural_form($n, $forms) {
return $n%10==1&&$n%100!=11?$forms[0]:($n%10>=2&&$n%10<=4&&($n%100<10||$n%100>=20)?$forms[1]:$forms[2]);
}
@mrded
mrded / foo.module
Created October 31, 2013 13:46
Drupal: Taxonomy terms as autocomplete using form API.
<?php
function bar_form($form, &$state) {
$form['bar'] = array(
'#type' => 'textfield',
'#title' => t('Bar'),
'#autocomplete_path' => 'taxonomy/autocomplete/field_bar_term', // Field name here.
'#element_validate' => array('foo_taxonomy_autocomplete_validate'),
);
@RWhar
RWhar / PHPUnitMockMagicGet
Last active July 26, 2022 06:16
PHPUnit - Mock _get() on an Abstract Class
class TestMyObjectLoader extends PHPUnit_Framework_TestCase
{
protected $mockObject;
public function setUp()
{
$this->mockObject = $this->getMockForAbstractClass('Project\MyObject', [], '', true, true, true, ['initialize', '__get']);
}
@sanks
sanks / yandex-maps-example.js
Last active April 2, 2021 07:44
Getting user region and city with Yandex.Maps API
ymaps.ready(function () {
ymaps.geolocation.get({ provider: 'yandex' }).then(function(result) {
var data = result.geoObjects.get(0).properties.get('metaDataProperty').GeocoderMetaData;
var administrativeAreaName = data.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName; // region
if ('SubAdministrativeArea' in data.AddressDetails.Country.AdministrativeArea) {
var localityName = data.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName; // city
} else {
var localityName = data.AddressDetails.Country.AdministrativeArea.Locality.LocalityName; // city
# This should be the public-facing name (ie: dns name)
HOME_SERVER_URL="https://matrix.org"
# The room ID is NOT the room alias. The ID can be found at the bottom of the room settings dialog in riot-web
ROOM_ID="!AbCDef823s:matrix.org"
# This is your user ID and access token. The access token must match the user.
USER_ID="@turt2live:matrix.org" # The home server should match this domain as well (ie: t2l.io as a HS should be :t2l.io in the user)
ACCESS_TOKEN="token_here"
@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active April 21, 2024 22:10
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@tetrapus
tetrapus / color-tabs.css
Last active July 2, 2018 13:20
Coloured tabs for TST
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
/* override base tab color */
:root:root {
--color-100: white;
}
/* Plain */
.tabbrowser-tab {
--color-main: var(--color-100);
@stecman
stecman / _readme.md
Last active December 26, 2017 20:47
List BTRFS subvolume and snapshot sizes like df

Setting a default color scheme (tint) for Riot on your account

Caution: This requires some amount of technical knowledge about how matrix/riot works.

For reference, the original grey color scheme in Riot had a primary color of #595959 and a secondary color of #ececec

  1. Open the developer tools by typing /devtools
  2. Click the "Explore Account Data" button
  3. Click the "im.vector.web.settings" button (if you don't have this button, use the instructions below instead)
@meysam-mahmoodi
meysam-mahmoodi / kubernetes-uninstall.md
Last active April 12, 2024 18:50
Kubernetes completely uninstall

Kubernetes completely uninstall

This a gist for quick uninstall kubernetes

If the cluster is node, First delete it from master

kubectl drain <node name> — delete-local-data — force — ignore-daemonsets
kubectl delete node <node name>