Skip to content

Instantly share code, notes, and snippets.

# Database dump from remote Postgres database
pg_dump postgres://username:password@example.com:5432/databasename > ~/Desktop/database.sql
# Restore dump to remote Postgres database
psql postgres://username:password@example.com:5432/databasename < ~/Desktop/database.sql
@enriquez
enriquez / Rakefile
Created June 16, 2015 00:13
Example Rake tasks for building and testing apps with xctool
desc 'Run Tests'
task :test do
system 'xctool -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator run-tests'
end
namespace :myapp do
desc 'Build archive for MyApp Beta'
task :build_beta do
system 'xctool -workspace MyApp.xcworkspace -scheme MyApp -configuration Beta archive'
@enriquez
enriquez / git_versioning
Created June 16, 2015 00:11
Script for automatically versioning builds. Run this in a build phase.
#!/usr/bin/env ruby
built_products_dir = ENV['BUILT_PRODUCTS_DIR']
infoplist_path = ENV['INFOPLIST_PATH']
dsym_dir = ENV['DWARF_DSYM_FOLDER_PATH']
dsym_path = ENV['DWARF_DSYM_FILE_NAME']
info_plist = File.join(built_products_dir, infoplist_path)
dsym_info_plist = File.join(dsym_dir, dsym_path, "Contents", "Info.plist")

Keybase proof

I hereby claim:

  • I am enriquez on github.
  • I am enriquez (https://keybase.io/enriquez) on keybase.
  • I have a public key whose fingerprint is 24EF C494 25A1 9B68 CBE4 2011 7C13 16AD 970A 5701

To claim this, I am signing this object:

@enriquez
enriquez / openssl_pem.m
Created December 20, 2013 03:41
Write EC_KEY in PEM to STDOUT
- (void)logPEMForKey:(EC_KEY *)key {
const EC_GROUP *group = EC_KEY_get0_group(key);
PEM_write_ECPKParameters(stdout, group);
PEM_write_EC_PUBKEY(stdout, key);
PEM_write_ECPrivateKey(stdout, key, NULL, NULL, 0, NULL, NULL);
}
@enriquez
enriquez / MEAppDelegate.m
Created November 10, 2013 06:01
Use Private API for hiding status bar text. The Apple Product images (https://developer.apple.com/app-store/marketing/guidelines/#images) provide a generic status bar with full cell signal, 9:41 time, and full battery. I used this code to hide the status bar and took screenshots with the simulator. Then I placed the screenshots into the product …
#import "MEAppDelegate.h"
@interface UIStatusBar
@property(retain) UIColor * foregroundColor;
@end
@implementation MEAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Example of a better API for UIActionSheet
- (void)showActionSheet {
ECActionSheet *actionSheet = [[ECActionSheet alloc] initWithTitle:@"Title" cancelButtonTitle:@"Cancel"];
// set a destructive button if needed
[actionSheet addDestructiveButtonWithTitle:@"Destructive Button" target:self action:@selector(destructiveButtonPressed)];
// add buttons with target/action
[actionSheet addButtonWithTitle:@"Button One" target:self action:@selector(buttonOnePressed)];
@enriquez
enriquez / MENetworkOperation.h
Created August 23, 2012 18:25
another NSURLConnection in an NSOperation
//
// MENetworkOperation.h
//
// Created by Michael Enriquez on 8/21/12.
//
//
#import <Foundation/Foundation.h>
@interface MENetworkOperation : NSOperation <NSURLConnectionDelegate>
@enriquez
enriquez / server.js
Created May 27, 2011 23:50
Node server that prints the request method, url, body, and time since the last request.
var http = require('http');
var count = 0;
var body = '';
var lastStamp = new Date().getTime();
http.createServer(function (req, res) {
req.addListener('data', function(chunk) {
body += chunk;
});
req.addListener('end', function() {
Free tier EC2 Ubuntu Server 64bit: ami-3202f25b