Skip to content

Instantly share code, notes, and snippets.

// A simplified version of my view controller implementation.
// Assume that the user hasn't purchased anything yet, and that I will persist the transaction properly to user defaults.
import UIKit
import StoreKit
/// A view controller for the settings.
class SettingsTableViewController: UITableViewController {
/// The widget's IAP product, which will exist after we query the app store.
/** Returns the starting index of a longest run of two or more consecutive repeated values
* in the array `values`.
* @param values an array of integer values representing a series of number cube tosses
* Precondition: `values.length > 0`
* @return the starting index of a run of maximum size;
* `-1` if there is no run
*/
public final int getLongestRun(final int[] values) {
final int NO_RUN = -1;
func gcd(x: Int, _ y: Int) -> Int {
var a, b: Int
if x > y { a = x; b = y }
else { a = y; b = x }
var remainder: Int
repeat {
remainder = a % b
a = b
func isEven(number: Int) -> Bool {
return number % 2 == 0
}
//isEven(31)
func isDivisible(x: Int, by y: Int) -> Bool {
return x % y == 0
}
//isDivisible(30, by: 5)
@NathanJang
NathanJang / DailyTemp.java
Created September 22, 2015 12:51
APCS Unit 1 Troll FRQ
import javax.swing.JOptionPane;
public class DailyTemp
{
public static void main(String[] args) {
String numDays = JOptionPane.showInputDialog("Please enter the number of days");
int intnumDays = Integer.parseInt(numDays);
// number 2
int[] dates = new int[intnumDays]; /*
@NathanJang
NathanJang / ShittyPasswordApp.java
Last active January 21, 2016 01:19
Bad code for APCS
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
public class ShittyPasswordApp
{
public static void main(String[] args) {
new ShittyPasswordApp().run();
}
private ShittyPasswordApp() {}
This file has been truncated, but you can view the full file.
0 info it worked if it ends with ok
1 verbose cli [ 'node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '--save-dev',
1 verbose cli 'electron-prebuilt' ]
2 info using npm@2.9.1
3 info using node@v0.12.2
4 verbose node symlink /usr/local/bin/node
5 verbose install initial load of /Users/jonchan/Gits/Private/SRT-signup/package.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am nathanjang on github.
  • I am nathanjang (https://keybase.io/nathanjang) on keybase.
  • I have a public key whose fingerprint is 74C8 AF62 24AD FADE BB95 3045 F5CD F10B BA27 3A64

To claim this, I am signing this object: