Skip to content

Instantly share code, notes, and snippets.

// Creating a new Item
PlaylistItem pi = new PlaylistItem(mContext);
pi.title = "Discophrenia"
pi.desc = "This is a rather long description"
pi.author = "Brad Slyde"
if(pi.save){
// Saved successfully
}
else {
date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
date.to_formatted_s(:db) # => "2007-11-10"
date.to_s(:db) # => "2007-11-10"
date.to_formatted_s(:short) # => "10 Nov"
date.to_formatted_s(:long) # => "November 10, 2007"
date.to_formatted_s(:long_ordinal) # => "November 10th, 2007"
date.to_formatted_s(:rfc822) # => "10 Nov 2007"
<VirtualHost *:80>
ServerName www.yourhost.com
# be sure to point to 'public'!
DocumentRoot /somewhere/public
<Directory /somewhere/public>
# relax Apache security settings
# This step can achieved in a number of different steps
AllowOverride all
# MultiViews must be turned off
Options -MultiViews
package com.swan.helloworld;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@spp
spp / symfony_test.php
Created January 29, 2010 13:47
How to test your code snippets in Symfony
<?php
// These following lines load the project context
require_once(dirname(__FILE__).'/config/ProjectConfiguration.class.php');
// I use 'prod' all the time, and 'dev' only when something goes wrong
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
// Generally keep 'dev', I use 'prod' all the time, 'dev' only when something goes wrong
// If you want to test just the models and business logic:
// sfContext::createInstance($configuration);
// If you want to test URL helpers and other helpers that require controller context
sfContext::createInstance($configuration)->dispatch();
<?php
/*
Credit Card Validator
Date - Sep 04, 2009
Author - Brent Shaffer
ABOUT
>> wall "Changing the mysql root password, please bear. -Swanand"
Broadcast message from root (pts/3) (Sat Nov 21 12:53:50 2009):
Changing the mysql root password, please bear. Thanks, Swanand
>> wall "Done. Thanks for the patience. -Swanand"
Broadcast message from root (pts/3) (Sat Nov 21 12:54:44 2009):
Done. Thanks for the patience. -Swanand
>> Bitly.shorten "http://www.facebook.com/home.php"
=> "http://bit.ly/3B2w14"
>> Bitly.shorten "http://bit.ly/"
=> "http://bit.ly/"
@spp
spp / bitly.rb
Created November 11, 2009 11:55
# To change this template, choose Tools | Templates
# and open the template in the editor.
class Bitly < ActiveResource::Base
self.site = 'http://api.bit.ly'
self.user = 'USERNAME'
self.password = 'PASSWORD'
cattr_accessor :login, :return_format, :api_key, :bitly_version
class Array
def to_sentence(options = {})
# en-US: "One, Two, and Three" en-UK: "One, Two and Three"
options[:last_word_connector] ||= " and "
super
end
end