Skip to content

Instantly share code, notes, and snippets.

View jlogsdon's full-sized avatar

James Logsdon jlogsdon

View GitHub Profile
@jlogsdon
jlogsdon / adapters.application.js
Last active February 8, 2017 20:19 — forked from pangratz/adapters.application.js
pretender base
import Adapter from "ember-data/adapters/json-api";
export default Adapter.extend();
local gui=require 'gui'
local widgets=require 'gui.widgets'
tutorial_screen=defclass(tutorial_screen,gui.FramedScreen)
function tutorial_screen:init(args)
self:addviews{
widgets.Label{text="Info:",frame={t=1,l=1}},
widgets.Label{text="Other text: Text Text text",frame={t=2,l=2}},
@jlogsdon
jlogsdon / user.rb
Created June 21, 2012 18:10 — forked from andrewwho/userimages.rake
hurray
class User < ActiveRecord::Base
def fetch_facebook_image
return false if authentications.blank?
auth = authentications.find_by_provider('facebook')
self.remote_image_url = "https://graph.facebook.com/"+auth.uid+"/picture?type=large"
self.save
end
end
@jlogsdon
jlogsdon / solution.rb
Created May 1, 2012 20:35 — forked from isa/gist:2571012
Convert in less than 30 lines
Question: Convert following into the latter data structure in less than 30 lines:
List:
A, B, C
A, C, E
E, F, D
D, A, J
E, D, J
List
user.profile.detail = {:education=> {:degree=>[], :specialization=>[], :institution=>[]}}
=begin
Now I am trying to store it in arrays inside hashes while migrating but when I view it it will be #difficult to show the contents in order since these 3 different values are being stored in 3 different #array inside hash.
Considering there could be multiple rows for a single user, I wanna store it in the ascending order of dates ie first course should be entered first although I dont want to migrate start and end date.
How can I have a better structure of storing the values
I want to migrate data into this hash structure for the give table structure.
ID DEGREE SPECIFICATION INSTITUTION START_DATE END_DATE
<?php
class Sg_Session_SaveHandler_Cache implements Zend_Session_SaveHandler_Interface {
protected $_cache;
/**
* Session lifetime
*
* @var int
*/
protected $_lifetime = false;
/**