Skip to content

Instantly share code, notes, and snippets.

View amster's full-sized avatar
🎹

Amy Lee amster

🎹
View GitHub Profile
@amster
amster / WordleEmojiFormatter.ts
Created January 8, 2022 00:09
Given a Wordle answer and your guesses, it will format an emoji grid and English alt text.
// Wordle Emoji Formatter
//
// Given the correct word and your guesses, generates an emoji representation and ALT text.
let PUZZLE_NUMBER: number = 202;
let WORD: string = 'slump';
let GUESSES: string[] = ['clear', 'hoist', 'dumpy', 'slump'];
// ---
NSString *fileName = @"foo.json";
NSURL *documentsFolderURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
NSString *filePath = [documentsFolderURL.path stringByAppendingString:fileName];
NSString *jsonString = [[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL];
NSError *jsonError;
NSMutableDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&jsonError];
NSArray *allUrlsInDirectory = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
NSURL *documentsFolderURL = [allUrlsInDirectory lastObject];
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
exec:{
build:{
command:"phonegap build ios",
stdout:true,
stderror:true
}
{
"name": "YourAppHere",
"version": "0.0.1",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-uglify": "~0.2.2"
},
"dependencies": {
- (void)goToFirstPage:(id)sender {
int currentPage = [[self.pager.viewControllers objectAtIndex:0] idx];
// Don't do anything if we're already at the first page
if (currentPage =< 0) {
return;
}
// Instead get the view controller of the first page
SomePageViewController *newInitialViewController = (SomePageViewController *)[self viewControllerAtIndex:0];
- (void)goToPreviousPage:(id)sender {
int currentPage = [[self.pager.viewControllers objectAtIndex:0] idx];
// Don't do anything if we're already at the first page
if (currentPage =< 0) {
return;
}
// Instead get the view controller of the previous page
SomePageViewController *newInitialViewController = (SomePageViewController *)[self viewControllerAtIndex:(currentPage - 1)];
// Assuming property UIPageViewController *pager.
- (void)viewDidLoad
{
[super viewDidLoad];
// Create it.
self.pager = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
// Point the datasource back to this UIViewController.
// Assuming again pageViewController.viewControllers returns the
// NSArray of UIViewControllers and the object at index 0 is the
// current view controller---which has a property idx indicating
// the current page.
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController {
int currentPage = [[pageViewController.viewControllers objectAtIndex:0] idx];
return currentPage;
}
// Assuming SomePageViewController has a property called idx that holds its page number.
// Some number
#define MAX_PAGES 5
// Factory method
- (UIViewController *)viewControllerAtIndex:(int)i {
// Asking for a page that is out of bounds??
if (i<0) {
return nil;