Skip to content

Instantly share code, notes, and snippets.

View nitindhar7's full-sized avatar

Nitin Dhar nitindhar7

View GitHub Profile
@nitindhar7
nitindhar7 / gist:1708574
Created January 31, 2012 03:31
Fragment - creating a custom tab
// This converts the custom tab view we created and injects it into the tab widget
tab = inflater.inflate(R.layout.tab, getTabWidget(), false);
// Mainly used to set the weight on the tab so each is equally wide
tab.setLayoutParams(params);
// Add some text to the tab
label = (TextView) tab.findViewById(R.id.tabLabel);
label.setText("HOME");
// Show a thick line under the selected tab (there are many ways to show
// which tab is selected, I chose this)
divider = (TextView) tab.findViewById(R.id.tabSelectedDivider);
@nitindhar7
nitindhar7 / gist:1708580
Created January 31, 2012 03:31
Fragment - adding another tab (repeatitive)
// Add another tab
tab = inflater.inflate(R.layout.tab, getTabWidget(), false);
tab.setLayoutParams(params);
label = (TextView) tab.findViewById(R.id.tabLabel);
label.setText("USERS");
intent = new Intent(TabTutorialActivity.this, TabContentActivity.class);
intent.putExtra("content", "Content for USERS");
spec = tabHost.newTabSpec("users").setIndicator(tab).setContent(intent);
tabHost.addTab(spec);
@nitindhar7
nitindhar7 / gist:1708585
Created January 31, 2012 03:33
Fragment - getting fancy - detecting tab changes
// Listener to detect when a tab has changed. I added this just to show
// how you can change UI to emphasize the selected tab
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tag) {
// reset some styles
clearTabStyles();
View tabView = null;
// Use the "tag" for the tab spec to determine which tab is selected
if (tag.equals("home")) {
@nitindhar7
nitindhar7 / gist:2840586
Created May 31, 2012 02:36
Setting up a connection to RabbitMQ and declaring a queue.
ConnectionFactory factory = new ConnectionFactory();
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.queueDeclare("registered-users", false, false, false, null);
@nitindhar7
nitindhar7 / gist:2840599
Created May 31, 2012 02:38
Publishing a message to RabbitMQ
String message = "Hello World!";
channel.basicPublish("users", "registered-users", null, message.getBytes());
@nitindhar7
nitindhar7 / gist:2840604
Created May 31, 2012 02:38
Consuming messages in RabbitMQ
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume("registered-users", true, consumer);
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
String message = new String(delivery.getBody());
System.out.println(" [x] Received '" + message + "'");
}
@nitindhar7
nitindhar7 / gist:3850936
Created October 8, 2012 05:54
Turn and Zoom - basic
$("#widget").turnandzoom();
@nitindhar7
nitindhar7 / gist:3850941
Created October 8, 2012 05:56
Turn and Zoom - options
$("#widget").turnandzoom({
'width': 200,
'height': 200,
'slider': {
'height': 20
}
});
sudo apt-get install unixodbc unixodbc-dev unixodbc-bin
sudo apt-get install freetds-dev
sudo apt-get install tdsodbc
sudo gem install activerecord-sqlserver-adapter
sudo apt-get install sqsh
/etc/odbc.ini
/etc/odbcinst.ini
/etc/freetds/freetds.conf