Skip to content

Instantly share code, notes, and snippets.

View niklasp's full-sized avatar
💥
2024 let's go steppin

Niklas P niklasp

💥
2024 let's go steppin
View GitHub Profile
AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY")
AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_STORAGE_BUCKET_NAME")
AWS_AUTO_CREATE_BUCKET = True
AWS_HEADERS = {
"Cache-Control": "public, max-age=86400",
AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY")
AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_STORAGE_BUCKET_NAME")
AWS_AUTO_CREATE_BUCKET = True
AWS_HEADERS = {
"Cache-Control": "public, max-age=86400",
@niklasp
niklasp / 1und1_wordpress_git.txt
Last active January 6, 2017 15:14
1und1 git wordpress local development
#This shows how to setup 1und1 for wordpress development with git
# 1. setup git at 1und1
ssh <your-username>@<your-servername>.1and1-data.host
# 2. go to your wordpress folder usually
cd clickandbuilds/<your-site-name>
# 3. initialize a bare git repo (= without a working tree) and setup a post-receive hook that
# makes changes to your live website
@niklasp
niklasp / gist:ee13412f1d0cfda4fe1676866ebfc480
Created November 28, 2017 21:20
avada random header logo
/**
* The avada_logo_prepend hook.
*/
do_action( 'avada_logo_prepend' );
?>
<?php if ( ( Avada()->settings->get( 'logo', 'url' ) && '' !== Avada()->settings->get( 'logo', 'url' ) ) || ( Avada()->settings->get( 'logo_retina', 'url' ) && '' !== Avada()->settings->get( 'logo_retina', 'url' ) ) ) : ?>
<a class="fusion-logo-link" href="<?php echo esc_url_raw( home_url( '/' ) ); ?>">
<!-- standard logo -->
<?php
@niklasp
niklasp / preload_array.js
Created November 26, 2020 20:40 — forked from akella/preload_array.js
Preload array of images with callback
function loadImages(paths,whenLoaded){
var imgs=[];
paths.forEach(function(path){
var img = new Image;
img.onload = function(){
imgs.push(img);
if (imgs.length==paths.length) whenLoaded(imgs);
}
img.src = path;
});
@niklasp
niklasp / getExactElementPosition
Created March 27, 2021 19:17
Get the exact position of an element
// Helper function to get an element's exact position
function getPosition(el) {
var xPos = 0;
var yPos = 0;
while (el) {
if (el.tagName == "BODY") {
// deal with browser quirks with body/window/document and page scroll
var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
var yScroll = el.scrollTop || document.documentElement.scrollTop;
/**
*
* @param {DOMElement} container
* @param {DOMElement} element
*
* Make the element follow the mouse when it is over container, with
* a following speed of speed.
*/
export function followMouse( container, element, damping ) {
let mouseX = 0, mouseY = 0, translateX = 0, translateY = 0;
@niklasp
niklasp / threejsstarter.js
Last active July 20, 2021 12:50
Beautified threejs starter with shaders
import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
export default class Sketch {
constructor( options ) {
this.time = 0;
this.container = options.dom;
this.width = this.container.offsetWidth;
this.height = this.container.offsetHeight;
@niklasp
niklasp / vertex.glsl
Last active April 5, 2021 15:03
perlin3d cnoise vertex shader
// the shader is applied to each point forming an object
// in parallel by the gpu
// Classic Perlin 3D Noise
// by Stefan Gustavson
//
vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}
vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}
vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}
@niklasp
niklasp / gs5excerpt.js
Created May 27, 2021 14:51
gs5 lightgallery2
const gsBgImgSelector = '.wp-block-eedee-block-gutenslider .eedee-background-div img';
const dynamicEl = [ ...el.querySelectorAll( gsBgImgSelector ) ].map( ( sliderImg ) => {
return {
src: sliderImg.src,
thumb: sliderImg.src,
subHtml: '<h4>Image 1 title</h4><p>Image 1 descriptions.</p>',
};
});