Skip to content

Instantly share code, notes, and snippets.

View coreyjs's full-sized avatar

Corey Schaf coreyjs

View GitHub Profile
@coreyjs
coreyjs / gist:8034115
Created December 19, 2013 03:46
deserialize mutli params
# deserialze tag params, idea is to check for tag save/change, always update to newest params
# find all tags associated with beacon, transform to array and return to the controller
def self.deserialize_tag_parameters(params)
if !params[:beacon][:tags].nil?
if !params[:beacon][:tags].empty?
code_array = params[:beacon][:tags].split(',')
logger.debug "Tag params parsed out" + code_array.to_s
tags = Tag.where(:code.in => code_array)
end
end
@coreyjs
coreyjs / gist:8034124
Created December 19, 2013 03:47
c# string collection methods, early work
public static class StringExtensions
{
public static string Truncate(this string value, int maxLength) {
if (!string.IsNullOrEmpty(value) && value.Length > maxLength) {
return value.Substring(0, maxLength);
}
return value;
}
@coreyjs
coreyjs / gist:8034146
Created December 19, 2013 03:50
color theme switcher for spendify
//
// DataModel.h
// ShoppingHelper
//
// Created by Corey Schaf on 1/2/13.
// Copyright (c) 2013 blaQk SHeep. All rights reserved.
//
#import <Foundation/Foundation.h>
@coreyjs
coreyjs / simplegamecenter.cs
Last active October 24, 2022 02:12
Unity3d Simple GameCenter Integration
using UnityEngine;
using System.Collections;
using UnityEngine.SocialPlatforms;
using UnityEngine.SocialPlatforms.GameCenter;
public class GameCenter : MonoBehaviour {
static ILeaderboard m_Leaderboard;
public int highScoreInt = 1000;
@coreyjs
coreyjs / flash_messages
Created October 21, 2014 16:31
Display Rails Flash Messages
<% flash.each do |name, msg| %>
<% if msg.class == Array %>
<% msg.each do |message| %>
<%= content_tag :div, message, :id => "flash_#{name}" %>
<% end %>
<% else %>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
<% end %>
<% end %>
@coreyjs
coreyjs / Pulsar.cs
Last active August 29, 2015 14:14
Pulsar Unity Plugin
using UnityEngine;
using System.Collections;
using System.ComponentModel;
using System.Net;
using System.IO;
using System.Text;
namespace PulsarApp{
public class Pulsar : Singleton<Pulsar> {
@coreyjs
coreyjs / gist:61689f88918c394a019b
Created January 24, 2015 00:29
Init Pulsar Unity Plugin
PulsarManager = new Pulsar();
PulsarManager.Initialize("API_KEY", "APP_KEY");
string testData = @"{
""app"": ""my game"",
""version"" : ""0.0.1"",
""game"" : {
""level"" : ""1""}} ";
StartCoroutine(PulsarManager.AddEventMessage("1", testData));
select order_Id from [order] o where(
o.order_id in (
select osh.order_id
from order_status_history osh
join order_status os on os.status_id = osh.status_id
inner join (
select order_id, MAX(effective_date) as updated
from order_status_history
group by order_id) as status on osh.order_id = status.order_id and osh.effective_date = status.updated
@coreyjs
coreyjs / api_spec.rb
Created January 31, 2018 16:53
Rails API Spec Example
module ApiHelper
include Rack::Test::Methods
def app
Rails.application
end
end
RSpec.configure do |config|
config.include ApiHelper, api: true
@coreyjs
coreyjs / ch-01-app.rb
Last active October 2, 2018 15:47
ch-01-app.rb
class CreateApps < ActiveRecord::Migration[5.2]
def change
create_table :apps do |t|
# Name of our app, used for visual readability.
t.string :name, unique: true
# Internal identifier of our app, for communication from the open api endpoint
t.string :token, unique: true
# Switch to determine if this app is currently accepting data.