Skip to content

Instantly share code, notes, and snippets.

View m3g4p0p's full-sized avatar
💭
waits until idle

m3g4p0p

💭
waits until idle
View GitHub Profile
@m3g4p0p
m3g4p0p / autocomplete.js
Last active June 21, 2016 19:23
A JS autocomplete module
var Autocomplete = function(element, suggestions) {
'use strict';
/**
* Variables
*/
var container = document.createElement('div');
var list = document.createElement('ul');
var listItems = [];
var current = [];
@m3g4p0p
m3g4p0p / json2sql.php
Last active June 20, 2016 22:52
A simple script to iterate over an associative array (from a JSON file), create an SQL schema and populate it with the data
<?php
$idMap = [];
function json2sql($current, $parent, $json) {
global $idMap;
$table = "";
$insert = "";
$children = "";
@m3g4p0p
m3g4p0p / visible.js
Created June 12, 2016 18:26
jQuery extension to reduce the set of matched elements to those being (vertically) in the viewport
$.fn.visible = function() {
'use strict';
var $window = $(window),
windowScrollTop = $window.scrollTop(),
windowHeight = $window.height();
return this.filter(function() {
var $this = $(this),
thisOffsetTop = $this.offset().top,