Skip to content

Instantly share code, notes, and snippets.

View mitzerh's full-sized avatar

Helcon Mabesa mitzerh

View GitHub Profile
@mitzerh
mitzerh / diffwrap.sh
Created March 27, 2015 19:31
SVN Diff
#!/bin/sh
# Configure your favorite diff program here.
#DIFF="/usr/bin/vimdiff"
DIFF="/usr/bin/opendiff"
# Subversion provides the paths we need as the sixth and seventh
# parameters.
LEFT=${6}
RIGHT=${7}
@mitzerh
mitzerh / fiddle.css
Created February 18, 2015 14:28
Infinitely Loading Content
.highlight { border: 2px solid red; }
@mitzerh
mitzerh / viewport.js
Created February 18, 2015 02:52
Check if DOM is visible in viewport
function isElementInViewport (el) {
//special bonus for those using jQuery
if (typeof jQuery === "function" && el instanceof jQuery) {
el = el[0];
}
var rect = el.getBoundingClientRect();
return (
@mitzerh
mitzerh / .jshintrc
Last active August 29, 2015 14:14 — forked from haschek/.jshintrc
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true
@mitzerh
mitzerh / ParseTweet.js
Last active August 29, 2015 14:13
Parse Tweet String
var ParseTweetText = function(text) {
// link
text = text.replace(/(http|https):\/\/\S+/gi, function(val) {
return '<a target="_blank" href="'+val+'">'+val+'</a>';
});
// user_name
text = text.replace(/@[A-Z0-9\-\_]+/gi, function(val) {
return '<a target="_blank" href="https://twitter.com/'+val.slice(1)+'">'+val+'</a>';
@mitzerh
mitzerh / server-time.php
Created November 2, 2014 18:06
Current Time: Sample PHP server time
<?php
// sample script to return the server time in json output
header('Content-Type: application/json');
date_default_timezone_set('US/Eastern'); //server time zone
echo '{ "server": "' . date('m-d-Y H:i:s') . '" }';
?>
@mitzerh
mitzerh / script.js
Last active August 29, 2015 14:08
Current Time: Sample get server time
// sample - using a simple server timestamp; using jQuery JSON call
// Eastern Time
var REQ_ET = $.ajax({
url: "/dev/us-time/now/et.php",
dataType: "json",
cache: true
}).done(function(data){
window.CURRENT_TIME_ET = new CurrentTimer(new Date(data.server));
@mitzerh
mitzerh / fiddle.js
Created October 24, 2014 04:14
Query String Helper: Sample
var render = function(id, val) {
document.getElementById(id).innerHTML = val;
};
render("get-val-1", QueryParam.getVal("foo"));
render("get-all-1",
(function(){
@mitzerh
mitzerh / fiddle.js
Last active August 29, 2015 14:08
Query String Helper
var QueryParam = (function(){
var App = function() {
};
var Proto = App.prototype;
// get specific query param value
Proto.getVal = function(name) {
@mitzerh
mitzerh / fiddle.html
Created October 23, 2014 01:56
Countdown Timer
<div>dy : hr : mn : sec</div>
<div id="timer"></div>