Skip to content

Instantly share code, notes, and snippets.

@jafstar
jafstar / explodeJS.js
Created May 18, 2012 07:28
Javascript explode() equivalent
console.log('searchVal split = ' + searchVal.split(' '));
var searchValArray = searchVal.split(' ');//.slice(1,-1);
console.log("SEARCH Array: " + searchValArray + "......");
var searchString = "";
for(var i in searchValArray){
searchString += String(searchValArray[i] + "+");
}
@jafstar
jafstar / reverseJSON.js
Created April 25, 2012 09:06
Reverse JSON
//FROM http://developer.appcelerator.com/question/115941/-parsing-xml-in-reverse-order
for (var i = json.length - 1; i >= 0; i--)
{
doSomething(json[i].name, json[i].msg);
}
@jafstar
jafstar / upload.js
Created April 18, 2012 15:02
Appcelerator + Cloudinary + Image Upload
//CREATE WINDOW
var win = Ti.UI.createWindow({
title: 'Upload',
backgroundColor: '#FFF',
fullscreen: true,
navBarHidden: true
});
//PHOTO VIEW CONTAINER
@jafstar
jafstar / trim.js
Created April 12, 2012 18:15
Javascript Trim Strings
/*** FROM http://www.somacon.com/p355.php ***/
//BOTH
function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g,"");
}
//LEFT
function ltrim(stringToTrim) {
@jafstar
jafstar / objects.js
Created January 29, 2012 05:14
Multiplayer Objects - Auto vs Jump
//AUTO
if(player.y >= floor_base - 20 && player.x <= 2680 && player.x >= 2070){
floor_y = floor_base - 20;
player.y = floor_base - 20;
}
//JUMP
if( player.y == floor_base - 20 && player.x <= 700 && player.x >= 400){
floor_y = floor_base - 20;
player.y = floor_base - 20;
@jafstar
jafstar / optout.txt
Created January 27, 2012 09:06
People Finder Opt Out
http://www.peoplesmart.com/optout
http://www.peoplefinders.com/optout-form.pdf
http://www.spokeo.com/privacy
https://www.intelius.com/optout.php
@jafstar
jafstar / FancyRadioBtn.html
Created January 4, 2012 18:55
Fancy Radio Button
<html>
<head>
<title>Fancy Radio Button</title>
</head>
<body>
<form action='some.php'>
<label for="employed1" >Are you currently employed?</label>
<br />
@jafstar
jafstar / playlist.jade
Created December 23, 2011 09:04
SoundCloud XML
playlist
each item, i in stack
<node URL = "#{item[1]}" PIC = "#{item[2]}" TITLE = "#{item[0]}" />
@jafstar
jafstar / playlist.js
Created December 23, 2011 09:03
Node + SoundCloud = XML Playlist
//MUSIC
app.get('/playlist', function(req, res){
var artist = "artistName";
var key = "1234567yourKeyHere";
var url = "http://api.soundcloud.com/users/" + artist + "/tracks.json?consumer_key=" + key;
var response = [];
var options = {
@jafstar
jafstar / app.js
Created December 19, 2011 05:06
Formidable + CloudMailin
//MSG
app.post('/msg', function(req, res){
if (req.url == '/msg') {
var form = new formidable.IncomingForm(),
fields = [];
form.on('error', function(err) {
res.writeHead(200, {'content-type': 'text/plain'});
res.end('error:\n\n'+util.inspect(err));