Skip to content

Instantly share code, notes, and snippets.

View pgorod's full-sized avatar

pgorod

View GitHub Profile
@pgorod
pgorod / Add_WindowsDefender_Exclusions.ps1
Created November 18, 2023 10:52 — forked from dkorobtsov/Add_WindowsDefender_Exclusions.ps1
PowerShell script to add Windows Defender exclusions for WSL2 and JetBrains IDE performance issues
# PowerShell script to add Windows Defender exclusions for WSL2 and JetBrains IDE performance issues
#
# For context please read this thread:
# https://github.com/microsoft/WSL/issues/8995
#
# How to use?
# - Save the Script: Open a text editor like Notepad and paste the PowerShell script into it.
# - Save the file with a .ps1 extension, for example, Add_WindowsDefender_Exclusions.ps1.
# - Run PowerShell as Administrator: Search for "PowerShell" in the Start menu, right-click on it, and choose "Run as administrator".
# - Navigate to the Script's Location: Use the cd command to navigate to the directory where you saved the .ps1 file.
@pgorod
pgorod / gist:bd53339fbf6bddbed824c762539ed058
Last active March 12, 2020 14:20 — forked from jmertic/gist:5660495
Programmatically Find the Name of the Relationship between two Modules
<?php
function getRelationshipByModules ($m1, $m2)
{
global $db,$dictionary,$beanList;
$rel = new Relationship;
if($rel_info = $rel->retrieve_by_sides($m1, $m2, $db)){
$bean = BeanFactory::getBean($m1);
$rel_name = $rel_info['relationship_name'];
foreach($bean->field_defs as $field=>$def){
@pgorod
pgorod / showAsPrint.js
Created June 25, 2019 09:51 — forked from jscher2000/showAsPrint.js
Emulate print media in Firefox 62 (userscript work in progress)
// For Firefox's Web Console, creates the functions showAsPrint() and undoShowAsPrint()
// to roughly emulate print media and revert
function showAsPrint(){
var docSS = document.styleSheets, ss, oldMedia, newMedia, rules;
var p2s = function(media){
if (media.indexOf('all') > -1) return media; //no need to change
if (media == 'print') return 'all, wasprint'; //show on screen, too
if (media.indexOf('print') > -1 && media.indexOf('screen') > -1) return media; //no need to change
if (media == 'screen') return 'wasscreen'; //hide these rules
if (media.indexOf('screen') > -1) return media.replace('screen', 'wasscreen'); //hide these rules
<?php
namespace Pokus;
class Exception extends \Exception
{
}
function tttt($string)
{
try {
@pgorod
pgorod / repair.php
Created December 12, 2018 18:04 — forked from chicks/repair.php
Quick Repair and Rebuild Sugar from the Command line - adapted from Jeff Bickhart's version.
#! /usr/bin/env php
<?php
# Stuff we have to do
if(!defined('sugarEntry'))define('sugarEntry', true);
function usage() {
global $argv;
return "\n" . $argv[0] . " <path to sugar>\n";
}
@pgorod
pgorod / Undo a commit and redo
Created April 2, 2018 17:00 — forked from tkersey/Undo a commit and redo
Git: undo a commit and redo
http://stackoverflow.com/questions/927358/git-undo-last-commit
Undo a commit and redo
$ git commit ...
$ git reset --soft HEAD^ (1)
$ edit (2)
$ git commit -a -c ORIG_HEAD (3)
This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before "reset".
@pgorod
pgorod / gist:5de7c6f8d37413654b16e06668d7e1b1
Last active February 12, 2024 19:36 — forked from jmertic/gist:3684156
HOWTO: Adding your own ListView action items - Part 1
<?php
require_once('include/MVC/View/views/view.list.php');
class CustomAccountsViewList extends ViewList
{
/**
* @see ViewList::preDisplay()
*/
public function preDisplay()
@pgorod
pgorod / gist:c838f258fadf9528b61183e763e978a8
Last active October 8, 2017 18:11 — forked from jmertic/gist:3684162
HOWTO: Adding your own ListView action items - Part 2
<?php
class CustomAccountsController extends SugarController
{
public function action_displaypassedids() {
if ( !empty($_REQUEST['uid']) ) {
$recordIds = explode(',',$_REQUEST['uid']);
foreach ( $recordIds as $recordId ) {
$bean = SugarModule::get($_REQUEST['module'])->loadBean();
$bean->retrieve($recordId);
@pgorod
pgorod / backup_github_issues.sh
Last active November 5, 2021 16:13 — forked from bojanpopic/backup_github_issues.sh
A (dirty) bash script that will backup issues from the GitHub repo using API. It takes pagination into consideration. Originally created by @boombatower, improved by @bojanpopic, them improved by me to handle number of pages automatically.
#!/bin/bash
# based on the script by Bojan Popic https://gist.github.com/bojanpopic/2c3025d2952844de1dd0
# Gets all issues form a repo. Since Pull Requests are also Issues in Github internally, these are also included.
repo="organization/repoName" # put the name of the repo here. Usually it is like this: organization/repo-na$
username="myuser" # your github username
password="mypassword" # your github password
# this script can be used on public repos with any user's credentials, you don't have to own the repo!