This file contains hidden or 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 save_image($inPath,$outPath) | |
{ //Download images from remote server | |
$in= fopen($inPath, "rb"); | |
$out= fopen($outPath, "wb"); | |
while ($chunk = fread($in,8192)) | |
{ | |
fwrite($out, $chunk, 8192); | |
} | |
fclose($in); | |
fclose($out); |
This file contains hidden or 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
<?php | |
$className = "TestObject"; | |
$objectIdToEdit = "EtgV2fqx5z"; | |
$url = 'https://api.parse.com/1/classes/' . $className . '/' . $objectIdToEdit; | |
$appId = 'yourApplicationIdHere'; | |
$restKey = 'yourRestAPIKeyHere'; |
This file contains hidden or 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
//load my Parse.com Class called "parts" | |
var Part = Parse.Object.extend("parts", { | |
//save the data back to parse.com when it changes | |
initialize: function() { | |
Parse.Object.prototype.initialize.apply(this,arguments); this.on("change", function (model,options) { | |
if (options && options.save === false) return; | |
model.save() | |
}); | |
} | |
}); |
This file contains hidden or 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 url = 'http://www.hobbyking.com/hobbyking/store/__55571__Quanum_Venture_FPV_QuadCopter_With_Power_System_ARF_Version_.html'; | |
var numbers = url.replace(/[\D]/g, ''); | |
console.log('http://www.hobbyking.com/hobbyking/store/uh_viewitem.asp?idproduct=' + numbers + '&aff=1588958'); |
This file contains hidden or 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 images = document.images; | |
for (var i=0; i<images.length; i++){ | |
console.log(images[i].src); | |
} |
This file contains hidden or 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 getFileName() { | |
//this gets the full url | |
var url = document.location.href; | |
//this removes the anchor at the end, if there is one | |
url = url.substring(0, (url.indexOf("#") == -1) ? url.length : url.indexOf("#")); | |
//this removes the query after the file name, if there is one | |
url = url.substring(0, (url.indexOf("?") == -1) ? url.length : url.indexOf("?")); | |
//this removes everything before the last slash in the path | |
url = url.substring(url.lastIndexOf("/") + 1, url.length); | |
//return |
This file contains hidden or 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
//original: http://snook.ca/archives/javascript/simplest-jquery-slideshow | |
$(function(){ | |
$('.fadein img:gt(0)').hide(); | |
setInterval(function(){ | |
$('.fadein :first-child').fadeOut() | |
.next('img').fadeIn() | |
.end().appendTo('.fadein');}, | |
3000); | |
}); |
This file contains hidden or 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
$(document).on('click','.navbar-collapse.in',function(e) { | |
if( $(e.target).is('a') ) { | |
$(this).collapse('hide'); | |
} | |
}); |
This file contains hidden or 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
if (!document.getElementsByClassName) { | |
document.getElementsByClassName = function(search) { | |
var d = document, elements, pattern, i, results = []; | |
if (d.querySelectorAll) { // IE8 | |
return d.querySelectorAll("." + search); | |
} | |
if (d.evaluate) { // IE6, IE7 | |
pattern = ".//*[contains(concat(' ', @class, ' '), ' " + search + " ')]"; | |
elements = d.evaluate(pattern, d, null, 0, null); | |
while ((i = elements.iterateNext())) { |
This file contains hidden or 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
// node: | |
var moment = require('moment'); | |
moment().add('days', 2).fromNow(); | |
// 'in 2 days' | |
moment().subtract('days', 2).fromNow(); | |
// '2 days ago' | |
moment('November 1977').fromNow() |
NewerOlder