Skip to content

Instantly share code, notes, and snippets.

View GonchuB's full-sized avatar
🚀

Gonzalo Beviglia GonchuB

🚀
View GitHub Profile
@GonchuB
GonchuB / formAutofillFix.js
Created March 10, 2014 13:50
Form autofill fix without jQuery
'use strict';
angular.module('freqshoApp')
.directive('formAutofillFix', function () {
return function (scope, elem, attrs) {
// Fixes Chrome bug: https://groups.google.com/forum/#!topic/angular/6NlucSskQjY
elem.prop('method', 'POST');
function triggerChangeHandlers(element) {
element.triggerHandler('input').triggerHandler('change').triggerHandler('keydown');
@GonchuB
GonchuB / keysToLowerCase.js
Created March 19, 2014 14:57
convert json keys to lowercase recursively.
/**
* Created by gonchub on 19/03/14.
*/
function keysToLowerCase(obj) {
if (!typeof(obj) === "object" || typeof(obj) === "string" || typeof(obj) === "number" || typeof(obj) === "boolean") {
return obj;
}
var keys = Object.keys(obj);
var n = keys.length;
var lowKey;
@GonchuB
GonchuB / angularNgViewScope.js
Last active August 29, 2015 13:59
angular ng-view scope command
angular.element(document.querySelector('[ng-view]')).scope()
@GonchuB
GonchuB / azubuRemoveComponents.js
Created April 25, 2014 17:18
azubuRemoveComponents.js
(function(toRemove){toggleChat();leftMenuToggle();for(var i=0;i<toRemove.length;i++)$(toRemove[i]).remove();})(['#left_55', '#chat', '#top', '.view_bot']);
@GonchuB
GonchuB / shareMessages.js
Created June 18, 2014 17:47
Default share messages
var shareMessageFreq = 'I\'m checking out {freqName} on FreqSho. Perhaps you\'d like to get FREQ-y with them!';
var shareMessageVideo = 'I\'m checking out the video, "{videoName}" on FreqSho. Perhaps you\'d like to get FREQ-y with them!';
var shareMessagePlaylist = 'I\'m watching the playlist, "{playlistName}" on FreqSho. Feel free to get FREQ-y with it!';
if ($scope.model.shareType === shareTypes.channel) {
$scope.model.shareMessage = shareMessageFreq
.replace("{freqName}", $scope.model.displayName);
$scope.model.sharedBy = authService.getUser();
} else if ($scope.model.shareType === shareTypes.freqVideo) {
$scope.model.shareMessage = shareMessageVideo
@GonchuB
GonchuB / parseResponseSettings.js
Last active August 29, 2015 14:02
parseResponseSettings
var
_ = require('underscore'),
Utils = {
string: require('../utils/string')
},
whereToValues = {
notification: ['inApp', 'email'],
sharing: ['facebook', 'twitter']
},
categoryValues = {
@GonchuB
GonchuB / alias.sh
Created January 27, 2015 18:41
zsh alias
g=git
ga='git add'
gap='git add --patch'
gb='git branch'
gba='git branch -a'
gbr='git branch --remote'
gc='git commit -v'
'gc!'='git commit -v --amend'
gca='git commit -v -a'
'gca!'='git commit -v -a --amend'
@GonchuB
GonchuB / async.js
Created November 13, 2018 14:53
Async correction
// Original function definition with comments
async function asyncFunc() {
let data; // data variable gets declared, but it is `undefined`
// The promise returned by `axios.get` is not returned
axios.get("/some_url_endpoint")
.then((result) => {
// When this GET call gets resolved, we assign data variable to the result
data = result
});
@GonchuB
GonchuB / pay.js
Last active January 2, 2020 13:36
// Option 1: Duplicating the function
async function payWithPayPal(payload) {
setLoading(true);
await apis.paypal(payload);
trackWithAnalytics({ method: 'paypal', amount: payload.amount });
setLoading(false);
}
async function payWithCreditCard(payload) {
setLoading(true);
await apis.creditcard(payload);