Skip to content

Instantly share code, notes, and snippets.

View oropesa's full-sized avatar
🙂
I'm chachon

Oropesa oropesa

🙂
I'm chachon
View GitHub Profile
@oropesa
oropesa / Password-hash-and-check.php
Created December 23, 2019 12:18
Reuse the WordPress PasswordHash Class in others projects
// To find the last-version of WP PasswordHash, search: wp_hash_password, wp_check_password
// File: /wp-includes/class-phpass.php
// To save hash in database (updating password)
// "UPDATE {TABLE} SET password = '" . oro_password_hash( $password_new ) . "' WHERE id = $id"
// To check password with hash
if( ! oro_password_check( $password, $database[ 'password' ] ) ) {
// PASSWORD FAILED
}
#> diskpart
DISKPART> list disk
DISKPART> select disk [number-disk]
DISKPART> clean
DISKPART> create partition primary
DISKPART> select partition 1
DISKPART> active
DISKPART> format fs=NTFS
@oropesa
oropesa / var_dumpify.php
Last active February 14, 2020 15:02
Pretify var_dump() - Parse var_dump 2 PHP variable (in html mode)
function var_dumpify( $dump, $echo = true, $cast2php = false ) {
ob_start();
var_dump( $dump );
$str_dump = ob_get_clean();
$str_dump = str_replace( "array(0) {\n", 'array(0) {', $str_dump );
$str_dump = str_replace( "=>\n", '=>', $str_dump );
$str_dump = str_replace( "]=>", '] =>', $str_dump );
$var_dump = '';
$lines = explode( "\n", $str_dump );
1. Create folder in home with the command line
|- ~> mkdir script-folder
|- ~> touch script-folder/custom-script-done
|- ~> sudo chmod 777 script-folder/custom-script-done
|- ~> nano script-folder/custom-script.sh
touch /home/{USER_FOLDER}/script-folder/custom-script-done;
** write the command line **
\- ~> sudo chmod 755 script-folder/custom-script.sh
@oropesa
oropesa / text2Barcode128B.js
Last active November 15, 2019 14:55
Simple function to cast ASCII-string-text to barcode128-text for font. That text can be used with Barcode 128 Font and it's recognized by Barcode readers.
/* BARCODE 128 FONT (with or without text):
* https://fonts.google.com/specimen/Libre+Barcode+128+Text
* https://fonts.google.com/specimen/Libre+Barcode+128
*
* EXAMPLES (with checksum < 126 or checksum > 126 ):
* - textToBarcode128B( 'Hello World!' ); // "ÌHello World!WÎ"
* - textToBarcode128B( 'Hello W4rld!' ); // "ÌHello W4rld!ÆÎ"
*
* NOTE:
* The font takes miliseconds to refresh the barcode-text without checksum char.
@oropesa
oropesa / Object with private and autoFunction properties.js
Last active November 6, 2019 12:16
Object with private property. Object with function property. Object with function property without parenthesis.
var example = ( function() {
var private = 0;
var fnIncrement = function() {
return ++private;
}
var returned = { fnIncrement: fnIncrement };
Object.defineProperty( returned, 'autoIncrement', { get: fnIncrement } );
@oropesa
oropesa / update-linux-kernel.txt
Last active October 24, 2019 08:43
Update Linux Kernel (restarting before
1. See the current version
|- #> uname –sr
2. See if there is new version
|- #> apt update
3. Update to new version
|- #> apt dist-upgrade
4.0. With Reboot
|- #> reboot now
\- Done!
@oropesa
oropesa / functions.js
Created April 22, 2019 09:11
Functions to caste the youtube duration & youtube date to a common time & date string
/**
* Examples:
* - PT1H20M5S > 01:20:05
* - PT1H5S > 01:00:05
* - PT2H10M > 02:10:00
* - PT2M10S > 00:02:10
* - PT2H > 02:00:00
* - PT2M > 00:02:00
* - PT2S > 00:00:02
*
@oropesa
oropesa / Window.js
Created April 6, 2019 18:42
Initial steps of an electron project
const { BrowserWindow } = require( 'electron' );
const defaultProps = {
width: 1024,
height: 640,
webPreferences: { nodeIntegration: true },
show: false
};
class Window extends BrowserWindow {
@oropesa
oropesa / elementIsVisibleInViewport.js
Created February 24, 2019 20:52
Returns true if the element specified is visible in the viewport, false otherwise. Use Element.getBoundingClientRect() and the window.inner(Width|Height) values to determine if a given element is visible in the viewport. Omit the second argument to determine if the element is entirely visible, or specify true to determine if it is partially visi…
kconst elementIsVisibleInViewport = (el, partiallyVisible = false) => {
const { top, left, bottom, right } = el.getBoundingClientRect();
const { innerHeight, innerWidth } = window;
return partiallyVisible
? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) &&
((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
: top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;
};