Skip to content

Instantly share code, notes, and snippets.

View comm1x's full-sized avatar

Pavel Shorokhov comm1x

View GitHub Profile
#!/usr/bin/env node
const { execSync, spawn } = require('child_process');
const chalk = require('chalk');
function hasChangesInRepo() {
return execSync('git status --porcelain').toString().length > 0;
}
if (hasChangesInRepo()) {
@comm1x
comm1x / PanAndScalingGestureRecognizer.dart
Created December 10, 2019 00:23
Pan and scaling gesture recognizer for flutter
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
class PanAndScalingGestureRecognizer extends StatefulWidget {
final Widget child;
final void Function(Offset initialPoint) onPanStart;
final void Function(Offset initialPoint, Offset delta) onPanUpdate;
final void Function() onPanEnd;
final void Function(Offset initialFocusPoint) onScalingStart;
@comm1x
comm1x / AppActivity.kt
Created December 2, 2019 10:58
Single Activity implementation
class AppActivity: AppCompatActivity() {
companion object {
fun newInstance(context: Context) = Intent(context, AppActivity::class.java)
}
internal val navigationFragment = NavigationFragment()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val rootFrameLayout = FrameLayout(this).apply {
@comm1x
comm1x / AppActivity.kt
Created December 2, 2019 10:58
Single Activity implementation
class AppActivity: AppCompatActivity() {
companion object {
fun newInstance(context: Context) = Intent(context, AppActivity::class.java)
}
internal val navigationFragment = NavigationFragment()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val rootFrameLayout = FrameLayout(this).apply {
@comm1x
comm1x / AppActivity.kt
Created December 2, 2019 10:57
Single Activity implementation
class AppActivity: AppCompatActivity() {
companion object {
fun newInstance(context: Context) = Intent(context, AppActivity::class.java)
}
internal val navigationFragment = NavigationFragment()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val rootFrameLayout = FrameLayout(this).apply {
@comm1x
comm1x / jira-copy-task.js
Created January 14, 2019 15:31
Add button "Copy task name" to JIRA
// ==UserScript==
// @name Copy jira task name
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://kafoodle.atlassian.net/browse/*
// @grant none
// ==/UserScript==
@comm1x
comm1x / mkroundcorners
Created June 5, 2018 15:37
mkroundcorners - script for making round corners for png-images
#!/usr/bin/env bash
set -e
if [ $# -ne 3 ]; then
echo 'mkroundcorners - script for making round corners for png-images.'
echo 'Usage: mkroundcorners source.png 40 target.png'
exit 0
fi
SRC=$1
R=$2
@comm1x
comm1x / sortedby.swift
Created May 20, 2018 19:24
Extension methods .sortedBy .sortedByDescending like in Kotlin
extension Array {
func sortedBy<T: Comparable>(_ cb: (Element) -> T) -> [Element] {
return self.sorted(by: { (l: Element, r: Element) -> Bool in
return cb(l) < cb(r)
})
}
func sortedByDescending<T: Comparable>(_ cb: (Element) -> T) -> [Element] {
return self.sorted(by: { (l: Element, r: Element) -> Bool in
return cb(l) > cb(r)
@comm1x
comm1x / docker_dns_workaround.md
Last active October 22, 2018 15:53
Docker DNS workaround

Docker DNS workaround

1. Run docker container, which will resolve inner containers

version: '2'
services:
  dns-gen:
    container_name: dns-gen 
    image: jderusse/dns-gen

ports:

@comm1x
comm1x / macbench.sh
Last active January 23, 2018 11:26
Script parse macbench site and print in one line in CLI
#!/bin/bash
# brew install gnu-sed
# brew install html-xml-utils
if [ $# -eq 0 ]; then
echo "Mac Benchmark CLI interface"
echo "Usage: bench.sh MODE"
echo " 's' mode for single core"
echo " 'm' mode for multi core"
exit 0