Skip to content

Instantly share code, notes, and snippets.

lolgear / ExampleGitHubActionWithCommitAndPush.yaml
Created Mar 1, 2021
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.
View ExampleGitHubActionWithCommitAndPush.yaml
name: Awesome App
# Controls when the action will run.
# Triggers the workflow on push or pull request events but only for the develop branch
branches: [ master ]
# pull_request:
# branches: [ develop ]
name: Build master
lolgear /
Created Sep 29, 2019
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 /
Created Jun 29, 2019
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 / [Proposal] Allow default parameter in generic class
Last active Mar 20, 2018
[Proposal] Allow default values for parameters in generic clause
View [Proposal] Allow default parameter in generic class

[Proposal] Allow default values for parameters in generic clause

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

lolgear / scrivener_rename_jekyll_blog_post_to_metadata_title.rb
Last active Mar 6, 2018
Scrivener post-processing script which rename generated file into Jekyll post naming convention.
View scrivener_rename_jekyll_blog_post_to_metadata_title.rb
# 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 / simpsons_heights_ios_resource_counter.rb
Created Oct 27, 2017
This is simple resource counter that count an amount of time to produce the specific resource represented as vector
View simpsons_heights_ios_resource_counter.rb
# 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 =, 0) { |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 / CoreDataDatabaseCleanup.m
Created Mar 17, 2017
Core data database cleanup
View CoreDataDatabaseCleanup.m
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 /
Created Feb 1, 2017
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;'