Skip to content

Instantly share code, notes, and snippets.

View nacho4d's full-sized avatar

Guillermo Ignacio Enriquez Gutierrez nacho4d

View GitHub Profile
@nacho4d
nacho4d / NSView2PNG
Created October 13, 2011 06:48
[Cocoa] NSView to PNG
/* NSView to PNG */
NSView *view = versionsButton; /* this is the view :) */
NSBitmapImageRep *rep = [view bitmapImageRepForCachingDisplayInRect:[view bounds]];
[view cacheDisplayInRect:[view bounds] toBitmapImageRep:rep];
NSData *data = [rep representationUsingType:NSPNGFileType properties:nil];
[data writeToFile:@"/path/to/the/a/nice/place/view.png" atomically:YES];
@nacho4d
nacho4d / autozip.sh
Created November 14, 2011 06:33
[Shell] Zips a file - To be used with Automator to create a short cut for the task
#! /bin/sh
INFILE=$1
ZIP=".zip"
OUTFILE=$INFILE$ZIP
if [ -f "$INFILE" ]; then
echo "Compressing file: $INFILE"
COUNTER=0
while [ -f $OUTFILE ];
@nacho4d
nacho4d / limit
Created November 15, 2011 06:51
[Shell] Use ipfw to limit internet speed
#!/bin/bash
# configuration
#host1 is for metadata, host2 is for data
host1="api.dropbox.com"
host2="api-content.dropbox.com"
# usage
if [ "$*" == "" ]; then
echo "usage: $0 [restore|off|fast|medium|slow]"
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
#myCanvas {
border: 1px solid #9C9898;
// Created by Guillermo Enriquez on 09/10/2012.
// Copyright 2012 nacho4d. All rights reserved.
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, @"Application", @"AppDelegate");
[pool drain];
return retVal;
}
@nacho4d
nacho4d / [UIView] Drop shadow
Created March 27, 2012 06:10
Adds a drop shadow effect to the view
// Adds a drop shadow to the view
#import <QuartzCore/QuartzCore.h>
@interface UIView (WMAdditions)
- (void)addDropShadow;
@end
@implementation UIView (Dropshadow)
- (void)addDropShadow
@nacho4d
nacho4d / NSTask sample
Created April 8, 2012 13:25
NSTask sample
#import <Foundation/Foundation.h>
void doTaskAndCapture(void);
void doTaskAndCapture()
{
@try
{
// Set up the process
NSTask *t = [[[NSTask alloc] init] autorelease];
[t setLaunchPath:@"/bin/ls"];
@nacho4d
nacho4d / Daemon in OSX Example
Created April 8, 2012 17:06
Daemon in OSX Example
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>
# pragma mark Daemon Protocol
@protocol DaemonProtocol
- (void)performWork;
@end
# pragma mark MyTask Object Conforms to Protocol
@nacho4d
nacho4d / iTunes2Tweeter
Created May 4, 2012 07:28
Tweet current iTunes song using Tweeted for iMac with Applescript
on replace(src, tg, rp)
set oldDel to AppleScript's text item delimiters
set AppleScript's text item delimiters to tg
set myList to text items of src
set AppleScript's text item delimiters to rp
set myText to myList as string
set AppleScript's text item delimiters to oldDel
return myText
end replace
@nacho4d
nacho4d / UniversalCharsetDetectorResults.md
Created June 5, 2012 11:10
Universal Charset Detector Results

Universal Charset Detector:

Possible Encodings:

  • "ibm850"

  • "ASCII"

  • "UTF-8"

  • "X-ISO-10646-UCS-4-3412"

  • "X-ISO-10646-UCS-4-2143"