Skip to content

Instantly share code, notes, and snippets.

View abstractj's full-sized avatar

Bruno Oliveira da Silva abstractj

View GitHub Profile
@emboss
emboss / pbkdf2.rb
Created October 20, 2011 04:34
Using PBKDF2 with HMAC-SHA256 for storing passwords
p ="password"
#according to PKCS#5, should be at least 8 bytes. Public information, can be stored along with the pwd.
s = OpenSSL::Random.random_bytes(16)
c = 20000 # varies depending on how fast the system is, tweak until it takes "long enough"
digest = OpenSSL::Digest::SHA256.new
#should be >= the output size of the underlying hash function, but ">" doesn't improve security (says PKCS#5)
dk_len = digest.digest_length
#store the result for new passwords
value = OpenSSL::PKCS5.pbkdf2_hmac(p, s, c, dk_len, digest)
@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active April 2, 2024 20:18
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version
@kborchers
kborchers / persistence-spec.md
Created July 10, 2012 15:34
Initial persistence API draft

Persistence API - draft 0.1

This is a initial proposal on having a very simple persistence layer

Requirements

  • Enable data to be created/saved/persisted/queryied/removed to/from the server side in a consistent manner without no matter the data format expected by the server

References

/* Need to add license, description, etc. */
// This will be broken into its own file to be reused
(function( window, undefined ) {
var aerogear = window.aerogear = {
};
})( this );
// AeroGear Pipeline
Request Headers
POST /todo-server/rest/task HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Content-Length: 124
Origin: http://localhost:8080
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1
Content-Type: application/json
Accept: */*
@danbev
danbev / gist:3305522
Created August 9, 2012 16:09
Route definitions explained

Below is how routes are defined in aerogear-controller:

Routes routes = new AbstractRoutingModule() {
    @Override
    public void configuration() {
        route()
                .from("/home")
                .on(GET)
                .to(SampleController.class).index();
 }
@matzew
matzew / gist:3405912
Created August 20, 2012 17:15
AeroGear-iOS: first API draft

Basic functionality of the aerogear-ios pipeline structure - DRAFT Version 0.1

The pipeline object (AGPipeline):

/**
 * AGPipeline represents a 'collection' of server connections (pipes) and
 * their corresponding data models. This object provides a standard way to
 * communicate with the server no matter the data format or transport expected.
 * 
  • A pipeline must have at least one pipe.

AeroGear DataManager JavaScript Specification

This is a very high level overview of the DataManager spec for the AeroGear.js library. This can also be used as inspiration for the other client libraries and is open for discussion from all points of view.

AeroGear.DataManager

Similar to AeroGear.Pipeline, this is an object used as a factory for creating new DataManager objects, which at this time are being referred to as valves in an attempt to stay with the Pipeline theme but is definitely not a name that is set in stone. A new valve is based off of adapters and planned adapters for the JS lib are memory (default), session/local storage, IndexedDB and possibly Web SQL though I believe this is no longer maintained and may be unnecessary. These objects then deal only with client side data.

Methods

this.getData = function() {
return data;
};
this.setData = function( newData ) {
data = newData;
};
this.addDataRecord = function( record ) {
data.push( record );
};
this.removeDataRecord = function( record ) {
@danbev
danbev / gist:3871798
Created October 11, 2012 11:42
RestEasy Integration

RestEasy Integration with AeroGear Controller

This document is intended to describe AeroGear Controllers integration with RestEasy.

Background

Currently, the routes that AeroGear Controller can handle are "one way" in the sense that they go through AeroGear Controller are forwarded to a view, which can be populated by a data model provided by the Controller for the route in question.
For example:

route()
      .from("/customers/{id}")
 .on(RequestMethod.GET)