Skip to content

Instantly share code, notes, and snippets.

View MurzNN's full-sized avatar
🎯
Focusing

Alexey Murz Korepov MurzNN

🎯
Focusing
View GitHub Profile
@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:

@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>
@andriyun
andriyun / drupal8-change-active-theme-programmatically.php
Last active November 22, 2022 19:56
Drupal 8 switch active theme programmatically
<?php
/**
* See original implementation http://cgit.drupalcode.org/mailsystem/tree/src/MailsystemManager.php#n60
*/
// Switch the theme to the configured mail theme.
$theme_manager = \Drupal::service('theme.manager');
$mail_theme = '[your theme name]';
$current_active_theme = $theme_manager->getActiveTheme();
if ($mail_theme && $mail_theme != $current_active_theme->getName()) {
$theme_initialization = \Drupal::service('theme.initialization');
@hagemann
hagemann / blocksToHtml.js
Last active October 27, 2022 08:11
Render EditorJS blocks to HTML.
const renderHtml = (blocks) => {
var html = blocks.map(block => {
switch (block.type) {
case 'code':
return `<pre><code>${ block.data.code }</pre></code>`
/**
* Original type is 'header' but I renamed the block to follow correct terminology:
* https://github.com/editor-js/header/issues/21
*/
@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']);
}
@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]);
}
@DiesIrae
DiesIrae / cascadeDelete.ts
Last active March 22, 2022 20:10
Abstract Cascade Delete Hook for Keystone 6
// "@keystone-next/types": "^22.0.0",
// "@keystone-next/keystone": "^22.0.0"
// The actual lib
// utils/keystone/cascadeDelete.ts
import { ListHooks } from "@keystone-next/types"
import { BaseGeneratedListTypes } from "@keystone-next/types/src/utils"
type BeforeDeleteType = Exclude<
ListHooks<BaseGeneratedListTypes>["beforeDelete"],
@adrianlzt
adrianlzt / sharescreen
Last active January 7, 2022 07:14
Scripts to share only a portion of the screen
#!/bin/bash
# Modified version of https://github.com/Ashark/hliss/blob/master/vlc-hangouts
# Script to share a portion of the screen in VLC to be used by Chrome/Firefox to share the screen
# By default, when run, it asks to click in some window. The area of that window is what is going to be shared.
# If executed with "sharescreen area", it asks for a portion of the screen to be shared.
unset x y w h
# Old code to choose a monitor
@alfianmalik
alfianmalik / README.MD
Last active December 11, 2021 22:59
how to install protobuf + grpc + php on ubuntu

Hello, i am try to install protobuf + grpc + php, here is how i do

sudo apt install php-dev protobuf-compiler protobuf-compiler-grpc
sudo pecl channel-update pecl.php.net
sudo pecl install grpc protobuf

sudo -i
cd /etc/php/7.1/mods-available  
echo "extension=protobuf.so" &gt; protobuf.ini
@MurzNN
MurzNN / element-web-update.sh
Last active October 21, 2021 16:43
element-web-update.sh - bash script for auto-update web version of Element IM to latest version from GitHub vector-im/element-web project releases
#!/bin/bash
###################################################################
# Script for check new version of Element from github
# and download new version, if update is avaiable
#
# https://gist.github.com/MurzNN/ee64f98ab2e71b886c41d55594e5dd9e
#
###################################################################