Skip to content

Instantly share code, notes, and snippets.

View Rho-bur's full-sized avatar
💭
I may be slow to respond.

Robertino Vasilescu Rho-bur

💭
I may be slow to respond.
View GitHub Profile
@Taluu
Taluu / MockEntityManager.php
Last active February 18, 2023 16:59
Mock some services for PHPUnit
<?php
namespace Traits\Tests;
/**
* Mocks the entity manager
*
* Provides everything in the memory, so the tests does not depend on doctrine,
* which does a lot of stuff (maybe too much). This also allows to avoid to
* need and modify the data in the database, even if those are for the tests.
@chrisjhoughton
chrisjhoughton / wait-el.js
Last active October 6, 2023 09:46
Wait for an element to exist on the page with jQuery
var waitForEl = function(selector, callback) {
if (jQuery(selector).length) {
callback();
} else {
setTimeout(function() {
waitForEl(selector, callback);
}, 100);
}
};
@tkh44
tkh44 / FileController.js
Last active March 10, 2020 09:04
Simple file upload for sails.js
module.exports = {
get: function (req, res) {
res.sendfile(req.path.substr(1));
},
_config: {
rest: false,
shortcuts: false
}
};
@varmais
varmais / thinced.js
Created October 1, 2015 19:43
Geolocation to Promise wrap example
var getPosition = function (options) {
return new Promise(function (resolve, reject) {
navigator.geolocation.getCurrentPosition(resolve, reject, options);
});
}
getPosition()
.then((position) => {
console.log(position);
})
@julienbourdeau
julienbourdeau / prestashop.conf
Created May 4, 2016 14:23
PrestaShop Nginx Configuration
server {
listen 80;
listen [::]:80; #Use this to enable IPv6
server_name www.example.com;
root /var/www/prestashop17;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
index index.php index.html;
@rhwilr
rhwilr / Awesome-PHP-Development-Environment-on-Arch.md
Last active February 17, 2022 22:34
This is my awesome php development environment

Introduction

The following steps are required for a typical web developer stack for php and some front-end development. This is for a developer machine and not for a live environment!

Installation stack

@ljharb
ljharb / array_iteration_thoughts.md
Last active May 22, 2024 09:22
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu

@craigvantonder
craigvantonder / logstash-mysql-elasticsearch-service.md
Last active September 1, 2020 12:28
Logstash (MySQL -> AWS Elasticsearch Service) Integration in Ubuntu 16.04
@mikermcneil
mikermcneil / datepicker.component.js
Created August 20, 2018 21:23
A datepicker component for Vue/parasails, assuming you're using the "Web App" template (aka parasails). _Note: this code was pasted here as of Mon Aug 20, 2018 -- note that this may have been updated or changed in the mean time._
// This goes in `assets/js/components/datepicker.component.js`
// ^^Remove this comment
/**
* <datepicker>
* -----------------------------------------------------------------------------
* A wrapper for the jQuery UI datepicker, which falls back to a date input on mobile.
*
* @type {Component}
*
* @event input [emitted when the value is changed privately]
@mikermcneil
mikermcneil / stripe-card-element.component.js
Created February 9, 2019 15:37
An example of a component for using Stripe Elements with parasails / Vue.js (`<stripe-card-element>`)
/**
* <stripe-card-element>
* -----------------------------------------------------------------------------
* A wrapper for the Stripe Elements "card" component (https://stripe.com/elements)
*
* Example usage:
* ```
* <stripe-card-element stripePublishableKey="…" v-model="formData.cardInfo"></stripe-card-element>
* ```
*