Skip to content

Instantly share code, notes, and snippets.

View edysegura's full-sized avatar
👽
Always learning!

Edy Segura edysegura

👽
Always learning!
View GitHub Profile
@edysegura
edysegura / gist:1b8d260c9f40552f1c989e6a6b5ad4e1
Created December 2, 2016 00:31 — forked from yano3/gist:1378948
git commit --amend --reset-author
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
@edysegura
edysegura / generateJSONFile.js
Created December 1, 2016 11:58
[JS] How to create file in JavaScript Rhino
function generateJSONFile(spec) {
var
json = JSON.stringify(specAttributes, null, 2),
file = new FileWriter("c:/temp/" + spec + ".json");
file.write(json);
file.close();
}
@edysegura
edysegura / strict.js
Created November 7, 2016 11:01
[JS] Why use strict mode in JavaScript
function withoutStrict() {
console.log(this)
}
function withStrict() {
"use strict";
console.log(this)
}
withoutStrict() //object window
@edysegura
edysegura / sleep.js
Last active March 23, 2017 18:33
[JS] Sleep function in JavaScript
function sleep(milliSeconds) {
let startTime = Date.now();
while(Date.now() < startTime + milliSeconds);
}
//it will hold the thread in 10 seconds
sleep(10000);
@edysegura
edysegura / .bashrc
Last active June 12, 2020 19:46
[Git] Using TortoiseGit in command line
#!/bin/bash
alias git-commit='TortoiseGitProc.exe /command:commit'
alias git-log='TortoiseGitProc.exe /command:log'
alias git-diffall='TortoiseGitProc /command:showcompare /revision1:HEAD~1 /revision2:0000000000000000000000000000000000000000'
# Personal customization
# export PS1="\u@\W $ " # username @ working dir
export PS1="\e[1;32m\u@\e[1;34m\W\e[m $ " # username @ working dir
# export PS1="\e[1;32m$\e[m " # username @ working dir
@edysegura
edysegura / functional.js
Created June 30, 2016 20:43
[JS] Functional JavaScript with filter, map and sort
var collection = [
{name:"Lidy", gender:"female"},
{name:"", gender:"unknown"},
{name:"Guto", gender:"male"},
{name:"Daniel", gender:"male"},
{name:"", gender:"unknown"},
{name:"Edy", gender:"male"},
{name:"Udit", gender:"male"},
{name:"Scott", gender:"male"},
{name:"", gender:"unknown"},
@edysegura
edysegura / sort.js
Created June 28, 2016 18:47
[JS] Using Array.prototype.sort
var numbers = [0,1,2,-2,-1];
console.log('Default: ' + numbers.sort());
function asc(a, b) {
return a-b;
}
function desc(a, b) {
@edysegura
edysegura / mockRequest.groovy
Last active June 24, 2016 17:21
[SoapUI] Tips and Tricks to use in scripts tab on SoapUI
def get = { param ->
mockRequest.httpRequest.getParameter(param)
}
def name = get "param1"
def resource = get "param2"
log.info "Parameters: ${param1} and ${param2}"
@edysegura
edysegura / array-reduce.js
Created June 9, 2016 12:53
[JS] Using reduce to calculate average
var scores = [1, 4, 6, 8];
var result = scores.reduce((total, score) => total + score) / scores.length;
console.log(result); // 4.75
@edysegura
edysegura / hasOwnProperty.js
Created May 31, 2016 03:15
[JS] Why to use hasOwnProperty?
// Poisoning Object.prototype
Object.prototype.bar = 1;
var foo = {goo: undefined};
console.log(foo.bar); // 1
console.log('bar' in foo); // true
console.log(foo.hasOwnProperty('bar')); // false
console.log(foo.hasOwnProperty('goo')); // true