Skip to content

Instantly share code, notes, and snippets.

View davidverhage's full-sized avatar

Monoquo davidverhage

View GitHub Profile
@davidverhage
davidverhage / Return readable date
Created August 15, 2015 22:03
Date snippet v1
/**
* A simple snippet to return a stored date from mysql to human readable form
*/
$originalDate = "2010-03-21";
$newDate = date("d-m-Y", strtotime($originalDate));
@davidverhage
davidverhage / Timestamp to human v2 function
Last active August 29, 2015 14:27
Timestamp to human
/**
* Original segment author: Patrick Talmadge
* Translated to dutch: David Verhage
*/
function genTime($timestamp)
{
// Get time difference and setup arrays
$difference = time() - $timestamp;
$periods = array("seconden", "minuten", "uur", "dagen", "weken", "maanden", "jaar");
$lengths = array("60","60","24","7","4.35","12");
@davidverhage
davidverhage / show_hide html
Created August 18, 2015 21:51
Show and hide element or part
<?php
/**
* A smooth way of hiding and showing certain elements using jQuery
*
*/
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
@davidverhage
davidverhage / Cookiestrap
Created August 19, 2015 20:48
Bootstrap cookie Workaround (workout)
<?php
/**
* Ever needed a modal message displayed only once for every 'new' visitor?
* Title: Bootstrap using cookies to show modal once
*/
if (!isset($_COOKIE['notifica-modal'])){
setcookie("notifica-modal", "true", time()+86400, "/");
?>
<script type="text/javascript">
$(window).load(function(){
@davidverhage
davidverhage / Db driven dropdown
Created August 24, 2015 20:08
For legend sake
/**
* Codeigniter Based
*
*/
function get_selections($table, $id = 'id', $column = 'name')
{
$alert='';
$value= "select * from {$table}";
$result= $this->db->query($value);
@davidverhage
davidverhage / chat.php
Last active September 14, 2015 19:32 — forked from iGusev/chat.php
php-chat
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<meta http-equiv="refresh" content="2">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
.chat-body {
margin-bottom: 10px;
@davidverhage
davidverhage / killTabSpaces.js
Created May 31, 2016 20:55
A quick clean tool to remove spaces and tabs from a designated input field
$(document).ready(function() {
// attempt to kill all Alien spaces and tabs when keyup is initiated
$('input#login').keyup(function() {
console.log('check input form for spaces');
$(this).val($(this).val().replace(/ +?/g, ''));
var value = $.trim( $(this).val() );
$(this).val( value );
});
// if all fails and alien tabs do try to take over,
// clean the field when out of focus using blur()
<noscript>
Om deze site optimaal te gebruiken is het noodzakelijk om Javascript aan te zetten.
</noscript>
$(document).ready(function() {
$.ajaxSetup({ cache: true });
$.getScript('//connect.facebook.net/en_US/sdk.js', function(){
FB.init({
appId: '{your-app-id}',
version: 'v2.7' // or v2.1, v2.2, v2.3, ...
});
$('#loginbutton,#feedbutton').removeAttr('disabled');
FB.getLoginStatus(updateStatusCallback);
});
/**
* Modify the parts you need to get it working.
*/
var should = require('should');
var request = require('../node_modules/request');
var io = require('socket.io-client');
var serverUrl = 'http://localhost';