Skip to content

Instantly share code, notes, and snippets.

View jairove's full-sized avatar

Jairo Velasco jairove

View GitHub Profile
let chai = require('chai').use(require('chai-as-promised'));
let expect = chai.expect;
import { binding, given, when, then } from 'cucumber-tsflow';
import { CallbackStepDefinition } from 'cucumber';
import { LoginPageObject } from './login.page';
@binding()
class LoginSteps {
private loginPageObject = new LoginPageObject();
import { element, by, protractor, ElementArrayFinder } from 'protractor';
import { promise as wdpromise } from 'selenium-webdriver';
export class LoginPageObject {
private form;
private passwordInput;
private emailInput;
private submitButton;
private title;
Feature: Login
Scenario Outline: The user is using the login form
Given user clicks the login link
Given '<email>' is the user email in the login form
Given '<password>' is the user password in the login form
When submitting the login form
Then the login form is validated '<valid>'
@jairove
jairove / AJAX_with_visual_feedback.js
Last active November 27, 2020 08:29
AJAX with visual feedback
$.ajax({
beforeSend: function (qXHR, settings) {
$('#loading').fadeIn();
},
complete: function () {
$('#loading').fadeOut();
},
type : "post",
url : wp_ajax_tets_vars.ajax_url,
data : {
@jairove
jairove / ajax_hook.php
Last active November 27, 2020 08:29
PHP Ajax hook
<?php
// Hook para usuarios no logueados
add_action('wp_ajax_nopriv_notify_button_click', 'notify_button_click');
// Hook para usuarios logueados
add_action('wp_ajax_notify_button_click', 'notify_button_click');
// Función que procesa la llamada AJAX
function notify_button_click(){
// Check parameters
@jairove
jairove / enqueue.php
Last active November 27, 2020 08:29
Enqueue script in WP
<?php
add_action( 'wp_enqueue_scripts', 'ajax_test_enqueue_scripts' );
function ajax_test_enqueue_scripts() {
wp_enqueue_script( 'test', plugins_url( ‘/ajax-test.js', __FILE__ ), array('jquery'), '1.0', true );
}
?>
@jairove
jairove / ajax.js
Last active November 27, 2020 08:29
AJAX Example
jQuery(document).ready( function(){
$(‘#my-button’).on('click', function(){
//La llamada AJAX
$.ajax({
type : "post",
url : 'your-admin-ajax.php', // Pon aquí tu URL
data : {
action: "notify_button_click",
message : "Button has been clicked!"
while i<CHARACTERS_LEN*CHARACTERS_LEN:
generated_name = next(generated_name)
username = ''.join(generated_name)
url = 'http://twitter.com/jairo'+username
r = requests.get(url)
if r.status_code == 404:
print('AVAILABLE USERNAME:\t jairo'+ username)
import string
import requests
CHARACTERS = string.ascii_lowercase+'_'
CHARACTERS_LEN = len(CHARACTERS)
def indexToCharacter(index):
if CHARACTERS_LEN <= index:
raise ValueError("Index out of range.")
else:
def next(string):
if len(string) <= 0:
string.append(indexToCharacter(0))
else:
string[0] = indexToCharacter((characterToIndex(string[0]) + 1) % CHARACTERS_LEN)
if CHARACTERS.index(string[0]) is 0:
return list(string[0]) + next(string[1:])
return string