Skip to content

Instantly share code, notes, and snippets.

Avatar
👨
On paternal leave

Kristofer Giltvedt Selbekk selbekk

👨
On paternal leave
View GitHub Profile
@selbekk
selbekk / gist:bba01162a835abbc8a93
Created Jan 25, 2015
enkel ajax-sending av skjema
View gist:bba01162a835abbc8a93
$('#form').on('submit', function(e) {
// stopp formet i å bli submitted
e.preventDefault();
// en referanse til form-taggen
var $form = $(this);
// lag et options-objekt som gir info til $.ajax etterpå
var opts = {
url: 'kontakt.php', // send ajax-request til denne filen
View gist:fe20586bebcdb3635292
<?php
$to = "hpn_x@hotmail.com"; // this is your Email address
$from = $_POST['mailInput']; // this is the sender's Email address
$name = $_POST['nameInput'];
$subject = "forespørsel til Livs Lekestue";
$message = $name . " " . " wrote the following:" . "\n\n" . $_POST['messageInput'];
$headers = "From:" . $from;
$responseCode = 200; // regner med at alt går bra
if(!mail($to,$subject,$message,$headers)) { // mail-metoden returnerer true eller false avhengig av om mailen ble sendt
View gist:aa2ee544a5e6b28ccab3
[include]
path = ~/.gitconfig-user
# Include user specific information
[core]
editor = vim
excludesfile = /opt/boxen/config/git/gitignore
autocrlf = input
# Convert line endings to platform input (LF on *nix, CRLF on windows).
# In other words, don't use this on windows. Use 'true' instead.
@selbekk
selbekk / styles.scss
Created Aug 6, 2015 — forked from pburtchaell/styles.css
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
View styles.scss
@mixin vh($heightPercentage) {
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*
* Original gist at from here: https://gist.github.com/pburtchaell/e702f441ba9b3f76f587
@selbekk
selbekk / dataset-es2015-polyfill.js
Last active Mar 30, 2018
A simple rewrite of Elijah Grey's dataset polyfill to ES2015. Works with babel!
View dataset-es2015-polyfill.js
/*
@name HTML 5 dataset Support
@version 0.0.2
@home http://code.eligrey.com/html5/dataset/
@author Elijah Grey - eligrey.com
@license http://www.gnu.org/licenses/lgpl.html
Rewritten to ES2015 by Kristofer Selbekk
*/
Element.prototype.setDataAttribute = function(name, value) {
@selbekk
selbekk / qs-simple.js
Last active Aug 10, 2016
Simple query string parsing
View qs-simple.js
export function parse(input) {
if (!input || typeof input !== 'string') {
return input;
}
const qs = input.startsWith('?') ? input.substring(1) : input;
return qs.split('&')
.filter(item => item)
.reduce((prev, item) => {
@selbekk
selbekk / withDependencies.js
Created Dec 6, 2016
Simple dependency injection
View withDependencies.js
import React from 'react';
export default withDependencies(TargetComponent, dependencies) {
return function DependencyInjector(props) {
return <TargetComponent {...props} {...dependencies} />;
}
}
@selbekk
selbekk / withSpinner.jsx
Created Mar 13, 2017
A simple spinner HOC
View withSpinner.jsx
// Her er en enkel spinner - en div med no css på
const Spinner = () => (
<div className="spinner" />
);
// Her er en liste med todos - den rendrer ut listen med todos.
const TodoList = props => (
<ul classList="todos">
{props.todos.map(todo => <li className="todo" key={todo.id}>{todo.text}</li>)}
</ul>
View table.jsx
const Table = props => (
<table>
<thead>
<tr>
{props.headers.map(header => <th>{header}</th>)}
</tr>
</thead>
<tbody>
{props.data.map(row => (
<tr>
@selbekk
selbekk / showcase.jsx
Created Apr 11, 2017
Reecap showcase
View showcase.jsx
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import classNames from 'classnames';
import EventImage from '~/components/EventImage';
import Logo from '~/components/Logo';
import Spinner from '~/components/Spinner';
import * as dispatchers from '~/dispatchers';
You can’t perform that action at this time.