Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexander Pavlyuk EvAlex

View GitHub Profile
@EvAlex
EvAlex / print-jira-users-status.js
Last active Dec 26, 2017
Jira - users remaining till license limit
View print-jira-users-status.js
/**
* Useful when you have more users in Jira than your license limit allows and some of them are inactive.
* Say, you have 89 users, while your license allows only 50. Some of current users are inactive.
* You hired 2 people and want to find out whether there's enough room for them. And if not - which users
* are candidates for removal. Problem is there's no "only active" filter and no sorting by last login date
* on users page in Jira. This script helps solve these problems.
*
* To use this script:
* - go to Administration in your Jira
* - go to Users page
@EvAlex
EvAlex / event-debouncer.ts
Last active Jul 20, 2017
EventDebounvcer for Angular
View event-debouncer.ts
import { Renderer2, NgZone } from '@angular/core';
import { Subject } from 'rxjs/Subject';
export class EventDebouncer {
constructor(private _zone: NgZone, private _renderer: Renderer2) {
}
listen(
target: 'window' | 'document' | 'body' | any,
eventName: string,
@EvAlex
EvAlex / git-squash-merge.sh
Created Jul 8, 2017
Shell script to perform git feature branch merge with squash preserving author
View git-squash-merge.sh
#!/bin/bash
set -e
function select_branch() {
echo "Not merged branches on origin:"
branches=`git branch --list -r --no-merged`
IFS=$'\n' read -d '' -r -a branches_arr <<< "$branches" || true # dunno why, IFS raises error code
if [ ${#branches_arr[@]} -eq 0 ]; then
echo "\e[93mNo unmerged remote branches found\e[0m"
exit
View stateful-observer.ts
import { Observer, Observable, ReplaySubject, Subscriber } from 'rxjs/Rx';
interface IObserver<T> {
next(value?: T): void;
error(err: any): void;
complete(): void;
}
/**
* Provides Observer interface implementation that is handy for use in data-binding
@EvAlex
EvAlex / color.ts
Created Apr 20, 2017
TypeScript Color class, useful to manipulate rgba components and convert to rga/rgba/hex
View color.ts
export const RGB_COLOR_REGEX = /\((\d+),\s*(\d+),\s*(\d+)(,\s*(\d*.\d*))?\)/;
export class Color {
public r: number;
public g: number;
public b: number;
public a: number;
constructor()
constructor(colorStr?: string)
@EvAlex
EvAlex / timer.ts
Last active Apr 20, 2017
TypeScript Timer based on requestAnimationFrame()
View timer.ts
class Timer {
private _tasks: ITimerTask[] = [];
private _enabled = false;
register(fn: Function, period: number, dueTime = 0): number {
const id = this._tasks.map(t => t.id).reduce((p, c) => p > c ? p : c, 0) + 1;
this._tasks.push({
id: id,
registerTime: new Date(),
@EvAlex
EvAlex / process_ram_usage_windows.rb
Last active Apr 20, 2017
Get Process RAM usage in Windows - Ruby
View process_ram_usage_windows.rb
require 'CSV';
def get_ram_usage(pid)
output = CSV.parse(`tasklist /FO CSV /V /FI "PID eq #{pid}"`)
# Column name is "Mem Usage". Usually it's 5-th column (index 4)
col_index = output[0].each_index.select { |i| output[0][i] =~ /mem/i }.first || 4
parse_usage_str output[1][col_index]
end
def parse_usage_str(str)
You can’t perform that action at this time.