Skip to content

Instantly share code, notes, and snippets.

@rippo
rippo / account.login.page.js
Last active October 19, 2017 09:32
Page object pattern using chromeless
var AccountLoginPage = function (chromeless, options) {
this.chromeless = chromeless
this.options = options
this.usernameLocator = 'input[id="Username"]'
this.passwordLocator = 'input[id="Password"]'
this.submitButtonLocator = 'form input[type="submit"]'
this.inputWithValidationErrorLocator = 'input.input-validation-error'
this.usernameRequiredValidationLocator = '.field-validation-error[data-valmsg-for="Username"]'
@dinhkhanh
dinhkhanh / change-dropdown-attribute-to-multiselect.sql
Last active April 17, 2020 09:23
Magento change dropdown attribute to multiselect
-- First, update the attribute input type to multiselect
UPDATE eav_attribute SET
entity_type_id = 4,
attribute_model = NULL,
backend_model = 'eav/entity_attribute_backend_array',
backend_type = 'varchar',
backend_table = NULL,
frontend_model = NULL,
frontend_input = 'multiselect',
frontend_class = NULL
SELECT c.*, p1.*
FROM customer c
JOIN purchase p1 ON (c.id = p1.customer_id)
LEFT OUTER JOIN purchase p2 ON (c.id = p2.customer_id AND
(p1.date < p2.date OR p1.date = p2.date AND p1.id < p2.id))
WHERE p2.id IS NULL;
@marinsagovac
marinsagovac / Mailhog + Symfony 3
Last active March 29, 2021 19:37
Mailhog + Symfony 3
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send@example.com')
->setTo('recipient@example.com')
->setBody('You should see me from the profiler!')
;
$this->get('mailer')->send($message);
@hlashbrooke
hlashbrooke / function.php
Created July 12, 2013 11:18
Simple way to generate a random string/password in PHP
<?php
function random_password( $length = 8 ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
$password = substr( str_shuffle( $chars ), 0, $length );
return $password;
}
?>
@samelhusseini
samelhusseini / microbit-spotify.js
Last active March 29, 2022 01:27
A node script for listening to micro:bit serial messages and controlling spotify on a Mac
var SerialPort = require("serialport");
const Readline = SerialPort.parsers.Readline;
var spotify = require('spotify-node-applescript');
var port = new SerialPort('/dev/tty.usbmodem1422', {
baudRate: 115200,
autoOpen: false
})
const parser = new Readline();
port.pipe(parser);
@mbmccormick
mbmccormick / gist:628268
Created October 15, 2010 14:33
Query Google Maps GeoCode API with zip code and return city and state.
<?php
$zipcode = $_GET[zipcode];
$url = "http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=" . $zipcode;
$geocode = simplexml_load_file($url);
$city = $geocode->result->address_component[1]->long_name;
for ($i = 2; $i < 6; $i++)
{
if ($geocode->result->address_component[$i]->type == "administrative_area_level_1")
{
@arthurattwell
arthurattwell / dialog.html
Last active August 1, 2022 09:54
Google Sheets script to allow multi-select in cells with data-validation (adapted from https://www.youtube.com/watch?v=dm4z9l26O0I)
<div style="font-family: sans-serif;">
<? var data = valid(); ?>
<form id="form" name="form">
<? if(Object.prototype.toString.call(data) === '[object Array]') { ?>
<? for (var i = 0; i < data.length; i++) { ?>
<? for (var j = 0; j < data[i].length; j++) { ?>
<input type="checkbox" id="ch<?= '' + i + j ?>" name="ch<?= '' + i + j ?>" value="<?= data[i][j] ?>"><?= data[i][j] ?><br>
<? } ?>
<? } ?>
<? } else { ?>
@chrisdiana
chrisdiana / gist:8d7985e9b06dfbb792a8
Last active October 4, 2022 22:08
Detect field change in ExtJS
var panel = new Ext.form.FormPanel({
title: 'Example',
width: 350,
items: [],
listeners: {
add: function(me, component, index) {
component.on('change', function(f,n,o) {
alert('detected! '+f.label+' value changed from '+o+' to '+n);
console.log(component.startValue);
});
@matheusgontijo
matheusgontijo / magento-2-debugging-tricks-mysql-query-fetchall-fetchrow-data-hydrate-and-xdebug.php
Created June 10, 2019 01:00
Magento 2 Debugging Tricks - MySQL Query, fetchAll, fetchRow, Data Hydrate & PHP xDebug by Matheus Gontijo
Magento 2 Debugging Tricks - MySQL Query, fetchAll, fetchRow, Data Hydrate & PHP xDebug by Matheus Gontijo
Video: https://www.youtube.com/watch?v=xLf3OwpAFhQ
-----------------------------------------------
1) Track MySQL queries
vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php::query
vendor/magento/zendframework1/library/Zend/Db/Select.php