Skip to content

Instantly share code, notes, and snippets.

View molekilla's full-sized avatar

Rogelio Morrell molekilla

  • Panama
View GitHub Profile
@molekilla
molekilla / gist:1fd988d89086f6b64944
Created August 21, 2014 14:25
hapi-authenticated-route
var debug = require('debug')('users');
var createHandler = require('./v1/create.js');
exports.register = function(plugin, options, next) {
plugin.route({
method: 'POST',
path: '/v1/users',
handler: createHandler,
config: {
@molekilla
molekilla / gist:0feda8cecd14e6f20830
Created August 21, 2014 14:26
hapi-server-config
server.pack.register(require('hapi-auth-bearer-token'), function(err) {
server.auth.strategy('token', 'bearer-access-token', {
validateFunc: function(token, callback) {
// read from db or some place
var matched = false;
var tokenResult = { token: token };
var err = null;
if (token === 'a1b2c3') {
@molekilla
molekilla / rutha-render-partial.js
Created August 28, 2014 00:25
rutha-render-partial.js
exports.profile = function(request, reply) {
request.server.render('partials/navbar', {}, function(err, rendered, config) {
reply.view('profile', {
title: 'Test',
navbar: rendered
});
});
};
@molekilla
molekilla / rutha-server-options.js
Created August 28, 2014 00:27
rutha-server-options.js
module.exports = {
views: {
engines: {
'html': {
compile: require('./underscore_compiler')
}
},
compileMode: 'sync',
path: './views',
partialsPath: './views/partials'
@molekilla
molekilla / gist:90c0ac36b1f0d56569fc
Created September 9, 2014 21:51
ng-messages.js
<!-- parcialmente basado en yearofmoo.com -->
<form name="formulario">
<div class="field">
<label for="correo">Correo Electronico:</label>
<input type="email"
name="correo"
ng-model="datos.email"
required />
<div ng-messages="formulario.correo.$error">
<div ng-message="required">Campo requerido</div>
@molekilla
molekilla / gist:979960da22d49c6c8446
Last active August 29, 2015 14:06
required only after ng blur and ng change
<!-- parcialmente basado en yearofmoo.com -->
<form name="formulario">
<div class="field">
<label for="correo">Correo Electronico:</label>
<input type="email"
name="correo" ng-change="MiCtrl.checkRequired(datos.email)" ng-blur="MiCtrl.checkRequired(datos.email)"
ng-model="datos.email"
/>
<div ng-messages="formulario.correo.$error">
<div ng-message="required">Campo requerido</div>
context: 'td',
props: {
tipo: function ($scope) {
// either return or assign to this.model
return $scope.eq(0).text();
},
fecha: function ($scope) {
return $scope.eq(1).text();
}
const bot$ = Rx.Observable.from(request(postReq));
bot$.mergeMap((body) => {
const byCedulaResp = menio.parse(body, 'subscribers');
const req = Object.assign({}, postReq, {
form: {
selectsuscriptor: byCedulaResp.subs[0],
}
});
return Rx.Observable.from(request(req));
})
@molekilla
molekilla / jwt java signing
Created June 27, 2017 14:00
jwt java signing
private String createBearerToken() throws Exception {
byte[] decoded = ("-----BEGIN RSA PRIVATE KEY-----\n" +
"-----END RSA PRIVATE KEY-----\n").getBytes();
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
PEMParser pemParser = new PEMParser(new BufferedReader(new InputStreamReader(new ByteArrayInputStream(decoded))));
JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider("BC");
Object object = pemParser.readObject();
KeyPair kp = converter.getKeyPair((PEMKeyPair) object);
java.security.interfaces.RSAPrivateKey generatedPvk = (java.security.interfaces.RSAPrivateKey)kp.getPrivate();
@molekilla
molekilla / encrypt.ps1
Created January 26, 2018 22:05
Write secure string with powershell
# Write secure string as file
Write-Output "Ingrese contraseña: "
$Secure = Read-Host -AsSecureString
$Encrypted = ConvertFrom-SecureString -SecureString $Secure -Key (1..16)
$Encrypted | Set-Content httpbin_creds.txt
$Secure2 = Get-Content httpbin_creds.txt | ConvertTo-SecureString -Key (1..16)
$Secure2
Write-Output "Archivo encriptado como httpbin_creds.txt exitosamente"