This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is most concise I could get without compromising on speed. | |
const arr = [1, 5, 2, 2, 5, 5, 6, 6, 5, 6, 6, 2, 3, 3, 5, 3]; | |
let f = new Map(); | |
for (let i = 0; i < arr.length; i++) | |
f.set(arr[i], f.has(arr[i]) ? f.get(arr[i]) + 1 : 1); | |
let l = arr[0]; | |
for (let i = 1; i < arr.length; i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function timeSince(date) { | |
var seconds = Math.floor((new Date() - date) / 1000); | |
var interval = Math.floor(seconds / 31536000); | |
if (interval > 1) { | |
return interval + " years"; | |
} | |
interval = Math.floor(seconds / 2592000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Source : http://stackoverflow.com/questions/14069421/in-html5-how-to-show-preview-of-image-before-upload --> | |
<img id="uploadPreview" style="width: 100px; height: 100px;" /> | |
<input id="uploadImage" type="file" name="myPhoto" onchange="PreviewImage();" /> | |
<script type="text/javascript"> | |
function PreviewImage() { | |
var oFReader = new FileReader(); | |
oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function PopupCenter(url, title, w, h) { | |
// Fixes dual-screen position Most browsers Firefox | |
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left; | |
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top; | |
width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; | |
height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; | |
var left = ((width / 2) - (w / 2)) + dualScreenLeft; | |
var top = ((height / 2) - (h / 2)) + dualScreenTop; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
date("Y-m-d H:i:s") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
### Canonicalize codeigniter URLs | |
# If your default controller is something other than | |
# "welcome" you should probably change this | |
RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getXML($uri = NULL) | |
{ | |
$xml = simplexml_load_file($uri, "SimpleXMLElement", LIBXML_NOCDATA); | |
return $xml; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onkeypress="if ( isNaN( String.fromCharCode(event.keyCode) )) return false;" | |
Example Use : <input type="text" name="length" value="" class="form-control " placeholder="Video Duration (in seconds)" autocomplete="off" onkeypress="if ( isNaN( String.fromCharCode(event.keyCode) )) return false;"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var newWindow = window.open("","Test","width=300,height=300,scrollbars=1,resizable=1") | |
newWindow.document.open() | |
newWindow.document.write(responseText) | |
newWindow.document.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AJAX Loading Proccesor | |
$("#data-terminal-processor").bind("ajaxStart", function(){ | |
$(this).removeClass("icon-desktop").addClass("icon-refresh icon-spin");; | |
$("#display-teminal-header").hide(); | |
}).bind("ajaxStop", function(){ | |
$(this).removeClass("icon-refresh icon-spin").addClass("icon-desktop");; | |
$("#display-teminal-header").show(); | |
}); |