Skip to content

Instantly share code, notes, and snippets.

@lolgear
lolgear / ExampleGitHubActionWithCommitAndPush.yaml
Created March 1, 2021 10:45
This is an example workflow that shows how to keep build number in a repository and keep it up-to-date. This action is fired on push to specified branch.
name: Awesome App
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [ master ]
# pull_request:
# branches: [ develop ]
jobs:
name: Build master
@lolgear
lolgear / replace_tabs_with_spaces_in_swift_files.sh
Created September 29, 2019 11:33
Shell command to replace tabs with spaces ( 4 count in example ) in files matching pattern ( swift files )
find . -name '*.swift' | perl -ple 's/ /\\ /g' | xargs perl -i -lpe 's/^\t/ /g'
@lolgear
lolgear / find_headers_and_move_them_to_one_directory.sh
Created June 29, 2019 15:57
Search in a directory Core and put all headers in one directory Core/Include
find Core -name '*.h' | perl -ne 'chomp; my $f = (split("\/"))[-1]; my $s = qq(mv $_ Core/Include/$f); print $s, "\n"; print qx($s);'
@lolgear
lolgear / [Proposal] Allow default parameter in generic class definition.md
Last active March 20, 2018 19:32
[Proposal] Allow default values for parameters in generic clause

[Proposal] Allow default values for parameters in generic clause

During the review process, add the following fields as needed:

@lolgear
lolgear / scrivener_rename_jekyll_blog_post_to_metadata_title.rb
Last active March 6, 2018 07:01
Scrivener post-processing script which rename generated file into Jekyll post naming convention.
#!/usr/bin/ruby
# This script rename blog-post to jekyll conventions naming.
# Suppose, that you have a file with metadata content.
# File.txt:
# ---
# title:'Wow, title. Rename blog-post.'
# date:26.01.2018 12:31:55 GMT+3
# ---
# ruby script.rb -i File.txt
@lolgear
lolgear / simpsons_heights_ios_resource_counter.rb
Created October 27, 2017 20:25
This is simple resource counter that count an amount of time to produce the specific resource represented as vector
# Space describe the dependencies between coordinates
class Space
attr_accessor :basis, :normalized_basis
def add(lhs, rhs)
# pp "left -> #{lhs}"
# pp "right -> #{rhs}"
max = [lhs.count, rhs.count].max
result = Array.new(max, 0).each_with_index.map { |e, i|
# puts "left -> #{lhs[i]} right -> #{rhs[i]} e -> #{e}"
e += lhs[i] if i < lhs.count
date +"%Y-%m-%d %H:%M:%S %z" | pbcopy
ls Resources/*.png | perl -lne '$old = $_; s/(\@\w+)/_inverted$1/; $_ = qx(basename $_); chomp; $_ = qq(Results/$_); $s = qq(convert $old -fuzz 10% -fill none +opaque white $_); print $s; print qx($s);'
# 1. details:
# 2. take png images from directory Resources
# 3. append "_inverted" before \@ symbol.
# 4. convert $old -fuzz 10% -fill none +opaque white $new
# 5. -fuzz add threshold in 10% for white color. Which are NOT white in 10% thresholds would be removed.
# 6. -fill none should fill color with transparent color
# 7. +opaque matches color to be replaced. plus add inversion. So, +opaque matches these colors that SHOULD NOT be replaced.
@lolgear
lolgear / CoreDataDatabaseCleanup.m
Created March 17, 2017 16:26
Core data database cleanup
/*
For example, you use Core Data sqlite.
It is necessary, because sqlite database stores data in single file.
Whole database is single file.
Now you have two options.
1. Delete all data from all tables
2. Delete database sqlite file
Second option is clean but complex.
@lolgear
lolgear / git_format_commits_between_tags.sh
Created February 1, 2017 11:51
Output commits between two tags with format including date and sha and message
git log --format='%ad %h %B' 'TagName'..'HEAD' | perl -ne '/^\s+$/ or print;'