Skip to content

Instantly share code, notes, and snippets.

View EvAlex's full-sized avatar

Alexander Pavlyuk EvAlex

  • Qoollo
  • Moscow, The Russian Federation
View GitHub Profile
@EvAlex
EvAlex / print-jira-users-status.js
Last active December 26, 2017 11:38
Jira - users remaining till license limit
/**
* 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 July 20, 2017 20:25
EventDebounvcer for Angular
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 July 8, 2017 06:49
Shell script to perform git feature branch merge with squash preserving author
#!/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
@EvAlex
EvAlex / stateful-observer.ts
Created May 12, 2017 09:10
StatefulObserver
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 April 20, 2017 06:52
TypeScript Color class, useful to manipulate rgba components and convert to rga/rgba/hex
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 April 20, 2017 00:26
TypeScript Timer based on requestAnimationFrame()
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 April 20, 2017 11:37
Get Process RAM usage in Windows - Ruby
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)