Skip to content

Instantly share code, notes, and snippets.

public static void main(String[] args) {
try {
Scanner sc = new Scanner(new File(args[0]));
int n = Integer.parseInt(sc.next());
for (int i = 0; i < n; i++) {
System.out.println(sc.next()); // TEST
}
} catch (FileNotFoundException e) {
AVCaptureSession *session = [[AVCaptureSession alloc] init];
AVCaptureDevice *captureDevice = [[AVCaptureDevice alloc] init];
// Add input/output devices
// Check what media type is supported by the device
NSArray *devices = [AVCaptureDevice devices];
for (AVCaptureDevice *device in devices) {
NSLog(@"Device name: %@", [device localizedName]);
// Print out all font families
// Source: http://stackoverflow.com/questions/11083954/uifont-fontwithname-font-name
NSArray *fontFamilies = [UIFont familyNames];
for (int i = 0; i < [fontFamilies count]; i++) {
NSLog(@"Font: %@ ...", [fontFamilies objectAtIndex:i]);
}
@schifano
schifano / iOS Swift Programmatic UITextFields
Created August 27, 2015 22:09
Experimental code from MemeMe app and former drawTextInRect method.
topTextField.frame = CGRect(x: rect.origin.x, y: rect.origin.y + 500, width: 500, height: 100)
topTextField.backgroundColor = UIColor.blueColor()
self.imageView.addSubview(topTextField)
// I just wasn't changing it enough, 10 pts is really small, apparently
var y: CGFloat = (rect.origin.y - 50.0)
// TEST - DOES THIS EVEN PUT A THING ANYWHERE (the answer was no, bc of autolayout and constraints)
var testTopTextField: UITextField = UITextField(frame: CGRect(x: rect.origin.x + 10, y: y, width: 300.0, height: 50.0))
testTopTextField.text = "KITTENS"
@schifano
schifano / PlaySoundsViewController "Movie Quote" Forrest Gump
Created June 30, 2015 20:54
PlaySoundsViewController.swift - Pitch Perfect - Read one mp3 file rather than a recorded file.
if var filePath = NSBundle.mainBundle().pathForResource("movie_quote", ofType: "mp3") {
// Convert string to NSURL
var filePathURL = NSURL.fileURLWithPath(filePath)
} else {
println("File not found")
}
@schifano
schifano / python-warmup1.py
Last active August 29, 2015 13:55
My solutions for CodingBat Python Warmup-1. This is used to document my initial attempts and improved attempts.
# sleep_in
'''
The parameter weekday is True if it is a weekday,
and the parameter vacation is True if we are on vacation.
We sleep in if it is not a weekday or we're on vacation.
Return True if we sleep in.
'''
@schifano
schifano / gist:8530231
Created January 20, 2014 22:09
C - Prints substring using printf.
int n = 3;
printf("(%.*s)\n", n, filepath);
@schifano
schifano / gist:8516219
Last active January 3, 2016 20:39
C - reads and prints content from a file.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *fp; /* FILE pointer to keep track of file being accessed */
int c;
/* If file is empty, print error message */
if (fp == NULL) {
@schifano
schifano / 0_reuse_code.js
Created January 5, 2014 05:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@schifano
schifano / java-warmup1.java
Last active September 23, 2023 09:20
My solutions for CodingBat Java Warmup-1. This is used to document my initial attempts and improved attempts.
// sleepIn
// The parameter weekday is true if it is a weekday, and the parameter vacation is true if we are on vacation.
// We sleep in if it * is not a weekday or we're on vacation. Return true if we sleep in.
public boolean sleepIn(boolean weekday, boolean vacation) {
if (!weekday || vacation) {
return true;
}
return false;
}