Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Daniel V Morales DanyelMorales

🏠
Working from home
  • Cancún, Quintana Roo, México
Block or report user

Report or block DanyelMorales

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
@DanyelMorales
DanyelMorales / findElements.js
Created Dec 12, 2018
find Elements start with @
View findElements.js
Parser.prototype.findElements = function(block, filename) {
var elements = [];
// Replace Linebreak with Unicode
block = block.replace(/\n/g, '\uffff');
// Elements start with @
var elementsRegExp = /(@(\w*)\s?(.+?)(?=\uffff[\s\*]*@|$))/gm;
var matches = elementsRegExp.exec(block);
@DanyelMorales
DanyelMorales / replace.js
Created Dec 12, 2018
Replace Linebreak with Unicode
View replace.js
// Replace Linebreak with Unicode
block = block.replace(/\n/g, '\uffff');
@DanyelMorales
DanyelMorales / reverse.js
Created Dec 12, 2018
Reverse Unicode Linebreaks
View reverse.js
// Reverse Unicode Linebreaks
block = block.replace(/\uffff/g, '\n');
@DanyelMorales
DanyelMorales / sort.js
Created Dec 12, 2018
sort by group ASC, name ASC, version DESC
View sort.js
var semver = require("semver");
var blocks = [{group:"", name:"", version:""},{group:"", name:"", version:""}]
// sort by group ASC, name ASC, version DESC
blocks.sort(function(a, b) {
var nameA = a.group + a.name;
var nameB = b.group + b.name;
if (nameA === nameB) {
if (a.version === b.version)
@DanyelMorales
DanyelMorales / detectLineEnding.js
Created Dec 12, 2018
Detect and return OS specific line ending.
View detectLineEnding.js
/**
* Detect and return OS specific line ending.
*
* @returns {String}
*/
function detectLineEnding() {
if ( os.platform() === 'win32' )
return '\r\n';
if ( os.platform() === 'darwin' )
@DanyelMorales
DanyelMorales / detectLineEnding.js
Created Dec 12, 2018
Detect and return OS specific line ending.
View detectLineEnding.js
/**
* Detect and return OS specific line ending.
*
* @returns {String}
*/
function detectLineEnding() {
if ( os.platform() === 'win32' )
return '\r\n';
if ( os.platform() === 'darwin' )
@DanyelMorales
DanyelMorales / clean_spaces.js
Created Dec 12, 2018
replace spaces for line endings
View clean_spaces.js
var apiData = JSON.stringify(blocks, null, 2);
apiData = apiData.replace(/(\r\n|\n|\r)/g, app.options.lineEnding);
@DanyelMorales
DanyelMorales / fizzbuzz
Created Sep 25, 2018
fizzbuzz_elixir.exs
View fizzbuzz
------------- uggly solution
if(num es multiplo de 3){
if(num es multiplo de 5){
//FizzBuzz
} else {
// Fizz
}
}else if(multiplo de 5){
// buzz
View git-tag-delete-local-and-remote.sh
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
You can’t perform that action at this time.