Skip to content

Instantly share code, notes, and snippets.

@brianyang
brianyang / shalom_ajax.js
Created September 8, 2011 18:21
Single Page Interface Implementation
// this function will load the main content from subsequent pages
function loadMain(e){
// define a reference to the href val
var targetVal = e.currentTarget.attributes[0].nodeValue;
// create wrapper elem if needed
if (!$('#wrap').length){
$('<div id=wrap />').insertAfter('header');
}
// prepare wrapper, pass href target from event obj
$('#wrap').empty().load(targetVal + ' #main', function(){
@brianyang
brianyang / gist:1211453
Created September 12, 2011 14:51
Twitter Stream - Front End
jQuery(function(){
// Execute this code when the page is ready to work
// Create a Script Tag
var script=document.createElement('script');
script.type='text/javascript';
script.src= "http://search.twitter.com/search.json?&q=%23Ogilvy&callback=processTheseTweets&_="+ new Date().getTime();
// Add the Script to the Body element, which will in turn load the script and run it.
$("body").append(script);
});
@brianyang
brianyang / ajaxFunc.js
Created September 13, 2011 16:14
rails backbone - rest api - ajax function
function getData(){
$.get('http://localhost:3000/posts.json');
}
function postData(){
var url ='http://localhost:3000/posts';
var data = {title:"asdf",content:"asdf"};
$.ajax({
type: "POST",
@brianyang
brianyang / jqueryui.htm
Created October 3, 2011 04:22
installing jQuery UI
<!doctype html>
<html>
<head>
<link href="/css/ui-lightness.css" />
<link href="/css/style.css" />
</head>
<body>
<div></div>
<script src="/js/jquery.js"></script>
<script src="/js/jqueryui.js"></script>
@brianyang
brianyang / hook_menu_alter.php
Created October 6, 2011 11:25
Drupal 7 - Implements hook_menu_alter()
/**
* Implements hook_menu_alter().
*
* Changing the page callback of a test page.
*/
function pages_menu_alter(&$items) {
$items['A&E']['page callback'] = 'a_and_e';
}
@brianyang
brianyang / node-and-npm-in-30-seconds.sh
Created December 1, 2011 21:03 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@brianyang
brianyang / .gitignore
Created December 9, 2011 03:48 — forked from sidwarkd/.gitignore
Very basic Node.js app using MongoLab and Heroku
node_modules
@brianyang
brianyang / demo file
Created December 10, 2011 00:55
node served with express on mongo in heroku
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, Mongolian = require("mongolian")
var app = module.exports = express.createServer();
@brianyang
brianyang / gist:1493617
Created December 18, 2011 14:50
copy source in file
cat ~/.ssh/id_rsa.pub | pbcopy
pbcopy <~/.ssh/id_rsa.pub
@brianyang
brianyang / gist:1493669
Created December 18, 2011 15:14
deploy an app on nodester & heroku
# deploy on nodester
nodester app create bysoft
nodester app init bysoft
# app deployed on bysoft.nodester.com
# deploy on heroku (incl package.json)