Skip to content

Instantly share code, notes, and snippets.

View carlosmcevilly's full-sized avatar

Carlos McEvilly carlosmcevilly

View GitHub Profile
@carlosmcevilly
carlosmcevilly / update-hashes.sh
Created February 6, 2014 02:04
make hashes of the ls -lR output for each directory and its subdirectories (one level down) in a ~/work/ directory
#!/bin/bash
export index=~/work/indexes
mkdir -p $index
cd ~/work
for dir in `ls -d *`
do
if [[ -d "$dir" ]]; then
echo doing $dir
@carlosmcevilly
carlosmcevilly / gist:8960812
Created February 12, 2014 17:49
Scaling a UIImage. Use in a category on UIImage.
/* from Bill Dudney's Practical Drawing session at 2011 WWDC */
+ (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)newSize {
UIGraphicsBeginImageContextWithOptions(newSize, YES, 0.0);
CGRect imageRect = {{0.0, 0.0}, newSize};
[image drawInRect:imageRect];
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return scaledImage;
}
@carlosmcevilly
carlosmcevilly / tagthis.py
Last active August 29, 2015 13:56
Add tags to a set of comment lines in notes.txt in the current directory
#!/usr/bin/env python3
"""
Add tags to a set of comment lines in notes.txt
This opens a file called notes.txt in the current
working directory (creating the file if it does not
exist) and prepends lines to it containing the tags
that are passed in on the command line. Tags are
only added once. Can be run again any time to add
@carlosmcevilly
carlosmcevilly / nuke-yadda.pl
Created March 25, 2014 22:26
Remove most legal boilerplate from an Apple sample project. For testing/research purposes only.
#!/usr/bin/perl
use strict;
use warnings;
my $path = $ENV{'XcodeProjectPath'};
$path =~ s{(.*)/\w+\.xcodeproj}{"$1"};
my $cmd = "/usr/bin/find $path -type f -name \"*.[mh]\" -print";
my $files = qx($cmd);
@carlosmcevilly
carlosmcevilly / gist:dfe8824daf219433a0be
Created May 28, 2014 07:22
python3 http server in current directory
python3 -m http.server
@carlosmcevilly
carlosmcevilly / gists-for-user.js
Created October 19, 2014 21:50
bookmarklet that takes you to the gists page for the user whose github pages you are viewing
javascript:void(window.location=window.location.toString().replace(/%5Ehttps:%5C/%5C/(?:www%5C.)?github%5C.com%5C/(%5Cw+)(?:%5C/.*)?$/,'https://gists.github.com/$1'))

Keybase proof

I hereby claim:

  • I am carlosmcevilly on github.
  • I am carlosity (https://keybase.io/carlosity) on keybase.
  • I have a public key whose fingerprint is 213E 95F2 2CBD C8CD BB12 7E63 015F D971 F9D6 B7C7

To claim this, I am signing this object:

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@carlosmcevilly
carlosmcevilly / make-ios-ovpn.pl
Created January 7, 2015 17:46
Given a .pfx and .ovpn file pair, create a new .ovpn file with the key and certs inline, suitable for use with the OpenVPN iOS app.
#!/usr/bin/perl
use strict;
use warnings;
# $Id: make-ios-ovpn.pl,v 0.0 2015/01/07 06:18:40 carlos Exp $
my ($pfxfile, $ovpnfile, $out, $rest) = @ARGV;
error_exit("usage: $0 <pfxfile> <ovpnfile> <out>")
unless (defined($out) && !defined($rest));
#!/bin/bash
#
# Using the information available in the new iOS8 simulator for each
# device/runtime (device.plist), this script creates a readable folder structure
# (no UDIDs, just simple device/runtime names). Inside that structure it creates
# soft links to your apps in development.
#
# You can run this script every time you install an app to your simulator, or
# you can simply call it to access this folder making sure it will always be
# updated :)