Skip to content

Instantly share code, notes, and snippets.

View mkykode's full-sized avatar

Jull Weber mkykode

View GitHub Profile
@sTiLL-iLL
sTiLL-iLL / frag.js
Created August 25, 2014 01:28
Fastest way to add new nodes to the DOM
var frag = document.createDocumentFragment();
ajaxResult.items.forEach(function(item) {
// Create the LI element
var li = document.createElement('li');
li.innerHTML = item.text;
// Do some normal node operations on the LI here,
// like add classes, modify attributes,
// add event listeners, add child nodes, etc.
@sTiLL-iLL
sTiLL-iLL / debounce.js
Created August 25, 2014 01:33
A load balancing function.... debounce()
/*
The debounce method returns a function which wraps your callback,
limiting its execution rate to the limit specified in the second argument.
Now your frequent callbacks can't brick the user's browser!
*/
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
@sTiLL-iLL
sTiLL-iLL / seshCache.js
Last active August 29, 2015 14:05
Simple caching inside of session storage...
// session storage caching
define(function() {
var cacheObj = window.sessionStorage || {
getItem: function(key) {
return this[key];
},
setItem: function(key, value) {
@sTiLL-iLL
sTiLL-iLL / condyLoad.js
Created August 26, 2014 07:06
basic conditional loading (loads when specified elements are present)
/*
The arguments against this practice will be (1) concatenating into existing JS and CSS to save on the number of requests and (2) flash of content style changes. The first argument needs to be judged on a per-case basis; if the required CSS and JS is small, it should be concatenated to a file used throughout the site or site subsection. The second argument can always be hushed with a bit of transition magic!
*/
$('article pre').length && (function() {
var mediaPath = '/assets/';
$('<link>').attr({
type: 'text/css',
rel: 'stylesheet',
href: mediaPath + 'css/syntax.css'
@sTiLL-iLL
sTiLL-iLL / thepool.js
Last active August 29, 2015 14:05
simple and effective object / worker / connection pool implimentation in javascript
function PoolFactory() {
var createPool = function (options) {
var wrkrs = [], freeWrkrs = [],
opts = options || {},
wCnt = options.maxWorkers || 4,
wrkrPth = options.path || 'whateveryouwant.js';
@sTiLL-iLL
sTiLL-iLL / objProtaddl.js
Created August 26, 2014 09:11
extend, toggleClass, and equals methods
// functional additions to the Object prototype
Object.prototype.extend = function() {
if (arguments.length === 0)
return this;
for (var i = 0; i < arguments.length; i++) {
for (var property in arguments[i]) {
if (arguments[i].hasOwnProperty(property))
@nishantmodak
nishantmodak / nginx.conf.default
Last active October 27, 2025 14:27
Default Nginx Conf
#user nobody;
#Defines which Linux system user will own and run the Nginx server
worker_processes 1;
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores.
#error_log logs/error.log; #error_log logs/error.log notice;
#Specifies the file where server logs.
@tomazzaman
tomazzaman / README.md
Last active September 17, 2023 20:59
Gulp workflow for WordPress theme development

Gulp workflow for WordPress theme development

Requirements

In order for Livereload to work, you need a Firefox or Chrome extension as Gulp doesn't inset it automatically. Alternatively, you can also manually put the livereload script in footer.php, just make sure to insert it only on development environment:

<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
@retlehs
retlehs / header.php
Created April 29, 2015 04:55
Sage header template for Bootstrap top navbar component
<?php
// This file assumes that you have included the nav walker from https://github.com/twittem/wp-bootstrap-navwalker
// somewhere in your theme.
?>
<header class="banner navbar navbar-default navbar-static-top" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only"><?= __('Toggle navigation', 'sage'); ?></span>
@arkadiusjonczek
arkadiusjonczek / functions.php
Created June 9, 2015 00:34
Remove Genesis Credits Footer
//* Remove Credits & more
remove_action('genesis_footer', 'genesis_do_footer');