Skip to content

Instantly share code, notes, and snippets.

@lolgear
lolgear / C fgets stop at eof and newline
Created December 5, 2012 04:33
fgets normal input from stdin with stop at newline
char* inputStringWithStopChar(char stopChar){
int n = 5;
int size = n;
char* const_str = (char*)malloc(n*sizeof(char));
char* substring = (char*)malloc((n+n)*sizeof(char));
char*p;
while((fgets(const_str,n,stdin)!=NULL)&&(strchr(const_str,stopChar)==NULL)){
strcat(substring,const_str);
size += n;
substring = (char*)realloc(substring,size*sizeof(char));
@lolgear
lolgear / reset_settings_and_content_ios_simulator
Created December 13, 2012 10:59
reset settings and content ios simulator script
#!/usr/bin/perl
sub before_space{
for(@_){
s/[ ]/\\ /g;
}
return @_;
}
my $path = $ENV{HOME}.'/';
$path .= q(Library/Application Support/iPhone Simulator);
@lolgear
lolgear / gist_parrot_gsoc_2013.md
Last active December 17, 2015 13:09
GNU Scientific Library (GSL) bindings for Parrot

Abstract

This project can be thought of as porting a subset Math::GSL to Parrot.

Details

There are many GSL subsystems, so this project should focus on binding to Special Function, Random Distributions and Cumulative Distribution Functions (CDFs), which have the simplest function signatures. Deliverables will be the implementation, examples, docs and tests.

Schedule

May 27- June 16:

This period I will spent on read documentation to parrot, also see examples of GSL library.

@lolgear
lolgear / clear_script.pl
Created June 10, 2013 16:07
This script clear data, which were placed in directory .../DerivedData - directory of compiled Xcode projects
#!/usr/bin/perl
my $pathToCacheDirectory = qq(~/Library/Developer/Xcode/DerivedData/);
sub TaskToDo{
my ($refToArgv)=@_;
die "can't work with too much parameters" unless(scalar(@$refToArgv)==1);
my $what = shift @$refToArgv;
my $time = 30; #wait 30 seconds in each iteration
my $workRef = sub{
print "i will delete: ";
@lolgear
lolgear / build_osx_framework_without_pin_in_ass.pl
Last active May 3, 2016 17:00
this is very helpful script, which can helps me and you to build Xcode libraries into frameworks ;) (NB: It will need some fixes about framework Resources)
#----- Common functions -----#
sub say {
for (@_){print; print "\n";}
}
sub qxx{
my $what = shift;
say qq(I will do $what);
my $str = qx($what);
if ($?){
die "I fall down on < $what >\n! because of < $? >";
/Users/mac/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- git (LoadError)
from /Users/mac/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/mac/Documents/Projects/BitBucket/KulaTechAutomaticBuildService/GitManager/GitManager.rb:3:in `<module:GitManipulations>'
from /Users/mac/Documents/Projects/BitBucket/KulaTechAutomaticBuildService/GitManager/GitManager.rb:1:in `<top (required)>'
from /Users/mac/Documents/Projects/BitBucket/KulaTechAutomaticBuildService/BuildService.rb:6:in `require_relative'
from /Users/mac/Documents/Projects/BitBucket/KulaTechAutomaticBuildService/BuildService.rb:6:in `<module:BuildService>'
from /Users/mac/Documents/Projects/BitBucket/KulaTechAutomaticBuildService/BuildService.rb:1:in `<top (required)>'
from /Users/mac/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/mac/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/
# ------------------ Gemfile ------------------ #
source 'https://rubygems.org'
ruby '2.1.2'
gem 'git', :git => 'https://github.com/schacon/ruby-git.git', :tag => 'v1.2.8'
gem 'json'
gem 'xcodeproj', :git => 'https://github.com/CocoaPods/Xcodeproj.git', :tag => '0.18.0'
self.images =
images
.select{
|image|
image.kind_of?(ImageClass)
}
.map{
|image|
self.generate_image_object_from_image
}
Project/Helpers/Helpers.rb
Component/ComponentModule.rb
Component/ComponentParts/FirstPart.rb
Component/ComponentParts/SecondPart.rb
# how to solve dependency: SecondPart.rb use Helpers.rb ( module NecessaryHelp ) ?)
attr_accessor(
:path,
:name
)
def initialize(path,name)
self.path = path
if name
@name = name
end