Skip to content

Instantly share code, notes, and snippets.

Manuel Rueda manrueda

Block or report user

Report or block manrueda

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@manrueda
manrueda / index.ts
Created Mar 29, 2019
typedoc-plugin-external-module-name issue
View index.ts
/**
* @module @cool/package
*/
import * as _sub from './sub'
export const sub: typeof _sub = _sub;
@manrueda
manrueda / clean-up.sh
Created Aug 28, 2017
Remove cache instances of GitLab CI Runner
View clean-up.sh
docker ps -a | grep cache | awk '{print $2}'
@manrueda
manrueda / code-generator.js
Created Jun 6, 2017
Generate code from swagger source
View code-generator.js
const swaggerExtractor = /https?:\/\/(.*)\/.*\/#!\/(.*)\/(.*)/i
function getUrlsParts (url) {
const [, domain, entity, method] = url.match(swaggerExtractor)
return { domain, entity, method }
}
async function getModels(url) {
const { domain, entity, method } = getUrlsParts(url)
const req = await fetch(`https://${domain}/api/core/swagger/api-docs/${entity}`)
const jsonResponse = await req.json()
@manrueda
manrueda / Dockerfile
Last active Jun 6, 2017
Node.js v8.0.0 - ARMv7l
View Dockerfile
# Node.js v8.0.0 - ARMv7l
FROM arm32v7/buildpack-deps:jessie
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
# gpg keys listed at https://github.com/nodejs/node#release-team
RUN set -ex \
&& for key in \
9554F04D7259F04124DE6B476D5A82AC7E37093B \
@manrueda
manrueda / http-file-explorer.js
Created May 23, 2017
CRUD over a folder over HTTP
View http-file-explorer.js
const formidable = require('formidable')
const fs = require('fs-extra')
const path = require('path')
module.exports = ({path: _path}) => {
fs.ensureDirSync(_path)
return async (req, res) => {
const method = req.method.toLowerCase()
switch (method) {
case 'get':
@manrueda
manrueda / converter.js
Last active Aug 24, 2016
Convert a JSON string to a an string with JS code representing that object
View converter.js
(JSONString => {
let objectString = JSONString;
JSONString.match(/"(.*?)":\n*(.*)/gi).forEach(line => {
var parts = line.match(/"(.*?)":\n*(.*)/);
if (parts[2].match(/^"(.*)",?$/)){
let hasComma = !!parts[2].match(/^"(.*)",{1}$/)
parts[2] = '\'' + parts[2].match(/^"(.*)",?$/)[1] + '\'' + (hasComma ? ',': '');
}
objectString = objectString.replace(parts[0], parts[1] + ': ' + parts[2])
})
@manrueda
manrueda / grid.html
Last active Jun 27, 2016
WjFlexGridCellTemplate with angular templates, width error
View grid.html
<div>
<wj-flex-grid items-source="data" style="height: 150px;margin-top:10px" control="flex" initialized="initialized(s,e)">
<wj-flex-grid-column header="Country" binding="country" width="*" allow-resizing="false">
<wj-flex-grid-cell-template cell-type="Cell">
<!--<h1>{{$item.country}}</h1>-->
<div ng-include="'tpl.html'"></div>
</wj-flex-grid-cell-template>
</wj-flex-grid-column>
<wj-flex-grid-column header="Sales" binding="sales" width="*" allow-resizing="false"></wj-flex-grid-column>
<wj-flex-grid-column header="Expenses" binding="expenses" width="*" allow-resizing="false"></wj-flex-grid-column>
@manrueda
manrueda / interceptor.js
Created Apr 14, 2016
Intercept angular.module function before his creation
View interceptor.js
window.angular = {};
window.angular.modules = {};
var originalModuleFunc;
var customFunction = function(){
if (arguments.length > 1) {
angular.modules[arguments[0]] = originalModuleFunc.apply(null, arguments);
return angular.modules[arguments[0]];
}else{
return originalModuleFunc.apply(null, arguments);
@manrueda
manrueda / mouse.js
Created Dec 6, 2015 — forked from bfncs/mouse.js
Read Linux mouse(s) in node.js
View mouse.js
/**
* Read Linux mouse(s) in node.js
* Author: Marc Loehe (marcloehe@gmail.com)
*
* Adapted from Tim Caswell's nice solution to read a linux joystick
* http://nodebits.org/linux-joystick
* https://github.com/nodebits/linux-joystick
*/
var fs = require('fs'),
@manrueda
manrueda / example.js
Last active Oct 10, 2015
New line parse in environment variables
View example.js
// set the TEST environment variable with TEST=first line\\n\\nsecond line\\n
// you need to duplicate the \ to scape it
function parseEnvVarible(envVar){
return new Buffer(envVar.split('\\n').join(require('os').EOL), 'UTF-8').toString('UTF-8');
}
console.log('Wrong: ' + process.env.TEST);
console.log('Right: ' + parseEnvVarible(process.env.TEST));
You can’t perform that action at this time.