Skip to content

Instantly share code, notes, and snippets.

View phynet's full-sized avatar
🤘
I said yeah.

Sofia Swidarowicz phynet

🤘
I said yeah.
View GitHub Profile
@phynet
phynet / gist:10732884
Last active August 29, 2015 13:59
CellForRow
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellName = @"CellViewName";
CellChatEditNameGroup *aCellName = [tableView dequeueReusableCellWithIdentifier:cellName];
if (aCellName == nil) {
NSArray *views = [[NSBundle mainBundle] loadNibNamed:cellName owner:nil options:nil];
aCellName = (CellViewName *)[views objectAtIndex:0];
}
@phynet
phynet / designer.html
Last active August 29, 2015 14:05
designer
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../yt-video/yt-search-video.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
@phynet
phynet / gist:57b3c6548dd8948423f9
Last active August 29, 2015 14:24
Swift Cheat Page

##Extension A Swift extension is similar to an Objective-C category. Extensions expand the behavior of existing classes, structures, and enumerations, including those defined in Objective-C.

extension Double {
   var km: Double { return self * 1_000.0 }
   var m: Double { return self }
   var cm: Double { return self / 100.0 }
   var mm: Double { return self / 1_000.0 }
   var ft: Double { return self / 3.28084 }

}

##Translate removeObjectAtIndex from NSMutableArray into Array in Swift

If you were wondering how in hearth you could removeObject from an Array declared in Swift... I was in your same predicament. Thankfully there are people out there that came first, and found a solution. I'm goin to translate it here for you all and of course, for me...

###Objective-C code:

[self.selectedRows removeObject:[NSNumber numberWithLong:indexPath.row]];

Taken from Stackoverflow

func f(n: Int) {
  func lap(n: Int) -> Int {
    if n == 0 { return 0 }
    print(n)
    return lap(n - 1)
  }
  lap(n)

}

Previous Swift 2.0, the option .character for String's type, was obtained using advance and startIndex (pretty much a pain in the butt, so make it an extension and you could have the characters :P )

var kString = "My string"
var countString = count(kString)

for i in 0...countString - 1 {
  let index = advance(kString.startIndex, i)
  print("INSIDE FOR \(kString[index])")
  self.labelAmount.text?.append(kString[index])
@phynet
phynet / observer_updateData.m
Created September 14, 2015 06:38
Using NSNotification to update data
__typeof__(self) __weak wself = self;
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
[wself updateData];
}];
let orderedSet = NSOrderedSet(array: [ 42, 43, 44])
var enumarator = orderedSet.reversedOrderedSet
print(enumarator)
for elem in orderedSet {
print("elements \(elem)")
}
@phynet
phynet / parse.js
Created November 11, 2015 07:17
To know which column/property has been changed in beforeSave in PARSE
for (var i in userPoints.dirtyKeys()) {
var dirtyKey = userPoints.dirtyKeys()[i];
alert("DIRTY KEY val " + dirtyKey);
}
@phynet
phynet / UIView-shadow.m
Created December 21, 2015 15:22
Create a shadow under a uiview
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:self.menuView.bounds];
self.menuView.layer.masksToBounds = NO;
self.menuView.layer.shadowColor = [UIColor blackColor].CGColor;
self.menuView.layer.shadowOffset = CGSizeMake(0.0f, 0.5f);
self.menuView.layer.shadowOpacity = 0.75f;
self.menuView.layer.shadowPath = shadowPath.CGPath;