Skip to content

Instantly share code, notes, and snippets.

date +"%Y-%m-%d %H:%M:%S %z" | pbcopy
@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
@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 / [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 / 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 / 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 / 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