Skip to content

Instantly share code, notes, and snippets.

View sp90's full-sized avatar
🦜
Focusing

Simon sp90

🦜
Focusing
View GitHub Profile
@sp90
sp90 / Icon.js
Created March 17, 2017 05:33
svg-sprite icon helper for react
import React from 'react';
var GLYPHS = {
CHECK: require('../icons/check-1.svg'),
CHECK_CIRCLE: require('../icons/check-circle-1.svg'),
CHECK_SHIELD: require('../icons/check-shield.svg')
};
/*
Ex:
<slider content="sliderContent"></slider>
@sp90
sp90 / cron.js
Created October 19, 2017 14:10
Backup script to run for DynamoDB
var DynamoBackup = require('dynamo-backup-to-s3');
var schedule = require('node-schedule');
var config = require('config');
schedule.scheduleJob('0 */12 * * *', backupS3);
function backupS3() {
var backup = new DynamoBackup({
readPercentage: .25, // 25% read capacity
bucket: 'navnPåBucket',
(function() {
'use strict';
var modules = [];
angular
.module('factory.ls', modules)
.factory('Ls', Ls);
function Ls() {
@sp90
sp90 / whenScrolled.js
Last active June 12, 2018 08:11
Simplest infinite scroll module (194 bytes GZIPPED)
(function() {
'use strict';
var modules = [];
angular
.module('directive.whenScrolled', modules)
.directive('whenScrolled', whenScrolled);
function whenScrolled() {
@sp90
sp90 / angularjs.excelgenerator.js
Created July 13, 2018 07:24
A angular based file to generate excel from html
(function() {
'use strict';
angular
.module('factory.Excel', [])
.factory('Excel', Excel);
function Excel($document, $window) {
return {
create: create
@sp90
sp90 / increment.py
Created October 1, 2018 07:43
A simple increment function in python
# So first we def (define) the function and giving it
# the name increment, and adding one parameter
# i call that number_to_increment because its
# the number that you want to increment by 1
def increment(number_to_increment):
# Then we return the number_to_increment + 1
# So if the number_to_increment is 3 it will return 4, if number_to_increment is 500 it will return 501
return number_to_increment + 1
# Here we test the function works
@sp90
sp90 / count.py
Created October 1, 2018 08:11
Simple python function to count occurenances
# We need to count the occurance of words in a text
def count_word_in_text(text, word_to_count_by):
# We first have the text and then we run a "count" method on the text
# then we parse the word_to_count_by
return text.count(word_to_count_by)
# Now we add a string of text we want to count the occurances of a certain word in
# Secound paramater is the word we want to count
count_of_words = count_word_in_text("Hello world, its a great day in this world", "world")
# First we def (define) a function that takes 2 arguments:
# 1. argument is the text to look for occurances
# 2. argument is the word_to_count
def count_word_in_text(text, word_to_count):
# The count of our word that we're counting
count = 0
# The text index looking from
start = 0
@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,