DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets

  • submit to reddit

Recent Snippets

                    public static T GetAppSetting<T>(string key, T defaultValue)
{
    if (!string.IsNullOrEmpty(key))
    {
        string value = ConfigurationManager.AppSettings[key];
        try
        {
            if (value != null)
            {
                var theType = typeof(T);
                if (theType.IsEnum)
                    return (T)Enum.Parse(theType, value.ToString(), true);

                return (T)Convert.ChangeType(value, theType);
            }

            return default(T);
        }
        catch { }
    }

    return defaultValue;
}                
                    public static int GetObjSize(Object obj)
        {
            try
            {
                string XmlString = string.Empty;
                MemoryStream MemStream = new MemoryStream();
                XmlSerializer Serializer = new XmlSerializer(obj.GetType());
                XmlTextWriter XmlText = new XmlTextWriter(MemStream, Encoding.Default);
                Serializer.Serialize(XmlText, obj);
                byte[] bytes = new byte[] { };
                bytes = MemStream.ToArray();
                XmlString = Encoding.Default.GetString(bytes, 0, bytes.Length);
                MemStream.Flush();
                MemStream.Close();
                XmlText.Flush();
                XmlText.Close();

                byte[] bytesobj = new byte[XmlString.Length * sizeof(char)];
                Buffer.BlockCopy(XmlString.ToCharArray(), 0, bytes, 0, bytes.Length);
                return bytesobj.Length;
            }
            catch (Exception e)
            {
                return -1;
            }
        }                
                    Look at the list of Scheduled Jobs: http://<base_url>/civicrm/admin/job?reset=1
Take note of the line labelled "API Action"
In your codebase, look at the file <civicrm_base>/api/v3/Job.php
Search for the function with the "API Action" line's name
The file you're looking for is in the require_once line, and the function name is the one called.                
                    Edit MembershipTypes: http://<base_url>/civicrm/admin/member/membershipType?reset=1&action=browse
For each MembershipType that should get a reminder, set the message to use, and the reminder days: http://<base_url>/civicrm/admin/member/membershipType?action=update&id=15&reset=1
Manually execute the Membership Reminder Date Processor: http://<base_url>/civicrm/admin/job?action=export&id=11&reset=1
Wait for the Scheduled Job "Membership status processor" to run: http://<base_url>/civicrm/admin/job?action=export&id=11&reset=1                
                    	function populateDropDown() {
	    
	    $.getJSON('/getData.aspx', { Name:$('#parm').val()}, function(data) {
	 
 	        var select = $('#DDLControl');
	        var options = select.attr('options');
	        $('option', select).remove();
	 
 	        $.each(data, function(index, array) {
	            options[options.length] = new Option(array['variety']);
	        });
	 
	    });
	 
	}
	 
	$(document).ready(function() {
	     
	    populateDropDown();
	    $('#DDLchangeData').change(function() {
	        populateDropDown();
	    });
	     
 	});                
                    <code>
declare str varchar2(128);
begin
str := null;
dbms_output.put_line('sample-1>>' || length(str)|| '<<');
 
str := '';
dbms_output.put_line('sample-2>>' || length(str)|| '<< !!!');
 
if length(str) = 0 then
  dbms_output.put_line('String length is 0'); 
else
  dbms_output.put_line('String length is undefined'); 
end if;
dbms_output.put_line
     ('Where as non-empty strings perform as excepted'); 
str := 'A';dbms_output.put_line( str || '>>' || length(str));
str := 'Beware of dealing with zerolenght strings in PL/SQL ';
dbms_output.put_line( str || '>>' || length(str)|| '<<');
end;
</code>
                
                        require 'grabzitclient'
     
    grabzItClient = GrabzItClient.new("YOUR APPLICATION KEY", "YOUR APPLICATION SECRET")
    grabzItClient.save_picture("http://www.google.com", "images/test.jpg")                
                    private static final String ALPHA_NUMERIC_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
public static String randomAlphaNumeric(int count) {
		StringBuilder builder = new StringBuilder();
		while (count-- != 0) {
			int character = (int)(Math.random()*ALPHA_NUMERIC_STRING.length());
			builder.append(ALPHA_NUMERIC_STRING.charAt(character));
		}
		return builder.toString();
}                
                    #!/bin/sh

ifconfig |sed -n '2p'|awk -F: '{print $2}'|awk '{print $1}'