Skip to content

Instantly share code, notes, and snippets.

View MurzNN's full-sized avatar
🎯
Focusing

Alexey Murz Korepov MurzNN

🎯
Focusing
View GitHub Profile
@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);
@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active May 3, 2024 20:50
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:

# 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"
@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
@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']);
}
@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'),
);
@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]);
}