Skip to content

Instantly share code, notes, and snippets.

@batazo
batazo / .gitlab-ci.yml
Created January 24, 2024 00:33 — forked from transitive-bullshit/.gitlab-ci.yml
GitLab CI Detox React Native Example
stages:
- E2E
.ios_base:
tags:
- macOS
- swiftlint
cache:
paths:
- node_modules
@batazo
batazo / monitoring_binary_logs.js
Created May 17, 2022 16:39 — forked from Rowadz/monitoring_binary_logs.js
Monitoring binary logs via Nodejs
const mysql = require('mysql');
const MySQLEvents = require('@rodrigogs/mysql-events');
const ora = require('ora'); // cool spinner
const spinner = ora({
text: '🛸 Waiting for database events... 🛸',
color: 'blue',
spinner: 'dots2'
});
const program = async () => {
// TodoPage.js
export const TodoContext = createContext({});
class TodoPage extends React.Component {
state = {
todos: [
{ id: 1, desc: 'Check email', completed: false },
{ id: 2, desc: 'Write blog post', completed: false },
],
user: { name: 'John', canDelete: true },
@batazo
batazo / cas.js
Created June 4, 2021 04:28 — forked from torjusti/cas.js
Simple equation solving hack in JavaScript
// Prototype that stores information about a given polynomial.
function Polynomial(data) {
// Support providing already existing Polynomials.
this.polynomial = data instanceof Polynomial ? data.polynomial : data;
}
// Rank all coefficients in the polynomial and return the largest.
Polynomial.prototype.getLargestCoefficient = function() {
var re = /(\d+)/g, match, max = 0;
while(match = re.exec(this.getPolynomial()))
@batazo
batazo / README.md
Created February 20, 2021 18:06 — forked from jonathantneal/README.md
createElement.js // a 300 byte DOM Element creator

createElement.js

createElement.js lets document.createElement use CSS selectors.

This is a pretty useful library for building out DOM elements. The whole thing runs on one regex and a for loop, so it’s plenty fast. The script is 300 bytes when compressed and gzipped. For 524 bytes (advanced), it includes nesting support and can generate entire DOM hierarchies, including text nodes.

Usage

document.createElement(); // generates <div />
@batazo
batazo / Database.php
Created May 11, 2020 15:46 — forked from n0m4dz/Database.php
PHP PDO database CRUD class
<?php
class Database extends PDO
{
public function __construct($DB_TYPE, $DB_HOST, $DB_NAME, $DB_USER, $DB_PASS)
{
parent::__construct($DB_TYPE.':host='.$DB_HOST.';dbname='.$DB_NAME, $DB_USER, $DB_PASS);
}
@batazo
batazo / PDOFunctionsDemo.php
Created May 3, 2020 16:47 — forked from MuhammadFaizanKhan/PDOFunctionsDemo.php
Insert, Update, Delete and Select with PHP, PDO and MySQL
<?php
/**
* Created by PhpStorm. * User: Faizan Khan * Date: 1/2/2018 * Time: 10:51 AM
*/
/*Script Motive: The purpose of the file is to present different PDO Functions for DML and DDL operations
Sample Table
Table Name: UserTbl
Columns: Id, UserName, Email, RecordAddDate
*/
@batazo
batazo / custom-loop.php
Created April 21, 2020 03:52 — forked from danielpataki/custom-loop.php
Retrieve Any Post You Want With WP_Query
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'future'
);
$scheduled = new WP_Query( $args );
if ( $scheduled->have_posts() ) :
?>
<?php while( $scheduled->have_posts() ) : $scheduled->the_post() ?>
@batazo
batazo / bbcode.php
Created April 6, 2020 07:59 — forked from zacscott/bbcode.php
Simple BBcode rendering function (PHP).
<?php
/**
* Renders BBCode to html, suitable to be embedded in a document. Supports only
* a limited set of BBCode tags (can be extended), which are:
*
* @param $bbcode The bbcode to be rendered. Must not be `null` or empty
* string.
* @param $reps Optional additional replacements. Allows you to add custom tags
* etc. Should be an associative array, mapping a regex (preg) to replacement.
@batazo
batazo / .htaccess
Created March 20, 2020 00:44 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/