Skip to content

Instantly share code, notes, and snippets.

@8ctopotamus
8ctopotamus / Fix image upload HTTP ERROR on InmotionHosting.txt
Created September 11, 2017 15:48
Fix image upload HTTP ERROR on InmotionHosting
# Add this to the .htaccess
# fix image upload HTTP ERROR on inmotion hosting
SetEnv MAGICK_THREAD_LIMIT 1
@8ctopotamus
8ctopotamus / CycleCameraUnity.cs
Created September 11, 2017 21:12
Cycling through Cameras Unity3D
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameController : MonoBehaviour {
public GameObject[] gameCameras;
private int gameCameraIndex = 0;
### You need to do this first:
# 1 .Enable External option in Unity → Preferences → Packages → Repository (only if Unity ver < 4.5)
# 2. Switch to Visible Meta Files in Edit → Project Settings → Editor → Version Control Mode
# 3. Switch to Force Text in Edit → Project Settings → Editor → Asset Serialization Mode
# 4. Save Scene and Project from File menu.
# 5. Quit Unity and then you can delete the Library and Temp directory in the project directory. You can delete everything but keep the Assets and ProjectSettings directory.
@8ctopotamus
8ctopotamus / gatsby-build-DOM-protection-example.js
Last active November 24, 2020 14:26
gatbys build DOM protection: Avoid Gatsby Build Errors when working with DOM
// we need to guard against anything that uses document or window
// for the gatsby build to work because there is no DOM in the build process.
// Example of importing a package such as sketch-js:
let sketch
if (typeof document !== 'undefined')
sketch = require('sketch-js')
@8ctopotamus
8ctopotamus / quick-esc.js
Last active January 18, 2018 16:52
Quick-escape functionality
(function() {
// the ESC button on the page
var quickESCButton = document.getElementById('quick-esc')
function getAway() {
// open new tab with innocent site
window.open("http://weather.com", "_newtab")
// replace current site with another benign site
window.location.replace('http://google.com')
}
@8ctopotamus
8ctopotamus / github-generate-ssh-key.md
Created March 15, 2018 21:21
Generate an SSH key to fix 'could not read Username for 'https://github.com': Invalid argument'

Source: hexojs/hexo-deployer-git#71

error: failed to execute prompt script (exit code 1) fatal: could not read Username for 'https://github.com': Invalid argument

1- Create a ssh key using Git Bash using following command

ssh-keygen -t rsa -b 4096 -C "[email protected]"

After running this command just install the by default options and enter the password balnk when it prompts.

@8ctopotamus
8ctopotamus / Expose Custom Post Type (And Taxonomy) as Endpoint to WP JSON API
Last active May 16, 2018 20:59
After adding the properties (indicated by comment: /* Required to expose to WP-JSON API */ ) to your register_post_type() function, you should be able to get your CPT data as JSON by visiting example.com/wp-json/wp/v2/cpt-endpoint.
//Register the post type
register_post_type('podcasts', array(
'label' => 'Podcasts',
'description' => 'A library of podcasts.',
'public' => true,
'show_in_rest' => true, /* Required to expose to WP-JSON API */
'rest_base' => 'podcasts', /* Required to expose to WP-JSON API */
'rest_controller_class' => 'WP_REST_Posts_Controller', /* Required to expose to WP-JSON API */
'show_ui' => true,
'show_in_menu' => true,
@8ctopotamus
8ctopotamus / count-repeater-fields-in-acf-flexible-content-example.php
Last active June 27, 2024 13:19
Count number of repeater fields in ACF flexible content.
// Source: https://katienelson.co.uk/developer-acf-counting-repeater-rows-inside-flexible-content/
// The following code doesn’t work with a repeater field if it is part of a flexible content block.
<?php
if(have_rows('card')):
$cards = get_sub_field('card');
$number_of_cards = count($cards);
endif;
?>
@8ctopotamus
8ctopotamus / Dynamically force HTTPS in .htaccess
Created August 23, 2018 19:53
Dynamically force HTTPS in .htaccess
# force HTTPS dynamically
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@8ctopotamus
8ctopotamus / lobff-book-slider.html
Created August 27, 2018 15:31
LOBFF Book slider
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css">
<style>
#nowhere-to-go-book {
display: flex;
flex-direction: column;
align-items: center;
padding: 40px 0;
width: 100%;