Skip to content

Instantly share code, notes, and snippets.

View arttuladhar's full-sized avatar

Aayush Tuladhar arttuladhar

View GitHub Profile
@arttuladhar
arttuladhar / sysreport
Created September 14, 2011 16:01
Generates System Report of the Local Machine
#!/bin/bash
# Description: Linux System Information Report in HTML format
# Version 2.0
# Useage: sysreport > /var/www/html/report.html
# License: BSD
# Author: Greg Ippolito
cat << HEAD
<HTML>
<HEAD><TITLE>System Report</TITLE></HEAD>
@arttuladhar
arttuladhar / ubuntucleaner.sh
Created September 25, 2011 19:18
Routine Ubuntu Cleanup
#!/bin/bash
OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
YELLOW="\033[1;33m"
RED="\033[0;31m"
ENDCOLOR="\033[0m"
@arttuladhar
arttuladhar / Delegates_Multicast.cs
Created January 13, 2012 05:45
Multicast Deligate - It is a delegate which holds the reference of more than one method.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
delegate void Delegate_Multicase(int x, int y);
@arttuladhar
arttuladhar / printenv.pl
Created January 13, 2012 16:11
Examine and alter environment variables through %ENV
#!/usr/bin/perl
foreach $key ( sort keys(%ENV) ) {
print "$key==>$ENV{$key}\n";
}
@arttuladhar
arttuladhar / valid.cs
Created January 13, 2012 16:33
This way of instanciating a class is totally valid in C# 3.0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
public class Person{
@arttuladhar
arttuladhar / test.cs
Created January 13, 2012 16:53
Guess the Output
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
@arttuladhar
arttuladhar / rfid.c
Created January 28, 2012 17:13
Gets Data from RFID Reader
#include <18F4455.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
#rom int 0xf00000={1,2,3,4}
#include <usb_cdc.h>
#include <usb_bootloader.h>
#include <lcd.c> //This LCD will e changed to <lcd420.c>
#include <kbd.c>
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, stream=RFID)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_B7, stream=XBEE)
@arttuladhar
arttuladhar / Main.java
Created December 16, 2012 19:02
JMX 101
package com.aayush.tutorial;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
@arttuladhar
arttuladhar / MyConnectionPool.java
Created December 21, 2012 05:01
Java Connection Pooling using Commons Library
package helper;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@arttuladhar
arttuladhar / HangMan.java
Created December 29, 2012 19:42
SignOn features using Google Web Services is easy and efficient way to authenticate users. It's pretty common these days to have authentication via Google UserServices. Google App Engine provides UserServiceFactory api for this purpose. I tried implementing this API within Google Web Toolkit and here's the code snippet for reference. The code is…
package com.aayush.hangman.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;