Skip to content

Instantly share code, notes, and snippets.

Alejandro García Iglesias alejandroiglesias

View GitHub Profile
View WindowInstanceMap.js
import Vue from 'vue'
export default class extends Vue {
constructor() {
super({
data() {
return {
scrollY: 0
}
},
@alejandroiglesias
alejandroiglesias / flatten-array.js
Last active Sep 6, 2016
Recursively flattens arbitrarily nested arrays.
View flatten-array.js
/**
* Recursively flattens arbitrarily nested arrays.
*
* @param {Array} array The array to flatten.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
function flattenArray(array, result = []) {
if (!Array.isArray(array)) throw new TypeError('Called on non-array.');
array.forEach(item => {
View init1.js
// <div ng-controller="MyCtrl"></div>
function MyCtrl ($scope) {
// my init code here
}
View directives.js
app.factory('notification', function ($document, $templateCache, $compile) {
return {
show: function (message) {
// Compile template.
var template = $templateCache.get('template/notification.html');
console.log('tpl', $compile(template)); // This breaks
// Append notifications to DOM element.
// $document.find('#notifications').append(el);
View gist:6301571
$rootScope.$on('auction:finished', function (event, auction) {
// If current user won, show win modal.
if (auction.winner.facebookId !== $scope.user.facebookId) {
return;
}
$scope.wonAuction = auction;
// If playing for tokens, update user tokens.
if (auction.bidType !== $scope.AUCTION_TYPE_TOKENS) {
return;
}
View gist:6224591
<!-- wonAuction.bidType = 'token'; -->
<!-- AUCTION_TYPE_CREDITS = 'credit'; -->
<div class="win-popup" ng-show="wonAuction" ng-switch="wonAuction.bidType == AUCTION_TYPE_CREDITS">
<div class="title">
<img src="{% static 'images/tokens-won-title.png' %}" ng-switch-when="false">
<img src="{% static 'images/item-won-title.png' %}" ng-switch-when="true">
</div>
</div>
View tooltips-popovers.css
.tooltip {
position: absolute;
z-index: 1030;
display: block;
visibility: visible;
font-size: 11px;
line-height: 1.4;
opacity: 0;
filter: alpha(opacity=0);
}
View tooltips.css
/* Tooltips */
.has-tip {
border-bottom: dotted 1px #cccccc;
cursor: help;
font-weight: bold;
color: #333333; }
.has-tip:hover, .has-tip:focus {
border-bottom: dotted 1px #196177;
color: #2ba6cb; }
.has-tip.tip-left, .has-tip.tip-right {
View gist:6168183
angular
.module('api', ['$http'])
.constant('API_URL', '/api/')
.factory('getInitializationData', function () {
//since $http.get returns a promise,
//and promise.then() also returns a promise
//that resolves to whatever value is returned in it's
//callback argument, we can return that.
return $http
.get(API_URL + 'action/initalize')
View js_error_tracker.py
from random import shuffle
debuggify = '''
<script type="text/javaScript" src="https://cdn.debuggify.net/js/a4f458fc1c74cf2b60f0909da8531164/debuggify.logger.http.js"></script>
'''
qbaka = '''
<script type="text/javascript">
(function(a,c){a.__qbaka_eh=a.onerror;a.__qbaka_reports=[];a.onerror=function(){a.__qbaka_reports.push(arguments);if(a.__qbaka_eh)try{a.__qbaka_eh.apply(a,arguments)}catch(b){}};a.onerror.qbaka=1;a.qbaka={report:function(){a.__qbaka_reports.push([arguments, new Error()]);},customParams:{},set:function(a,b){qbaka.customParams[a]=b},exec:function(a){try{a()}catch(b){qbaka.reportException(b)}},reportException:function(){}};var b=c.createElement("script"),e=c.getElementsByTagName("script")[0],d=function(){e.parentNode.insertBefore(b,e)};b.type="text/javascript";b.async=!0;b.src="//cdn.qbaka.net/reporting.js";"[object Opera]"==a.opera?c.addEventListener("DOMContentLoaded",d):d();qbaka.key="a72f5cc63c961ae53e177e4ca071beb5"})(window,document);qbaka.options={autoStacktrace:1,trackEvents:1};
</
You can’t perform that action at this time.