Wednesday, April 16, 2014

Setting up ox for mongo

As per http://oxformongo.org/docs/Installation...

Made a virtual host in apache httpd.conf:

<VirtualHost *:80>

        ServerName ox.com

        ServerAlias www.ox.com *.ox.com

        DocumentRoot "/Library/WebServer/Documents/ox/app-blank/webroot"

</VirtualHost>

Modded /etc/hosts to add:

127.0.0.1 ox.com

127.0.0.1 www.ox.com

Put ox in:

/Library/WebServer/Documents/ox

Restart apache.

Inside app-blank:

chmod -R 775 tmp

Changed app-blank/config/app.php to reflect:

$mongo_config = array(

'set_string_id' => TRUE,

'persistent' => TRUE,

'host' => 'localhost', <--make sure this is not the same as your server alias

'database' => 'ox',

'port' => '27017',

'login' => '',

'password' => '',

'replicaset' => '',

);

Also in config/framework.php:

if (!defined('DIR_FRAMEWORK')) {

define ("DIR_FRAMEWORK",'/Libarary/WebServer/Documents/ox/ox/');

}

Started mongod with this command:

mongod --dbpath /Library/WebServer/Documents/ox/data/db/

And on mongo shell I just did:

use ox

to make the 'ox' database referenced in the app.php config file.

Having to install PHP's pear so I can install the mongo extension for PHP to make this work. In my /Users/me/Downloads/ I did:

curl -O http://pear.php.net/go-pear.phar

then

sudo php -d detect_unicode=0 go-pear.phar

as per

http://pear.php.net/manual/en/installation.getting.php

Installing pear I'm using these lcoations:

1. Installation base ($prefix) : /usr/bin/pear

2. Temporary directory for processing : /tmp/pear/install

3. Temporary directory for downloads : /tmp/pear/install

4. Binaries directory : /usr/bin/pear/bin

5. PHP code directory ($php_dir) : /usr/bin/pear/share/pear

6. Documentation directory : /usr/bin/pear/docs

7. Data directory : /usr/bin/pear/data

8. User-modifiable configuration files directory : /usr/bin/pear/cfg

9. Public Web Files directory : /usr/bin/pear/www

10. Tests directory : /usr/bin/pear/tests

11.        Name of configuration file : /Users/me/.pearrc

But it throws this ridiculous warning:

** WARNING! Old version found at /usr/bin/pear, please remove it or be sure to use the new /usr/bin/pear/bin/pear command

The 'pear' command is now at your service at /usr/bin/pear/bin/pear

** The 'pear' command is not currently in your PATH, so you need to

** use '/usr/bin/pear/bin/pear' until you have added

** '/usr/bin/pear/bin' to your PATH environment variable.

So I then edited /Users/me/.profile and appended :/usr/bin/pear/bin to one of my path exports. Fine. That didn't work.. had to do it to .bash_profile. Ahh, that worked. I guess .profile is a vestige of some yesteryear time? Does it only get run at login? Mine is at least four years old.

Anyway according to this mongodb-user Google group message now I do:

pecl install mongo

then add:

extension=mongo.so

to the end of your php.ini

I had to sudo it.

A bunch of stuff flies by. It asks:

Build with Cyrus SASL (MongoDB Enterprise Authentication) support? [no] :

...to which I pressed Enter (no).

A bunch more stuff... A LOT... flies by.

Finally I modified php.ini and restarted apache again. Progress is made, now I'm getting:

404 Error

File (root/index)was not found

if I just go to my URL http://ox.com/. However if I go to the URL http://ox.com/root/ then I get the basic page.

I note that in Ox_FlatAction.php I set DEBUG=TRUE and I see that in ll. 91-93:

$file = DIR_CONSTRUCT . $dir . DIRECTORY_SEPARATOR . $flat_file;

if($this->flat_file_dir) {

$file = $this->flat_file_dir . DIRECTORY_SEPARATOR . $flat_file;

}

So if flat_file_dir is specified as it is when in routes.php l. 6:

Ox_Router::add(WEB_ROOT, new Ox_FlatAction('root'));

So basically when the constructor of Ox_FlatAction gets called on its ll. 54-58:

public function __construct($file_dir=null, $layout = null)

{

$this->flat_file_dir = $file_dir;

$this->layout = $layout;

}

Then $flat_file_dir gets set to /root/ and then in ll. 91-93 above file gets made to be root/index which does not exist because it's referencing the base file system.

I guess we need a rewrite directive in httpd.conf? Well conveniently oxformongo.org's installation doc does not actually show the .conf file text (it's just blank white space :/_).

Anyway not gonna worry about it because they also say in their routes doc that "to set up the route for the webroot, we do:

        Ox_Router::add(WEB_ROOT, new Ox_FlatAction());

