Skip to content

Instantly share code, notes, and snippets.

View jquave's full-sized avatar
✔️
jquave

Jameson Quave jquave

✔️
jquave
View GitHub Profile
- (NSDate *)beginningOfWeek {
NSCalendar *calendar = [NSCalendar currentCalendar];
// Get the weekday component of the current date
NSDateComponents *components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekCalendarUnit | NSWeekdayCalendarUnit)
fromDate:self];
[components setWeekday:1];
return [calendar dateFromComponents:components];
}
// Hack to pop up link clicks in a new modal view
// Thanks to http://niw.at/articles/2009/02/06/how-to-enable-the-popup-window-on-uiwebview/en
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if(navigationType == UIWebViewNavigationTypeLinkClicked || navigationType == UIWebViewNavigationTypeFormSubmitted) {
NSURL *url = [request URL];
NSString *urlString = [url absoluteString];
NSString *urlScheme = [[[request URL] scheme] lowercaseString];
if([urlScheme hasPrefix:@"http"]) {
ModalWebView *siteView = [[ModalWebView alloc] initWithNibName:@"ModalWebView" bundle:nil];
+ bundle exec rake db:drop db:create db:migrate db:seed AUTO_ACCEPT=true RAILS_ENV=development --trace
/home/touch/.rvm/gems/ruby-1.9.2-p318@rails321/gems/ffaker-1.12.1/lib/ffaker.rb:2: warning: already initialized constant VERSION
** Invoke db:drop (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:drop
** Invoke db:create (first_time)
** Invoke db:load_config
using UnityEngine;
using System.Collections;
public class ReaperAI : MonoBehaviour {
int S_IDLE = 0;
int S_ROAM = 1;
int S_CHASE = 2;
int S_GIVEUP = 3;
// If player isn't pressing a button and isn't in a jump, slow down, or slide around
//if(Mathf.Abs(MacroGetAxis("Horizontal"))<0.1 && !qGrounded) {
if(Mathf.Abs(MacroGetAxis("Horizontal"))<0.1 && qGrounded) {
// Walking
var slideFactor = 1.4;
// Sprinting
if(Mathf.Abs(currentRunSpeed)>sprintSpeed) slideFactor = 1.1;
/**
* This creates random animations by changing the point on the screen the popout should be animating towards
*/
- (void) changeTarget:(ccTime)dt {
if(isDragging || !isAnimatingRandomly) return;
// Create random movements
CGPoint p = self.position;
float destX = arc4random()%1024;
float destY = arc4random()%768;
float isOnX = arc4random()%100;
+(CCRenderTexture*) createStroke: (CCLabelTTF*) label size:(float)size color:(ccColor3B)cor
{
CCRenderTexture* rt = [CCRenderTexture renderTextureWithWidth:label.texture.contentSize.width+size*2 height:label.texture.contentSize.height+size*2];
CGPoint originalPos = [label position];
ccColor3B originalColor = [label color];
BOOL originalVisibility = [label visible];
[label setColor:cor];
[label setVisible:YES];
ccBlendFunc originalBlend = [label blendFunc];
[label setBlendFunc:(ccBlendFunc) { GL_SRC_ALPHA, GL_ONE }];
package {
import flash.net.*;
import flash.events.*;
// import flash.filesystem.*;
public class ImageArtifact implements IArtifact {
public var _date:Date;
// This defines the functions i want to add to the javascript engine,
// like "alert" is commonly used in web-based js to show a popup window with text.
// So I create a js function called alert and add it to the engine's gobal object (window in browsers)
// Then I tell it to call the C function jsc_alert() when the developer uses the alert() command in a javascript file.
int JSConnectDefineGlobalFunctions(JSContext *context, JSObject *global) {
static JSFunctionSpec global_funcs[] = {
JS_FS("csystem", myjs_system, 1, 0, 0),
-(void)loginWithUser:(NSString*)username andPassword:(NSString *)password withSuccessCallbackObject:(NSObject *)obj andSelector:(SEL)_s {
callbackObject = [obj retain];
callbackSelector = _s;
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:kAppKeyzHost]];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"getuser" forKey:@"ApiAction"];
[request setPostValue:kAppToken forKey:@"AppToken"];
[request setPostValue:username forKey:@"Login"];
[request setPostValue:password forKey:@"Password"];
[request setDelegate:self];