Skip to content

Instantly share code, notes, and snippets.

View amonshiz's full-sized avatar
💻

Andrew Monshizadeh amonshiz

💻
View GitHub Profile
@amonshiz
amonshiz / ConstraintViewController.m
Last active August 29, 2015 14:10
A simple gist demonstrating how one could use Autolayout to dynamically grow a view.
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraint;
@property (weak, nonatomic) IBOutlet UIButton *addButton;
@property (weak, nonatomic) IBOutlet UIView *containerView;
@property (nonatomic, weak) UIView *lastView;
@end
@amonshiz
amonshiz / PresentationController.m
Created December 7, 2014 01:16
Presenting a view controller with the new UIPresentationController
// Present the view controller using the popover style.
myPopoverViewController.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:myPopoverViewController animated: YES completion: nil];
// Get the popover presentation controller and configure it.
UIPopoverPresentationController *presentationController = [myPopoverViewController popoverPresentationController];
presentationController.permittedArrowDirections = UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionRight;
presentationController.sourceView = myView;
presentationController.sourceRect = sourceRect;
<apex:page standardController="Account" extensions="AccountCaseCommentsExtension" showHeader="true" sidebar="true">
<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockTable value="{!account.Cases}" var="c">
<apex:column value="{!c.CaseNumber}" />
<apex:column value="{!c.Subject}" />
<apex:column value="{!caseToCaseComment[c.Id].CommentBody}" />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:component controller="CaseCommentsComponentController" selfClosing="true">
<apex:attribute name="accountId" description="The ID of the Account to reference" type="Id" required="false" assignTo="{!theAccountId}"></apex:attribute>
<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockTable value="{!comments}" var="c">
<apex:column value="{!c.Parent.CaseNumber}" />
<apex:column value="{!c.Parent.Subject}" />
<apex:column value="{!c.CommentBody}" />
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:page standardController="Account" showHeader="true" sidebar="true">
<c:CaseCommentsComponent accountId="{!account.Id}" />
</apex:page>
<apex:component>
<apex:stylesheet value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js" />
<apex:includeScript value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js" />
<style type="text/css">
#sidebarDiv {
background: crimson;
}
</style>
apex:component controller="ActionButtonsComponentController">
<apex:attribute name="prev" assignTo="{!prevPage}" description="The previous page" type="String" required="true" />
<apex:attribute name="next" assignTo="{!nextPage}" description="The next page" type="String" required="true" />
<apex:form>
<apex:commandButton action="{!goToPage1}" value="Page 1" id="button1" />
<apex:commandButton action="{!goToPage2}" value="Page 2" id="button2" />
</apex:form>
</apex:component>
public with sharing class DataWrapper {
public Object value { get; set; }
public DataWrapper() {}
public DataWrapper(Object theValue) {
value = theValue;
}
}
enum PowerUp {
case None
case Scoring (Int)
case Velocity (Int)
}
@amonshiz
amonshiz / CountingDNANucleotides1.hs
Last active August 29, 2015 14:12
Solving Counting DNA Nucleotides on Project Rosalind
countingDNANucleotides = foldl (\(a,c,g,t) x -> if x == 'A' then (a+1,c,g,t) else if x == 'C' then (a,c+1,g,t) else if x == 'G' then (a,c,g+1,t) else if x == 'T' then (a,c,g,t+1) else (a,c,g,t)) (0,0,0,0)