...which is different from the base project which had Ox_FlatAction('root'), as you'll note above. Well OK. Now it's working :D

Tuesday, March 11, 2014

RAML

Brian turned me on to RAML: something for describing RESTful APIs in YAML evidently. I noted that it should have stood for RAML API Markup Language.

Friday, March 7, 2014

Wineskin

Haven't been able to get Wineskin to work with lineage15.com's Windows client, not sure why but once it launches, it says the binary is expired. If I set the date to 2010 then I it tries to launch but it just shows a jumbled screen that looks like it was rendered by a defective GPU, and throws an error about not being able to find GameGuard. Weird.

I finally got things going using Oracle's free VirtualBox with Windows XP. It actually runs great!

SSH with Sourcetree

I got SSH working with SourceTree to connect to a private github repo using an alternate keypair (i.e. another one than my id_rsa).

This involved adding the following text to ~/.ssh/config:

Host git-as-USERNAME

HostName DOMAIN.com

User USERNAME

IdentityFile ~/.ssl/USERNAME

And of course generating the USERNAME keypair I referred to this guide, which led to these commands:

ssh-keygen -t rsa -C "your_email@example.com" -f output_keyfile

SourceTree kept asking me for my password even after I set things up to where command line git was working right in the terminal. To fix this I had to format my repo URL with ssh:// in the beginning as suggested by Atlassian.

Wednesday, March 5, 2014

How I got Server Working, Etc.

Used the default settings of l1j-en for opcodes and it worked with lineage15.com's Windows one.

Got a pull from the SDL-based Intel Mac client attempt of Doors-Software.com's Thomas Epperson (uglyoldbob). It's a C++ based project that uses a makefile. His git repo is based on Windows and has Linux and Mac branches. I fixed a memory leak that was crashing the Mac Intel version. Maybe it wasn't crashing for him due to using ARC? Haven't found out yet, but I wasted many hours trying to get that thing into XCode and just could not get it to go. That's its whole own essay.

I finally got the Mac version built just using make. Had to swap out Opcodes.java and ClientThread.java back to what they are on his tikal_antharas_native branch of l1j-en. I can't stop thinking that it would make more sense to use the other opcodes that we know work. I also learned that his client is very early-stage without working sprites or many other things. What he's done so far is incredible but there is clearly much more work to be done. It would be very interesting of course but I'm wondering how much it would be worth to do.

More later.

Thursday, February 27, 2014

Lineage 1 Server Stuff

Been trying to get this to work. Spent most of yesterday. Built the server from the trunk.

But I keep getting the version mismatch error.

Figured out that you have to change the FIRST_PACKET to the 2.70C one and then Mac Crack of Time will be happy. This is the key packet that is sent by Lineage15. They send the version packet 0x32, not 0x7D. At least that's what it appears. Weird.

I also noticed there is a Tikal Antharas server project on github by uglyoldbob and specialdarkwolf. Uglyoldbob is who runs Doors Software and has made a special Mac client that supposedly lets you run the Mac version on Intel, though I couldn't get it to even get me to the login screen on most attempts.

It could have been my router setup since I had ports 2000 & 2001 directing to my computer, maybe that was messing things up. Or maybe there are other ports that need to be configured.

I think uglyoldbob is the same dude who runs the Frisky Cow private server, but I'm not 100% sure.

I suspect my issues relate to ClientThread.java. There are various versions with the different FIRST_PACKETs. I found this one too that has a different one, on the Google Code site. It later gets updated to something newer. It also mentions a 3.2 English Version check and has an "Opcodes.S_OPCODE_INITPACKET" value inserted there, something that's not in the milestone build! This is DarkWolf's and it's from his latest commit of the DarkWolf3.2 branch. It was from late 2012 I think. I haven't tried compiling it yet. In src/server/encryptions/java the value of the S_OPCODE_INITPACKET is 125, which is 0x7D like it's set everywhere. That further confuses me because then why does my client think it's an older version? Or I guess Tikal Antharas *is* 3.2. I guess that would make sense because it's supposedly "Episode 1.2" of "Season 3.0". But then 3.0's version must be something other than 7D, right? O.o.

So I found Darkwolf3.2 branch and got it by doing:

svn checkout http://l1j-en.googlecode.com/svn@781 l1j-darkwolf

I built that in Eclipse. I notice he has done a lot of custom shit in here vs. the main trunk. Nice.

I deleted my db and now I made the milepost 6:

mysql -p -u root l1jdb < l1jdb_m6.sql

Also I realized mysql was not in my path so I added it to /etc/profile.

I made serverstart.sh executable. Had to replace out the backslashes with regular slashes in there. (Un-windows-ize it). Also had to replace ; with :. Final result:

