Skip to content

Instantly share code, notes, and snippets.

class A
cattr_reader(
:dictionary
)
@@dictionary = {}
end
class B < A
# gem 'xcodeproj'
# native_target.rb
# @return [String] the name of the build product.
#
attribute :product_name, String
class A
def needToCallAsInstanceAndClass# or no arguments
self.class.needToCallAsInstanceAndClass(self.getArgs)
end
def self.needToCallAsInstanceAndClass(*args)
# wowowow
# implementation here
end
end
class A
def relativePath(path)
self.relativePath(path,self.path)
end
def self.relativePath(path,to_path)
Pathname.new(path).relative_path_from(Pathname.new(to_path))
end
end
ls ./AppIcon.appiconset/*.png | perl -MFile::Basename -ne 'chomp; ($b, $d, $f) = fileparse($_, qr/\.[^.]*/); $s = qx(convert -channel G -separate ${_} ./AppIconPublicBeta.appiconset/${b}.png); print "$s"; print "\n";'
http://www.imagemagick.org/Usage/color_basics/#separate
@lolgear
lolgear / project_find_and_link.pl
Created September 9, 2016 12:46
when you have too many xcworkspaces in your project, you could gather them in a directory and put it in dock
@lolgear
lolgear / git_single_file_revision_search.sh
Created November 23, 2016 15:44
Search Podfile.lock for specific pod commit updates.
# $file = path to file;
# $name = ( name to search (actually, it is a regex) )
# EncryptedCoreData:
# - :commit: 5044489e622143d6efdb69fbbc383748618b5fe4
# + :commit: 4ca0977e9e0b610e6813886276bb7bbd9406335f
#
#
# Pod revision.
git log -p -- FILE | perl -lne '$name = 'PODNAM'; (/^\s+$name[\w-]*:\s*$/ .. /^\+\s+:commit:/) and print'
@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;'
@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.
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.