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 / renew-ip.bat
Created January 4, 2017 13:32
[BAT] A simple BAT script to renew your ip
ipconfig /release
Ipconfig /renew
ipconfig /flushdns
ipconfig /flushdns
ipconfig /flushdns
ipconfig /flushdns
ipconfig /flushdns
@edysegura
edysegura / angularjs-interceptor.js
Last active May 12, 2023 15:37 — forked from gnomeontherun/angularjs-interceptor.js
[angularjs] How to create an AngularJS HTTP Interceptor
// Intercepting HTTP calls with AngularJS.
angular.module('MyApp', [])
.config(function ($provide, $httpProvider) {
// Intercept http calls.
$provide.factory('MyHttpInterceptor', function ($q) {
return {
// On request success
request: function (config) {
// console.log(config); // Contains the data about the request before it is sent.
@edysegura
edysegura / html5-validation-message.js
Last active April 28, 2023 06:22
How to prevent the browser from showing default HTML5 validation error message bubble?
document.addEventListener('invalid', (function(){
return function(e) {
//prevent the browser from showing default error bubble / hint
e.preventDefault();
// optionally fire off some custom validation handler
// myValidation();
};
})(), true);
@edysegura
edysegura / angularjs-class.js
Created August 4, 2017 16:20
How to create class in AngularJS
.factory('User', function (Organisation) {
/**
* Constructor, with class name
*/
function User(firstName, lastName, role, organisation) {
// Public properties, assigned to the instance ('this')
this.firstName = firstName;
this.lastName = lastName;
this.role = role;
@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
{
"onboarding": {
"$contentActions": [
{
"input": {
"bypass": false,
"$cardContent": {
"document": {
"id": "9d471950-53e9-4461-ba75-826b1193ff51",
"type": "text/plain"
@edysegura
edysegura / .zshrc
Last active August 20, 2020 20:45
[WSL and Windows Terminal] Configuration
# curl -L git.io/antigen > "$HOME/antigen.zsh"
source "$HOME/antigen.zsh"
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
antigen bundles <<EOBUNDLES
# Bundles from the default repo (robbyrussell's oh-my-zsh)
git
git-extras
z
docker
@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 / async-await.js
Last active August 6, 2019 01:45
Promises & Async/Await
const { promisify } = require('util');
const fs = require('fs');
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
function readData(filename) {
const createMessage = data => ({ filename, data });
return readFile(filename, 'utf-8').then(createMessage);
}
@edysegura
edysegura / .gitconfig
Last active July 11, 2019 14:50
[Git] Awesome git tips
git config --global alias.hist "log --pretty=format:'%C(yellow)%h%Creset %ad | %s%d %Cgreen[%an]%Creset' --graph --date=short"
git config --global core.safecrlf false