#!/bin/bash

# exit codes of GameServer:

# 0 normal shutdown

# 2 reboot attempt

while :: do

[ -f log/java0.log.0 ] && mv log/java0.log.0 "log/`date +%Y-%m-%d_%H-%M-%S`_java.log"

[ -f log/stdout.log ] && mv log/stdout.log "log/`date +%Y-%m-%d_%H-%M-%S`_stdout.log"

java -Xms1024m -Xmx1024m -cp l1jen.jar:lib/c3p0-0.9.1.2.jar:lib/mysql-connector-java-5.1.17-bin.jar:lib/javolution.jar:lib/bonecp-0.7.1.jar:lib/slf4j-api-1.6.1.jar:lib/slf4j-simple-1.6.1.jar:lib/guava-r09.jar l1j.server.Server > log/stdout.log 2>&1

[ $? -ne 2 ] && break

# /etc/init.d/mysql restart

sleep 10

done

When the client connects to lin 1.5 on port 2001, first they handshake. Then the client PSH: 0x4400. Server ACK. Client PSH: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855. That's the result of:

cksum -a sha256 /dev/null

(according to Hackpedia).

Anyway, server PSH: 0a000101000000 then 255.255.255. ... etc. a bunch of times for 473 bytes. Then the client went and talked to geotrust?? Anyway.

Later server does the standard first packet bullshit:

0032EC90C65CB13C2C28F6651DDD56E3EF

Then the client comes back with

0E 00 9F 41 51 02 90 56 7A 9B C4 49 E6 C8

And the server's all like

1E (30?)

Then

00 2F D3 D2 92 62 5B 88 53 98 9F 31 05 BF 86 55 45 6A 6D C3 2B C4 D7 8C 4D FF F8 56 78

That was with Tikal Antharas client. I think. Lets try a virgin Crack!

Client comes back on mine with:

0A 00 A7 05 AE 47 2A 13 C0 01

So that's different. Why? I got an exception when I used the 3.0 key:

char peer1_0[] = {

0x12 };

char peer1_1[] = {

0x00, 0x32, 0xec, 0x90, 0xc6, 0x5c, 0xb1, 0x3c,

0x2c, 0x28, 0xf6, 0x65, 0x1d, 0xdd, 0x56, 0xe3,

0xef };

char peer0_0[] = {

0x0e, 0x00, 0x84, 0x5a, 0x4a, 0x19, 0x70, 0x49,

0x9a, 0x09, 0xc9, 0x47, 0x71, 0xef };

char peer1_2[] = {

0x0a, 0x00, 0xa7, 0x05, 0xae, 0x47, 0x2a, 0x13,

0xc0, 0x01 };

When I connected TA with 0x32 it gave version mismatch. The mid flush was commented.

Sunday - Test 7

I put in the Darkwolf 3.2 opcodes. I'm also using 0x7d version and Darkwolf first packet. No mid flush.

Version mismatch!

With mid flush: same.

Found a set of C versions here on a TW board. Trying with mid flush on their 3.1.

Sunday, January 26, 2014

Learning about DBs

In Oracle we have LOBs, which could be a big JSON object response you want to store. The we have marts which are slices of that data to build tables against.

"Set up your DB with the series of LOBs, then warehouse the data and use surrogate keys to cross-query." What does this mean exactly?

Wednesday, November 27, 2013

Map and HTTP Stuffs

I made a QONQR API app thing. First time using iOS map and HTTP APIs.

Here was a few gotcha's I ran into, in reverse order.

Setting the map pins is done with MKAnnotation protocol. A protocol is like, a set of methods that an object has to abide by in order to pose as some certain thing or another, I think. To get the map pins to show up I had to make a Map Pin class as described here.

Monday, November 4, 2013

Inverted Color Fix

Finally figured out how to solve my problem about getting the app to know when there's been an invert color notification on iOS. I mentioned it on the dev forums here.

Commas in your decimals

Had to use commas in decimals for Germany. Here's how

Sunday, November 3, 2013

floating point comparisons in CoreData fetch requests

I had to use a predicate like this in order to compare a test value to another one in my predicate so that things were working good.

[NSPredicate predicateWithFormat:@"abs(value - %f) < 0.01", test];

Here was the question I asked:

http://stackoverflow.com/questions/19713261/how-would-you-make-a-predicate-in-coredata-to-search-for-a-float-within-a-tolera

I guess it turns out you can use SQLIte functions like abs() and cetera for more shit. Yay woo. I was led to this because the BETWEEN function doesn't work with floats, but crashes. You get the "unrecognized selector nsnumber" type error.

See also:

Predicate Programming Guide

