Skip to content

Instantly share code, notes, and snippets.

View sp90's full-sized avatar
🦜
Focusing

Simon sp90

🦜
Focusing
View GitHub Profile
@sp90
sp90 / _breakpoint.scss
Created May 20, 2021 11:45
Breakpoint mixin
/**
* $bp-mega: 2500px;
* $bp-mega: 1900px;
* $bp-kilo: 1360px;
* $bp-centi: 1024px;
* $bp-milli: 768px;
* $bp-nano: 480px;
*/
$breakpoint-map: (
import { of, BehaviorSubject } from 'rxjs';
import { fromFetch } from 'rxjs/fetch';
import { switchMap, catchError } from 'rxjs/operators';
interface CustomMethodInterface {
name: string;
endpoint: string;
method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
}
@sp90
sp90 / client.html
Created July 19, 2019 09:43
Simple karma testing client.html styling
<!DOCTYPE html>
<!--
The entry point for client. This file is loaded just once when the client is captured.
It contains socket.io and all the communication logic.
-->
<html>
<head>
<!-- %X_UA_COMPATIBLE% -->
<title>Karma</title>
<link href="favicon.ico" rel="icon" type="image/x-icon" />
@sp90
sp90 / chainable-methods.js
Last active July 9, 2019 14:11
A simple way of chaining methods
class klass {
constructor() {}
sum(...args) {
this.value = args.reduce((sum, current) => sum + current, 0);
return this;
}
add(value) {
@sp90
sp90 / Array-operations.js
Created March 20, 2019 08:18
Small subset of javascript operations on an array
let myArr = [0, 2, 5]
let arr2 = [1, 6, 7]
// Attach a value to the end of an array
myArr.push(6)
console.log(myArr) // [0, 2, 5, 6]
// Attach a value to the beginning of an array
myArr.unshift(3)
console.log(myArr) // [3, 0, 2, 5, 6]
@sp90
sp90 / dynogels-to-mongoose.js
Last active February 27, 2019 10:11
A script to help you move your data from your dynamodb to mongodb, if your using dynogels and mongoose
const Promise = require('bluebird')
const _ = require('lodash')
// Include your dynogels models
let models = require('./routes/helpers/models')
// Include your mongoose models
let mongooseModels = require('./routes/helpers/mongooseModels')
module.exports = (settings, itemsMapping) => {
@sp90
sp90 / elasticExample.js
Last active December 12, 2018 09:05
Elastic example - querying survey data
let dataSet = [{
"survey_answers": [
{
"id": "9ca01568e8dbb247", // As they are, this is the key to groupBy
"option_answer": 5, // Represent the index of the choosen option
"type": "OPINION_SCALE" // Opinion scales are 0-10 (meaning elleven options)
},
{
"id": "ba37125ec32b2a99",
"option_answer": 3,
@sp90
sp90 / find_count_of_lowest.py
Created November 15, 2018 16:52
Finding the lowest number and count the amount of occurrences
list_of_numbers = [1, 2 , 1, 3]
def find_count_of_lowest(numbers):
numbers.sort()
lowest_number = numbers[0]
count_lowest_number = 0
for number in numbers:
if number == lowest_number:
@sp90
sp90 / helper_functions.py
Last active November 12, 2018 08:46
Helper functions
# Numbers between
def numbers_between(numbers, min_range, max_range):
# Create empty list to contain our results
result = []
# Run through each number
for number in numbers:
# If number is bigger or equal to min_range and bigger or equal to max_range
if number >= min_range and number <= max_range:
@sp90
sp90 / scrollama-scale.js
Created October 15, 2018 21:25
A vue extension that uses scrollama to scale items on scroll in a smooth motion (Its abit janky)
import 'intersection-observer';
import scrollama from 'scrollama';
const scroller = scrollama();
// setup the instance, pass callback functions
scroller
.setup({
step: settings.$refs.slide__item,