Skip to content

Instantly share code, notes, and snippets.

View soberanes's full-sized avatar
🥑
Enjoying

Paul Soberanes soberanes

🥑
Enjoying
View GitHub Profile
<?php
/**
* Clase para registrar usuarios en nuestra base de datos
*/
class ManageUsers
{
public $link;
function __construct(){
$db_connection = new Database();
<?php
/**
* Clase para conectarnos a la base de datos
*/
class Database
{
protected $db_conn; //objeto de conexión
public $db_name = 'testconnection'; //nombre de la base de datos
public $db_user = 'root'; //username de mysql
public $db_pass = 'root'; //password de mysql
@soberanes
soberanes / resetadmin.sql
Created June 24, 2016 18:15
Problema con le CSS y JS del Admin de Magento después de migrar.
SET FOREIGN_KEY_CHECKS = 0;
UPDATE `core_store` SET `store_id` = '0' WHERE `store_id` = 2 LIMIT 1 ;
UPDATE `core_website` SET `website_id` = '0' WHERE `website_id` = 2 LIMIT 1 ;
UPDATE `core_store_group` SET `group_id` = '0' WHERE `group_id` = 2 LIMIT 1 ;
SET FOREIGN_KEY_CHECKS = 1;
@soberanes
soberanes / commentInput.php
Created June 23, 2016 21:45
Comentario en input del Grid en el admin de Magento
<?php
$afterElementHtml = '<p class="nm"><small>' . ' Nombre del archivo a generar.' . '</small></p>';
$linkFieldset->addField('field_name', 'text', array(
'after_element_html' => $afterElementHtml,
));
<?php
/*
A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D.
Count the minimal number of jumps that the small frog must perform to reach its target.
Write a function:
function solution($X, $Y, $D);
that, given three integers X, Y and D, returns the minimal number of jumps from position X to a position equal to or greater than Y.
For example, given:
X = 10
Y = 85
<?php
/*
A zero-indexed array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing.
Your goal is to find that missing element.
Write a function:
function solution($A);
that, given a zero-indexed array A, returns the value of the missing element.
For example, given array A such that:
A[0] = 2
A[1] = 3
<?php
/*
A non-empty zero-indexed array A consisting of N integers is given. Array A represents numbers on a tape.
Any integer P, such that 0 < P < N, splits this tape into two non-empty parts: A[0], A[1], ..., A[P − 1] and A[P], A[P + 1], ..., A[N − 1].
The difference between the two parts is the value of: |(A[0] + A[1] + ... + A[P − 1]) − (A[P] + A[P + 1] + ... + A[N − 1])|
In other words, it is the absolute difference between the sum of the first part and the sum of the second part.
For example, consider array A such that:
A[0] = 3
A[1] = 1
A[2] = 2
<?php
//Remove Paypal with localdelivery
function alter_shipping_methods($list){
$chosen_titles = array();
$available_methods = WC()->shipping->get_packages();
$chosen_rates = ( isset( WC()->session ) ) ? WC()->session->get( 'chosen_shipping_methods' ) : array();
foreach ($available_methods as $method)
foreach ($chosen_rates as $chosen) {
@soberanes
soberanes / function.php
Created March 5, 2015 23:08 — forked from hlashbrooke/function.php
Random password generator
<?php
function random_password( $length = 8 ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
$password = substr( str_shuffle( $chars ), 0, $length );
return $password;
}
$password = random_password(8);
?>
@soberanes
soberanes / index.html
Last active August 29, 2015 14:13 — forked from adilapapaya/README
Example code for exporting data in a table to a csv file.
<!DOCTYPE>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Adila Faruk">
<title>Exporting Data to a CSV File</title>