Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯

Deivinson Tejeda deivinsontejeda

🎯
View GitHub Profile
@deivinsontejeda
deivinsontejeda / jwt-expiration.md
Created May 24, 2020 — forked from soulmachine/jwt-expiration.md
How to deal with JWT expiration?
View jwt-expiration.md

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@deivinsontejeda
deivinsontejeda / ladder.md
Created Mar 7, 2018 — forked from jamtur01/ladder.md
Kickstarter Engineering Ladder
@deivinsontejeda
deivinsontejeda / component.js
Created Feb 13, 2018 — forked from adamesque/component.js
Ember Component Life-cycle Docs Feedback
View component.js
import Ember from 'ember';
export default Ember.Component.extend({
/**
Overall thoughts: Ember.Component needs a section in the module doc block outlining the order of events (just like the 1.13 blog post).
Individual events can then refer back to that lifecycle chart to avoid the "runs xth during re-renders but only on thursdays" sentences.
The module doc block should also get the section on what triggers a re-render (from the 1.13 blog post).
*/
myProp: null,
View gist:7721060
---
:verbose: false
install: --no-document --env-shebang
:sources:
- https://rubygems.org
:benchmark: false
:backtrace: false
update: --no-document --env-shebang
:update_sources: true
@deivinsontejeda
deivinsontejeda / request.js
Last active Feb 7, 2016
Tiny service which use ember-simple-auth 1.0.0 and wrap any remote call.
View request.js
import Ember from 'ember';
/**
* This service wrap any remote call which needs authorization
* in order to set necessary headers to being authorized
* once the user is logged in
*
*/
const { inject } = Ember;
@deivinsontejeda
deivinsontejeda / gist:6919226
Created Oct 10, 2013
Constantize without ActiveSupport
View gist:6919226

Constatize a string without ActiveSupport (commonly come by default in rails) isn't friendly and in some case include AS is overkill. So, with this snipe you can constatize a String.

require 'net/http'
cls = "Net::HTTP".split('::').inject(Object) { |host,name| memo.const_get(name) }

# now you can use cls like normal constant
cls.new

View DSL_jruby
class TestDSL < Regexp
def initialize(&block)
instance_eval &block
super('/some_regex/')
end
def some_method(value)
puts "Output: #{value}"
end
end
View simple-linear-regression.rb
class SimpleLinearRegression
def initialize(xs, ys)
@xs, @ys = xs, ys
if @xs.length != @ys.length
raise "Unbalanced data. xs need to be same length as ys"
end
end
def y_intercept
mean(@ys) - (slope * mean(@xs))
View json_formatter.rb
require 'json'
class JsonFormatter
METHODS = %w[start close stop start_dump dump_pending dump_failures dump_summary]
METHODS.each { |m| define_method(m) { |*a| } }
def initialize(out)
@output = out
@event_id = 0
@passed = true
View rspec_optmization_2.rb
# delay the GC - usage as below
# Spec::Runner.configure do |config|
.....
# config.before(:each) do
# begin_gc_deferment
# end
# config.after(:each) do