Getting Stuck

Predicate Format String Syntax

Creating Predicates

Friday, October 18, 2013

CoreData changes

There were some CoreData changes in iOS 7.

I had to add @{ NSSQLitePragmaOptions : @{ @"journal_mode" : @"DELETE" } } to my code to make it work right importing the database from before. The new way adds -shm and -wal files in SQLite DB.

I found this cool CoreData Editor app from Germany but Apple's douchy market limits won't let me buy it.

More interesting stuff

Interesting bit about protocol declarations needing to be made before includes.

Unsolved: when I change the Main View in XCode it bugs out. Lots of other people had this problem too:

- this class is not key value coding-compliant for the key authView

Wednesday, October 16, 2013

Useful lil things lately in IOS

I figured some cool stuff out on Key-Value coding for scalar values that are properties of objects:

https://developer.apple.com/library/ios/documentation/cocoa/conceptual/KeyValueCoding/Articles/DataTypes.html

Also found Touches ended usefule

https://developer.apple.com/library/ios/documentation/uikit/reference/UIResponder_Class/Reference/Reference.html#//apple_ref/occ/instm/UIResponder/touchesEnded:withEvent:

touchesEnded:withEvent:

Good shit on bitwise operators:

http://www.codeproject.com/Articles/2247/An-introduction-to-bitwise-operators

PCI-compliance is important for storing credit cards

http://www.pcicomplianceguide.org/pcifaqs.php

NSSortDescriptors are kind of annoying but maybe cool and useful

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSSortDescriptor_Class/Reference/Reference.html#//apple_ref/occ/clm/NSSortDescriptor/sortDescriptorWithKey:ascending:

Unlike LSL, finding something in an array if it's not there doesn't return -1 but instead 214783647

http://stackoverflow.com/questions/10929929/indexofobject-return-2147483647

The NSRange is an interesting structure

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSRange

I encountered weirdness trying to use TableViewCell's highlighted feature, ended up just giving up and painting my own way of doing it. Probably cuz I was doing it wrong but anyway who cares.

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/c/econst/UITableViewCellStyleValue1

I do want to add a search bar in tableview in an upcoming version

I was trying to think of how to make my UIMenuController not be black-on-black... never got to that

https://developer.apple.com/library/ios/documentation/iPhone/Reference/UIMenuController_Class/UIMenuController.html#//apple_ref/doc/uid/TP40008301-CH1-SW17

Saw Mission Street Grants and thought of applying:

https://www.missionmainstreetgrants.com/rules

I asked this question on CoreData but got no answers;

http://stackoverflow.com/questions/19320929/is-it-ok-to-use-dot-syntax-getters-within-an-nsmanagedobjects-custom-class

Was curious about iOS7/iOS6 deltas in InterfaceBuilder, found this:

http://stackoverflow.com/questions/17794037/interface-builder-what-are-the-uiviews-layout-ios-6-7-deltas-for

Here's how to update your app to a new version, which isn't working for me right now:

https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/11_EditingandUpdatingAppInformation/EditingandUpdatingAppInformation.html#//apple_ref/doc/uid/TP40011225-CH14-SW69

Here's how to beta test your app which also isn't working for me right now:

https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/TestingYouriOSApp/TestingYouriOSApp.html#//apple_ref/doc/uid/TP40012582-CH8-SW1

This was an awesome way to customize the colors of a UISegmentedControl

Saw this interesting idea of "passing around an NSManagedObjectContext" in iOS for keeping ViewControllers segmented. I should read this. It explains why not to be accessing the instance of one viewController inside another viewController, which I seem to do alot.

I also need to read up on Throwing Exceptions.

This was an awesome help tomake a segment of a UISegmentedControl deselect itself.

setBackgroundImage:forState:barMetrics: was useful for coloring my UISegmentedControl.

I thought about trying to animate the angle view display but after seeing that there was a CoreAnimation manifesto I kind of gave up, it doesn't seem to want to animate lines, just layers...

Luda gave an excellent explanation of how to add the done button, OK button, cancel button, or whatever on top of your keyboard in your iOS app.

XS-Labs gives an excellent rundown on XCode build settings

I asked this really stupid question on StackOverflow as to why integers don't get auto-cast as floats when getting assigned to floats. -11 lol

Save graphics from app to camera roll

http://stackoverflow.com/questions/10748669/convert-uiview-to-png-image

Add custom fonts to iOS app

http://www.codigator.com/tutorials/using-custom-fonts-in-ios-application/

Audio capture project

Found this cool project and downloaded it for audio capture and shit

https://developer.apple.com/library/ios/samplecode/AVCaptureToAudioUnit/Introduction/Intro.html#//apple_ref/doc/uid/DTS40012880