Skip to content

Instantly share code, notes, and snippets.

View sebbdk's full-sized avatar
Developing ad libitum

Sebastian Vargr sebbdk

Developing ad libitum
View GitHub Profile
@sebbdk
sebbdk / gist:04bbee348b38ee357b4043e7aace9a9e
Last active February 20, 2020 23:54
List redux reducer creator
This can be used to bootsrap making reducers that only have to manage an array of data.
// crud-lib.js
import nanoid from 'nanoid';
export function createActionTypes(reducerAlias) {
return {
add: Symbol(`CUD add in ${reducerAlias}`),
remove: Symbol(`CUD remove in ${reducerAlias}`),
update: Symbol(`CUD remove in ${reducerAlias}`),
@sebbdk
sebbdk / Regressive search, throw vs array vs null
Last active February 19, 2020 09:37
Tree search, throw vs array vs null
// Con, un-used catch, performance?, un-used catch is a codesmell
function findPage(pid, pages:IPage[]): IPage {
for(const page of pages) {
if (page.pageId === pid) return page;
if(page.subPages.length > 0) {
try {
return findPage(pid, page.subPages);
} catch {}
@sebbdk
sebbdk / filter-subscription.js
Last active December 6, 2019 22:30
Draft of how basic low level Redux filters could work
// ---> custom filtered sub-store
function createContentObservable(store) {
const contentSubs = {
X: []
}
const dispose = store.subscribe((cat) => {
if (store.getState().lastAction.type === 'content-change') {
const id = store.getState().lastAction.id;
@sebbdk
sebbdk / animate.js
Created September 3, 2019 09:28
Javascript - animate()
export function animate(cb, time) {
return new Promise((resolve, reject) => {
const startTime = performance.now();
const endTime = startTime + time;
function run() {
const currentTime = performance.now();
const deltaTime = currentTime - startTime;
const pctDone = deltaTime / time;
@sebbdk
sebbdk / scroll-to.js
Last active September 3, 2019 09:28
Javascript - scrollTo()
function scrollTo({ element = window, top = 0, left = 0, behavior = 'smooth' }) {
return new Promise((res) => {
const onScroll = function() {
// @ts-ignore
const scrollTop = element.scrollTop
if (scrollTop === top) {
element.removeEventListener('scroll', onScroll)
res();
}
#include <Wire.h>
#if defined(ARDUINO_SAM_DUE)
#define WIRE Wire1
#else
#define WIRE Wire
#endif
//Settings:
#define _i2caddr 0x60
@sebbdk
sebbdk / demo
Last active May 26, 2016 11:34
magic code
<div class="responsive-background" data-src="intro/introslide2.jpg"></div>
<script>
var resizeTimer;
var resizing = false;
var startWidth = 0;
var loadedImages = [];
var maxWidth = window.innerWidth;
$(window).on('resize', function(e) {
var params = {
merchantnumber:"[TEST MERCHANTNUMBER]",
currency:"208",
mobile:"0",
windowState:"4",
"iframeheight": "100%",
"iframewidth": "100%"
};
params.amount = 10;
Remote Address:[::1]:80
Request URL:http://localhost/help/dah/admin/notifications/add
Request Method:POST
Status Code:302 Found
Response Headers
view source
Access-Control-Allow-Origin:*
Connection:Keep-Alive
Content-Length:0
Content-Type:text/html; charset=UTF-8
'use strict';
function Boot() {
}
Boot.prototype = {
preload: function() {
this.load.image('preloader', 'assets/preloader.gif');
},
create: function() {