Skip to content

Instantly share code, notes, and snippets.

@krutz27
krutz27 / 0_reuse_code.js
Created September 25, 2013 22:28
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@krutz27
krutz27 / rss_feed_reader_PHP
Created September 25, 2013 22:29
reads RSS feed
<?php
//get the q parameter from URL
$q=$_GET["q"];
//find out which feed was selected
if($q=="Google")
{
$xml=("http://news.google.com/news?ned=us&topic=h&output=rss");
}
elseif($q=="MSNBC")
jQuery(document).ready(function($){
$("h3").each(function(){
if ($(this).text().length > 30) {
$(this).text($(this).text().substr(0, 27));
$(this).append('...');
}
});
});
var newDiv = $('<div></div>');
newDiv.attr("id","myNewDiv").appendTo("body");
jQuery(function () {
jQuery(":contains(FIND)").not(":has(:contains(FIND))").each(function () {
var that = $(this),
html = that.html();
html = html.replace(/(\(FIND:.*?\))/g, "REPLACE-WITH");
that.html(html);
});
});
$('<div id="overlay"></div>')
.css({
position : 'fixed',
top : 0,
left : 0,
right : 0,
bottom : 0,
opacity : 0.6,
background : 'black',
display : 'none'
var object =
{
a:10;
b:20;
s:'hello'
};
$.each(object, function(name, value)
var truck = function() {
this.turnLeft = function {
// turn left
return this;
}
this.turnRight = function {
jQuery(function () {
jQuery('#select_ID').change(function () {
var selected = $(this).find(':selected').val();
jQuery(".item_to_hide").hide();
jQuery('#' + selected).show();
}).change();
});
//jQuery version
jQuery.inArray("value", arr); // Usage: if( jQuery.inArray("value", arr) != -1 ) { true };
//Javascript version
Array.prototype.inArray = function (value) {
var i;
for (i=0; i < this.length; i++) {
if (this[i] === value) {
return true;
}