Skip to content

Instantly share code, notes, and snippets.

@gabrysiak
gabrysiak / new_gist_file.js
Last active August 29, 2015 14:19
Basic Server & Hello World
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337);
console.log('Server listening on port 1337');
@gabrysiak
gabrysiak / wp-db-url-replace.txt
Created February 25, 2015 19:17
Wordpress DB URL Replace
UPDATE `wp_options` SET option_value = replace(option_value, 'CURRENT_URL', 'NEW_URL') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE `wp_posts` SET guid = REPLACE (guid, 'CURRENT_URL', 'NEW_URL');
UPDATE `wp_posts` SET post_content = REPLACE (post_content, 'CURRENT_URL', 'NEW_URL');
UPDATE `wp_postmeta` SET meta_value = REPLACE (meta_value, 'CURRENT_URL','NEW_URL');
@gabrysiak
gabrysiak / local-storage-size.js
Created December 17, 2014 14:48
Javascript find size of local storage
// based on answer to question
// http://stackoverflow.com/questions/4391575/how-to-find-the-size-of-localstorage
(function showLocalStorageSize(){
function stringSizeBytes(str) {
return str.length * 2;
}
function toMB(bytes) {
return bytes / 1024 / 1024;
}
@gabrysiak
gabrysiak / time-method-call.js
Created December 17, 2014 14:47
Javascript get function execution time
// Taken from
// http://calendar.perfplanet.com/2014/performance-measurements-using-chrome-devtools-code-snippets/
var primesApp = {
findFirstPrimes: function () {
var n = Number(document.querySelector('#n').value);
console.log('finding first', n, 'primes');
var primes = findFirstPrimes(n);
renderPrimes(primes);
}
@gabrysiak
gabrysiak / timing.js
Created December 17, 2014 14:44
Javascript Timing API Measurements
// Taken from
// https://github.com/addyosmani/timing.js
// http://calendar.perfplanet.com/2014/performance-measurements-using-chrome-devtools-code-snippets/
/**
* Timing.js 1.0.1
* Copyright 2014 Addy Osmani
*/
(function(window) {
@gabrysiak
gabrysiak / nodejs-startup-service
Created October 31, 2014 13:31
NodeJS basic server and startup script to run application as service
// npm init
// install --save compression connect http serve-static
// vim server.js
var connect = require('connect');
var http = require('http');
var app = connect();
var compression = require('compression')
app.use(compression())
@gabrysiak
gabrysiak / pageslidejs-refresh-form.js
Created October 29, 2014 19:19
Pageslide.js - Refresh form on submit
// Clear interval and open contact form
var openPageslide =function (intervalName){
clearInterval(intervalName);
setTimeout(function(){
$('.pageslide a').trigger('click');
}, 1400);
};
// Pageslide
@gabrysiak
gabrysiak / my-theme-settings.php
Created October 22, 2014 21:43
Wordpress theme options page template.
<?php
add_action( 'admin_menu', 'my_theme_add_admin_menu' );
add_action( 'admin_init', 'my_theme_settings_init' );
function my_theme_add_admin_menu( ) {
add_menu_page( 'Theme Settings', 'My Settings', 'manage_options', 'my_theme_settings', 'my_theme_options_page', 'dashicons-admin-tools', 200 );
}
@gabrysiak
gabrysiak / parseUrl.js
Created October 15, 2014 20:42
Javascript function that returns parsed URL object
/**
* Parse url
* @param {string} url Url string
* @return {object} Parsed url object
*
* Example Use:
* var parsedUrl = parseURL('http://drive.google.com/search');
*
* parsedUrl {
* domain: "drive.google.com",
@gabrysiak
gabrysiak / LAUNCHLIST.md
Last active September 19, 2015 06:38
Website / App Launch Checklist

Website and Application Launch Checklist

A checklist of items to check when launching a website or application. Some items may be optional.

Website Specific

  • Git Repo Setup
  • Spelling, Grammer, Punctuation
  • Forms
  • Site Speed
  • Multi-browser compatibility