Skip to content

Instantly share code, notes, and snippets.

View mukhortov's full-sized avatar
:octocat:

Peter Mukhortov mukhortov

:octocat:
View GitHub Profile
@mukhortov
mukhortov / shuffle.ts
Last active November 29, 2023 09:53
Shuffle and group lines in a text file using deno
// ! deno run -A shuffle.ts
// Shuffle and group lines in a text file.
// Groups are created by adding two newlines between each group.
const filename = 'items.txt'
const txt = Deno.readTextFileSync(filename)
const nonEmpty = (i: string) => i.trim() !== ''
@mukhortov
mukhortov / usbreset.c
Last active January 16, 2022 09:02 — forked from x2q/usbreset.c
/* usbreset -- send a USB port reset to a USB device
*
* Compile using: gcc -o usbreset usbreset.c
*
* */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
@mukhortov
mukhortov / update-dns-record.sh
Last active May 18, 2021 10:51
Automatically update Cloudflare DNS record when the server IP has changed.
#!/bin/bash
#
# Automatically update Cloudflare DNS record when the server IP has changed.
#
# 1. Update params below
#
# 2. Add execute permissions:
# chmod +x ./update-dns-record.sh
#
# 3. To run every hour with cron edit crontab file:
@mukhortov
mukhortov / README.md
Last active April 15, 2024 06:11
Migrate GitHub issues with comments and labels to Jira

Migrate GitHub issues with comments and labels to Jira

Set up the environment

  1. Instal Deno. It's a secure runtime for JavaScript and TypeScript.
  2. Generate a personal access token for GitHub. And save it to ~/.github-oauth. You can use the following command to save it:
    echo generated_github_personal_access_token_goes_here > ~/.github-oauth
@mukhortov
mukhortov / tslint.json
Created July 18, 2018 13:24
tslint.json for create-react-app
{
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
"rules": {
"object-literal-sort-keys": false,
"ordered-imports": false,
"interface-name": false
},
"linterOptions": {
"exclude": ["config/**/*.js", "node_modules/**/*.ts"]
}
@mukhortov
mukhortov / remap_section_to_esc.sh
Last active April 30, 2018 20:05 — forked from lauri/gist:84674ab22aafc4e0f398a52a53cfd7ec
Remap section sign key (§) to ESC (useful if you have a MacBook Pro with touch bar)
#!/bin/bash
#
# Remap section sign key (§) to ESC
#
# 0x700000064 - section sign (§) key below ESC
# 0x700000029 - ESC
#
# https://developer.apple.com/library/content/technotes/tn2450/_index.html
#
@mukhortov
mukhortov / timerFormatter.ts
Last active April 11, 2018 17:33
Convert seconds to HH:MM:SS
const timerFormatter = (secs: number): string => {
const secondsInDay = 60 * 60 * 24
const secondsInHour = 60 * 60
const secondsInMinute = 60
const hoursInDay = 24
const days = Math.floor(secs / secondsInDay)
const hours = Math.floor((secs / secondsInHour) % hoursInDay).toString().padStart(2, 0)
const minutes = Math.floor((secs / secondsInMinute) % secondsInMinute).toString().padStart(2, 0)
const seconds = (secs % secondsInMinute).toString().padStart(2, 0)
@mukhortov
mukhortov / UIViewController+VisibleViewController.swift
Created February 28, 2018 08:12
Visible ViewController UIViewController extension
//
// UIViewController+VisibleViewController.swift
//
import Foundation
extension UIViewController {
func currentlyDisplayedViewController() -> UIViewController? {
if isKind(of: UINavigationController.self) {
let navigationController = self as! UINavigationController
@mukhortov
mukhortov / VisibilityToggler+UIView.swift
Created February 28, 2018 08:11
Visibility Toggler UIView Extension
//
// VisibilityToggler+UIView.swift
//
private var associatedPropertyHeight: CGFloat = 0
private var associatedPropertyWidth: CGFloat = 0
extension UIView {
fileprivate var visibilityConstraintIdentifier: String { return "UIVisibilityGenerated" }
@mukhortov
mukhortov / Resize+UIView.swift
Created February 28, 2018 08:09
Resize UIView Extension.swift
//
// Resize+UIView.swift
//
extension UIView {
func resizeX(_ width: CGFloat) {
for constraint in self.constraints {
if constraint.firstAttribute == NSLayoutAttribute.width && constraint.constant != width {
constraint.constant = width
superview?.layoutIfNeeded()