Skip to content

Instantly share code, notes, and snippets.

View SebbeJohansson's full-sized avatar

Sebastian Johansson SebbeJohansson

View GitHub Profile
@SebbeJohansson
SebbeJohansson / clCurl.php
Created September 26, 2018 08:39
clCurl - Curl wrapper.
<?php
namespace Apex\Core;
class clCURLold {
public $oRequest;
public $iLastHTTPStatus;
public $aOptions = array();
@SebbeJohansson
SebbeJohansson / oldcURL.php
Last active September 26, 2018 08:40
cURL execution function. - Old version.
/**
* Execute a cURL.
*
* @param $url
* @param array $header An array of headers.
* @param string $mode Mode for the execution (PUT/GET/POST).
* @param string $variables Variables/body to send in execution. String or json.
* @return mixed Returns decoded json of return from execution.
*/
<?php
$config = require('config.php');
$key = $config['secure_key'];
$uploadhost = $config['output_host'];
$uploadfolder = $config['output_folder'];
$redirect = $config['redirect_url'];
$giphy_key = $config['giphy_api_key'];
if ($_SERVER["REQUEST_URI"] == "/robot.txt") { die("User-agent: *\nDisallow: /"); }
$row = 1;
$keys = [];
$array = [];
if (($handle = fopen("themes/fritidsfabriken/docs/feature_value_export_CZ_en.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
//echo "<p> $num fields in line $row: <br /></p>\n";
$value = [];
for ($c=0; $c < $num; $c++) {
//echo $data[$c] . "<br />\n";
const regex = /(?<start><img)(?<middle>.*?)(?<end>\/>)/ig;
const newText = col.RichText.replaceAll(regex, (match, p1, p2, p3, offset, string, namedGroups) => {
return `${namedGroups.start} loading="lazy" ${namedGroups.middle} ${namedGroups.end}`;
});
import axios from "axios";
import StoryblokClient from "storyblok-js-client";
import TurndownService from "turndown";
import markdownConverter from "storyblok-markdown-richtext";
// rember to remove
const spaceId = {{INSERT STORYBLOK SPACE ID HERE}};
let Storyblok = new StoryblokClient({
// Remmber to remove
oauthToken: "{{INSERT STORYBLOK MANAGEMENT API TOKEN HERE}}",
@SebbeJohansson
SebbeJohansson / StoryblokDateTimeField.js
Last active July 23, 2022 16:53
A storyblok datetime field with a default value for today.
const Fieldtype = {
template: `
<div>
<div class="image__wrap uk-margin-small-bottom">
<input type="datetime-local" id="date" name="date" v-model="model.date">
</div>
</div>
`,
mixins: [window.Storyblok.plugin],
methods: {
@SebbeJohansson
SebbeJohansson / GithubGistEmbed.vue
Created August 30, 2022 21:22
Nuxt3 Github Gist Embed component
<script setup lang="ts">
const props = defineProps({
gistId: {
type: String,
required: true,
},
file: {
type: String,
required: false,
default: '',
@SebbeJohansson
SebbeJohansson / SsrStoryblokComponent.vue
Last active January 28, 2023 11:49
Custom nuxt3 storyblok component rendering - Previously needed for proper ssr rendering
<!-- This is not needed anymore, just using useStoryblok() or useAsyncStoryblok() should work. -->
<!-- https://github.com/storyblok/storyblok-nuxt/issues/155 -->
<script setup lang="ts">
import { SbBlokData } from '@storyblok/vue/dist';
const props = defineProps({
blok: {
type: Object,
required: true,
},
@SebbeJohansson
SebbeJohansson / Custom useAsyncStoryblok - [...slug].vue
Last active January 28, 2023 19:00
Custom useAsyncStoryblok function with proper error handling
<!-- Example page -->
<script setup lang="ts">
import { ISbStoryData } from '@storyblok/vue/dist';
const route = useRoute();
const { locale } = useI18n();
let story = {} as ISbStoryData;
try {