Skip to content

Instantly share code, notes, and snippets.

View sueleybyte's full-sized avatar
🍰
The cake is not a lie!

Süleyman Özdogan sueleybyte

🍰
The cake is not a lie!
View GitHub Profile
@sueleybyte
sueleybyte / Blocks.md
Created May 28, 2020 18:16 — forked from bdlangton/Blocks.md
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
@sueleybyte
sueleybyte / cookie.js
Created October 29, 2019 23:00
Get a cookie, set a cookie, get all cookies
@sueleybyte
sueleybyte / cookies.js
Last active August 9, 2019 11:57
Get a specific cookie, all cookies and set a cookie
class Cookies {
static getCookie(name) {
return document.cookie.split(";").map(cookie => {
let [key, value] = cookie.split("=");
if (name === key) return value;
}).toString();
}
static getCookies() {
@sueleybyte
sueleybyte / update.sql
Last active August 9, 2019 11:56
Update Wordpress HTTP to HTTPS
-- Options
UPDATE wp_options SET option_value = REPLACE(option_value, "http", "https") WHERE option_name = "siteurl" OR option_name = "home" AND option_value NOT LIKE "https%";
-- Posts
UPDATE wp_posts SET guid = REPLACE(guid, "http", "https") WHERE guid NOT LIKE "https%";
@sueleybyte
sueleybyte / jwt_auth_middleware.js
Last active May 24, 2019 11:24
Middleware for checking JWT
const jwt = require("jsonwebtoken");
/**
* Check JWT
*/
function checkJWT(options) {
return (request, response, next) => {
// Check for paths to ignore
if (options.unless.includes(request.path)) return next();