Skip to content

Instantly share code, notes, and snippets.

View LordZombi's full-sized avatar

Zombi LordZombi

View GitHub Profile
@LordZombi
LordZombi / tabs.css
Last active March 2, 2023 15:27
Simple Vanilla.js tabs implementation
.tabs__header-tab.is-active {
// Some active styles for header
}
.tabs__content {
display: none; // Hide tab content
}
.tabs__content.is-active {
display: block; // And show only active
@LordZombi
LordZombi / kebabCaseFiles.js
Last active February 21, 2023 08:15
Rename files to kebab-case (AI generated)
const fs = require('fs');
const path = require('path');
function removeAccents(str) {
return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
}
function kebabCase(str) {
return str
.replace(/[^\w\s-]/g, '') // Remove non-Latin characters and keep spaces and hyphens
@LordZombi
LordZombi / animatedScrollTo.js
Created August 22, 2017 15:31 — forked from joshbeckman/animatedScrollTo.js
ScrollTo animation using pure javascript and no jquery
document.getElementsByTagName('button')[0].onclick = function () {
scrollTo(document.body, 0, 1250);
}
function scrollTo(element, to, duration) {
var start = element.scrollTop,
change = to - start,
currentTime = 0,
increment = 20;
@LordZombi
LordZombi / tricks
Created October 24, 2013 12:01
Wrong displaying on mobile | tablet ?
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<meta name=apple-mobile-web-app-capable content=yes>
<meta name=apple-mobile-web-app-status-bar-style content=black>
<meta name="googlebot" content="index,follow,snippet,archive">
<meta name="robots" content="index,follow">
<meta name="description" content="#">
<meta name="keywords" content="#">
<meta name="author" content="#">
@LordZombi
LordZombi / curl
Created October 18, 2013 13:01
Curl
$server = $this->getRequest()->getServer();
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 90); // times out after 90s
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
@LordZombi
LordZombi / disable.php
Last active December 23, 2015 21:29
Disable Layout, Never Render
// in controller action
$this->_helper->viewRenderer->setNeverRender();
$this->_helper->layout()->disableLayout();
@LordZombi
LordZombi / redirects
Last active December 20, 2015 20:49
Routes, Forward, Redirect
$this->_helper->redirector->gotoRouteAndExit(array(), 'backend-module-controller');
$params = array();
$this->forward('denied', 'error', 'default', $params);
return;
@LordZombi
LordZombi / language
Created August 8, 2013 09:56
Set locale language
$translator = $this->view->getHelper('translate')->getTranslator();
$translator->setLocale($order->getLanguage()->code);
@LordZombi
LordZombi / paypal
Created July 24, 2013 14:08
PayPal IPN setup
<?php
// STEP 1: read POST data
// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
// Instead, read raw POST data from the input stream.
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
@LordZombi
LordZombi / numbers
Created July 24, 2013 08:18
Rounding numbers
NUMBER FORMAT:
return number_format((float)$number, 2, '.', '');
SPRINTF:
$padded = sprintf('%0.2f', $unpadded); // 520 -> 520.00
ROUND:
<?php
echo round(3.4); // 3
echo round(3.5); // 4