Skip to content

Instantly share code, notes, and snippets.

View AlexDenisov's full-sized avatar
🇺🇦
Talking to Machines

Alex Denisov AlexDenisov

🇺🇦
Talking to Machines
View GitHub Profile
@AlexDenisov
AlexDenisov / install.md
Last active February 10, 2021 03:26
This script creates PDF from man page and opens it within Preview.app. Only Mac OS X.

pman

Generates PDF from man page and opens it within Preview.app.

Install

curl -o /usr/local/bin/pman https://gist.githubusercontent.com/AlexDenisov/4294335/raw/9fe40c81f6fc94760e81040d2636d0e703fc676f/pman.pl
chmod +x /usr/local/bin/pman

Usage

@AlexDenisov
AlexDenisov / iterate_each_array.pl
Created January 23, 2013 08:44
Iterate few lists with Perl
use List::MoreUtils qw( each_array );
my @first = qw( foo bar buzz );
my @second = (1, 2, 3);
my $it = each_array( @first, @second );
while ( my ($f, $s) = $it->() ) {
print "$f = $s\n";
}
//
// ConformsTo.h
//
// Created by Alex Denisov on 01.03.13.
//
#pragma once
#import <Foundation/Foundation.h>
#import <Cedar-iOS/Cedar-iOS.h>
#include <iostream>
#include <set>
using namespace std;
struct Point {
int x;
int y;
Point(int x, int y)
@AlexDenisov
AlexDenisov / spec_arc_support.rb
Created March 27, 2013 14:51
Add compiler flags on each Spec in target
require 'xcodeproj'
project = Xcodeproj::Project.new 'SomeProject.xcodeproj'
target = project.targets.last
build_phase = target.source_build_phase
files = build_phase.files
settings = { 'COMPILER_FLAGS' => '-fno-objc-arc' }
files.each do |f|
if f.display_name =~ /Spec/
if f.settings
- (void)printWithFormat:(NSString *)format arguments:(NSArray *)arguments
{
NSRange range = NSMakeRange(0, [arguments count]);
NSMutableData * data = [NSMutableData dataWithLength:sizeof(id) * [arguments count]];
[arguments getObjects:(__unsafe_unretained id *)data.mutableBytes range:range];
NSString * result = [[NSString alloc] initWithFormat:format
arguments:data.mutableBytes];
NSLog(@"%@", result);
}
#import <Foundation/Foundation.h>
int main()
{
NSLog(@"%@", @(13));
return 0;
}
@AlexDenisov
AlexDenisov / cocoapods_vs_static_lib.sh
Created December 17, 2013 05:06
CocoaPods vs Static Library
$ time xcodebuild -workspace ./BloodMagic.xcworkspace -scheme BloodMagic -config Debug -sdk iphonesimulator
# 40.31s user 4.15s system 288% cpu 15.435 total
$ time xcodebuild -project BloodMagic.xcodeproj -target BloodMagic -sdk iphonesimulator -configuration Debug build ARCHS=i386
# 18.64s user 2.31s system 282% cpu 7.404 total
@AlexDenisov
AlexDenisov / Makefile
Last active January 1, 2016 16:09
Flex/Bison studying.
all: calc
calc: parser lexer
CC lexer.c parser.c -o calc
lexer:
flex -o lexer.c lexer.l
parser:
bison -d -o parser.c parser.y
std::ostream& operator << (std::ostream& os, NSString *string);
std::ostream& operator << (std::ostream& os, UIEdgeInsets edgeInsets);
std::ostream& operator << (std::ostream& os, CGSize size);
std::ostream& operator << (std::ostream& os, CGPoint point);
std::ostream& operator << (std::ostream& os, CGRect rect);
std::ostream& operator << (std::ostream& os, SEL selector);
std::ostream& operator << (std::ostream& os, Class cls);
std::ostream& operator << (std::ostream& os, BOOL boolean);