Skip to content

Instantly share code, notes, and snippets.

View selbekk's full-sized avatar
👨
Working dad

Kristofer Giltvedt Selbekk selbekk

👨
Working dad
View GitHub Profile
@selbekk
selbekk / gist:bba01162a835abbc8a93
Created January 25, 2015 12:28
enkel ajax-sending av skjema
$('#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
<?php
$to = "[email protected]"; // 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
@selbekk
selbekk / gist:aa2ee544a5e6b28ccab3
Created February 18, 2015 08:55
My .gitconfig file
[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 August 6, 2015 07:36 — 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.
@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 March 30, 2018 18:52
A simple rewrite of Elijah Grey's dataset polyfill to ES2015. Works with babel!
/*
@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 August 10, 2016 10:46
Simple query string parsing
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 December 6, 2016 10:55
Simple dependency injection
import React from 'react';
export default withDependencies(TargetComponent, dependencies) {
return function DependencyInjector(props) {
return <TargetComponent {...props} {...dependencies} />;
}
}
@selbekk
selbekk / withSpinner.jsx
Created March 13, 2017 16:49
A simple spinner HOC
// 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>
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 April 11, 2017 11:24
Reecap showcase
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';