Skip to content

Instantly share code, notes, and snippets.

View tensiondriven's full-sized avatar

Jonathan Yankovich tensiondriven

View GitHub Profile
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_omniauth_authorize /users/auth/:provider(.:format) devise/omniauth_callbacks#passthru {:provider=>/(?!)/}
user_omniauth_callback /users/auth/:action/callback(.:format) devise/omniauth_callbacks#(?-mix:(?!))
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks"}
devise_scope :user do
get '/users/auth/facebook' => 'users/omniauth_callbacks#facebook'
end
traceroute: Warning: google.com has multiple addresses; using 173.194.38.137
traceroute to google.com (173.194.38.137), 64 hops max, 52 byte packets
1 192.168.1.1 (192.168.1.1) 949.937 ms 8.384 ms 4.646 ms
2 180.254.224.1 (180.254.224.1) 912.359 ms 599.573 ms 510.168 ms
3 180.252.3.157 (180.252.3.157) 720.499 ms 1182.759 ms *
4 45.subnet118-98-57.astinet.telkom.net.id (118.98.57.45) 1714.358 ms 934.298 ms 937.011 ms
5 113.subnet118-98-62.astinet.telkom.net.id (118.98.62.113) 1177.779 ms 2028.159 ms 643.433 ms
6 ppp-spl-a.telkom.net.id (61.5.48.17) 2041.459 ms 691.536 ms 1030.260 ms
7 98.191.240.180.telin.sg (180.240.191.98) 933.084 ms 505.898 ms 1324.144 ms
8 74.subnet118-98-61.astinet.telkom.net.id (118.98.61.74) 1589.766 ms
Jonathan Yankovich
3:34 alright… here's my idea for this data layer
3:35 actually it was matts idea, heres my implementation:
3:35 New model with: Task, User, Timestamp, Sample Size, and Sample Value (duration)
3:35 So, a typical record might be User 1, Task 1, 1:00pm, 1 hour, 20 minutes
3:36 meaning between 1:00 − 2:00 pm, user 1 spent 20 minutes on task 1
3:36 These would be generated for a given slice of time, and for a given resolution
3:36 Ex, one report for totals for the whole day might have a sample size of one day (24 hours) with total time for that task in that one record
3:37 but if the user requests a more granular report, the systme would generate a series of records with 1 hour time slices, ie 24 records, 1 hour per record, where each record shows how much time was spent on that task in that time period
3:37 many records may be generated with 0 minutes as their actual duration
last_week = <<EOT
-- chart_total_time_by_day
SELECT SUM ( EXTRACT( EPOCH FROM entries.end) - EXTRACT( EPOCH FROM entries.start) ) / 60 / 60 AS ct,
sub_dates.val AS d
FROM
(select '#{start_date.strftime('%Y-%m-%d')}'::date + generate_series(0, abs('#{start_date.strftime('%Y-%m-%d')}'::date - '#{end_date.strftime('%Y-%m-%d')}'::date)) AS val) AS sub_dates
LEFT OUTER JOIN
(select * FROM entries WHERE user_id = #{userid} #{where_task_id_clause}) AS entries
ON
date_trunc('day', entries.created_at) = sub_dates.val
Loading production environment (Rails 3.2.3)
irb(main):001:0> u = User.new
=> #<User id: nil, email: "", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, authentication_token: nil, created_at: nil, updated_at: nil, short_name: nil, invited_by_id: nil, name: nil, group_id: nil, first_time_email: true, first_time_web: true, first_time_password: nil, terms: nil, pref_send_me_email_updates: true, pref_send_me_my_email_updates: false>
irb(main):002:0> u.terms
=> nil
i
@tensiondriven
tensiondriven / gist:2945452
Created June 17, 2012 18:56
Objectiveli simple frame rules
def frametest
Log.log ''
Log.log ''
Log.log ''
Log.log ''
Log.log 'xx start'
frames, counts = get_flat_goals_array
@width = 640
@height = 480
@tensiondriven
tensiondriven / gist:2933858
Created June 15, 2012 00:30
Email id token encode/decode method
def self.get_guid record_id
str = record_id.to_s(36)
hash = (Digest::SHA1.hexdigest "SALTY#{record_id}HASH")[0..3].downcase
"[#{hash}#{str}]"
end
def self.get_id_for_guid guid
old_hash = guid[0..3]
record_id = guid[4..-1].to_i(36)
hash = (Digest::SHA1.hexdigest "SALTY#{record_id}HASH")[0..3].downcase
2012-05-24 20:52:44.579 Last5[26748:15b03] ----------[>] LoginController init
2012-05-24 20:52:44.592 Last5[26748:15b03] -----[>] LoginController viewDidLoad
2012-05-24 20:52:52.571 Last5[26748:15b03] startAsynchronousRequest started: https://secure.last5.co/tasks.json
2012-05-24 20:52:53.886 Last5[26748:15b03] startAsynchronousRequest complete [200]: [{"task":{"active":true,"color_id":null,"created_at":"2011-09-22T20:21:15Z","external_id":null,"id":23,"integration_id":null,"metadata":null,"name":"Break","position":1,"project_id":null,"task_type_id":null,"updated_at":"2012-05-17T16:34:25Z","user_id":1,"last_entry_timestamp":null}},{"task":{"active":true,"color_id":null,"created_at":"2011-09-22T02:25:09Z","external_id":null,"id":19,"integration_id":null,"metadata":null,"name":"Last5","position":2,"project_id":null,"task_type_id":3,"updated_at":"2012-05-17T16:34:25Z","user_id":1,"last_entry_timestamp":null}},{"task":{"active":true,"color_id":null,"created_at":"2011-09-23T03:20:28Z","external_id":null,"id":25,"i
@tensiondriven
tensiondriven / gist:1528698
Created December 28, 2011 17:05
Get list of all zones where it is midnight
zones_where_it_is_midnight = []
ActiveSupport::TimeZone.zones_map.each{ |zone|
if (Time.now.in_time_zone(zone[1]).strftime('%k').to_i == 0)
zones_where_it_is_midnight << zone[0]
end
}
puts zones_where_it_is_midnight.inspect