text:
package org.imazlwifu.uds;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.Set;

import org.imazlwifu.uds.model.Monitorable;

import android.app.Activity;
import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;
import android.util.Log;

/**
 * Controller class created by LibConfig
 *
 * @author Sascha Eiteneuer
 *
 */
public class UDS {
	final public static String ACTION_ALARM = "com.company.android.AlarmReceiver";
	final public static String ACTION_DATA_BROADCAST = "org.imazlwifu.uds.DataBroadcast";
	final public static String ACTION_START_SERVICE = "org.imazlwifu.uds.StartService";
	final public static String ACTION_STOP_SERVICE = "org.imazlwifu.uds.StopService";
	final public static String EXTRA_INTERVAL = "interval";
	final public static int DEFAULT_INTERVAL = 10;

	private LibConfig config;
	private Context context;

	UDS( LibConfig config ) {
		this.config = config;
		this.context = config.getApplicationContext();
	}

	public void startService() {
		if( LibConfig.instance.getMonitorables( true ).size() < 1 )
			Util.shortToast( context, "Nothing to monitor\nService not started\nvisit settings" );
		else {
			Log.d( "UDS", "starting service" );

			Intent i = new Intent( ACTION_START_SERVICE );
			i.putExtra( EXTRA_INTERVAL, config.getMonitoringInterval() );

			context.sendBroadcast( i );
		}
	}

	public void stopService() {
		Log.d( "UDS", "stopping service" );

		context.sendBroadcast( new Intent( ACTION_STOP_SERVICE ) );
	}

	public void startPreferenceActivity( Activity callingActivity ) {
		callingActivity.startActivityForResult( new Intent( callingActivity, PreferencesActivity.class ), 0 );
	}

	/**
	 * makes all on the device available sensors accessable for monitoring
	 */
	public void putMonitoredSensors() {
		SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences( context );
		Editor e = sp.edit();
		e.putBoolean( "useDefaults", true );
		e.commit();

		config.setupMonitorables( sp );
	}

	/**
	 * makes parameter class available for monitoring
	 */
	public void putCustomMonitorable( Class<?> c ) {
		// preventing multiple creation
		for( String name : PreferenceManager.getDefaultSharedPreferences( context ).getAll().keySet() )
			if( name.equals( c.getName() ) ) {
				Log.d( "UDS", ""+c.getName()+" already in existance" );
				return;
			}

		putCustomMonitorable( PreferenceManager.getDefaultSharedPreferences( context ), c.getName(), true );
	}

	// package protected
	void putCustomMonitorable( SharedPreferences pref, String name, boolean monitoring ) {
		Log.d( "UDS", "creating "+ name );

		Monitorable m;
		try {
			@SuppressWarnings("unchecked")
			Class<Monitorable> c = (Class<Monitorable>) Class.forName( name );
			Constructor<Monitorable> ctor = c.getConstructor( Context.class );
			m = ctor.newInstance( context );

			getBindings().put( m, monitoring );

			Editor e = pref.edit();
			e.putBoolean( name, monitoring );
			e.commit();
		} catch( ClassNotFoundException e ) {
			Log.d( "", "Error while putting custom monitorable. No class found matching "+ name +"\nStack Trace: " );
			e.printStackTrace();
		} catch (NoSuchMethodException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (IllegalArgumentException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (InstantiationException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (IllegalAccessException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (InvocationTargetException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}

	// package protected
	void putDefaultMonitorable( Monitorable key, boolean value ) {
			getBindings().put( key, value );

			SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences( context );
			Editor e = sp.edit();
			e.putBoolean( key.getName(), value );
			e.commit();
	}

	protected Notification updateNotification( int iteration ) {
		// TODO Auto-generated method stub
		return null;
	}

	private Set<Monitorable> getMonitorables() {
		return config.getMonitorables();
	}

	private Map<Monitorable, Boolean> getBindings() {
		return config.getBindings();
	}

	public void setMonitoringInterval( int monitoringInterval ) {
		config.setMonitoringInterval( monitoringInterval );
	}

	public int getMonitoringInterval() {
		return config.getMonitoringInterval();
	}

	/** debug TODO delete? */
	public String getDebugString() {
		StringBuilder b = new StringBuilder();

		b.append("State " + this + " {\n");

		for( Monitorable m : getMonitorables() )
			if( getBindings().get(m) ) {
				String s = "unknown";
				if (m.values() != null)
					s = m.values().values().toString();

				b.append("    " + m.getName() + ": " + s + "\n");
			}
		b.append("}");

		return b.toString();
	}

	public boolean isEnabled(Monitorable m) {
		return config.getMonitorable( m );
	}
}


text:
// Copyright 2007-2012 Chris Patterson, Dru Sellers, Travis Smith, et. al.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.

using Burrows.Configuration;
using Burrows.Configuration.BusConfigurators;
using Burrows.Configuration.EndpointConfigurators;
using Burrows.Endpoints;
using Burrows.Pipeline;
using Burrows.Transports.Rabbit;

namespace Burrows.Transports.Configuration.Extensions
{
    using System;
    using Configurators;
    using Magnum.Extensions;
    using Pipeline.Configuration;

    public static class TransportServiceBusExtensions
    {
        /// <summary>
        /// Returns the endpoint for the specified message type using the default
        /// exchange/queue convention for naming
        /// </summary>
        /// <typeparam name="TMessage">The message type to convert to a URI</typeparam>
        /// <param name="bus">The bus instance used to resolve the endpoint</param>
        /// <returns>The IEndpoint instance, resolved from the service bus</returns>
        public static IEndpoint GetEndpoint<TMessage>(this IServiceBus bus)
            where TMessage : class
        {
            return GetEndpoint(bus, typeof(TMessage));
        }

        /// <summary>
        /// Returns the endpoint for the specified message type using the default
        /// exchange/queue convention for naming.
        ///
        /// TODO: FIX!!!
        ///
        /// </summary>
        /// <param name="bus">The bus instance used to resolve the endpoint</param>
        /// <param name="messageType">The message type to convert to a URI</param>
        /// <returns>The IEndpoint instance, resolved from the service bus</returns>
        public static IEndpoint GetEndpoint(this IServiceBus bus, Type messageType)
        {
            var inboundTransport = bus.Endpoint.InboundTransport as InboundRabbitTransport;
            if (inboundTransport == null)
            {
                throw new ArgumentException(
                    "The bus must be receiving from a RabbitMQ endpoint to convert message types to endpoints.");
            }

            var inputAddress = inboundTransport.Address.CastAs<IRabbitEndpointAddress>();

            IMessageNameFormatter messageNameFormatter = inboundTransport.MessageNameFormatter;

            MessageName messageName = messageNameFormatter.GetMessageName(messageType);

            IEndpointAddress address = inputAddress.ForQueue(messageName.ToString());

            return bus.GetEndpoint(address.Uri);
        }

        /// <summary>
        /// <see cref="UseRabbitMq{T}(T,Action{ITransportFactoryConfigurator})"/>
        /// </summary>
        public static void UseRabbitMq(this IEndpointFactoryConfigurator configurator)
        {
            UseRabbitMq(configurator, x => { });
        }

        /// <summary>
        /// <para>This method specifies that the service bus under configuration is to
        /// use RabbitMQ for message queueing. See http://readthedocs.org/docs/masstransit/en/latest/configuration/transports/rabbitmq.html.
        /// This method also calls <see cref="SerializerConfigurationExtensions.UseJsonSerializer{T}"/>.</para>
        ///
        /// </summary>
        /// <typeparam name="T">configurator type param</typeparam>
        /// <param name="configurator">configurator instance</param>
        /// <param name="configureFactory">custom action used to call APIs on the configurator</param>
        /// <returns>the configurator instance</returns>
        public static void UseRabbitMq(this IEndpointFactoryConfigurator configurator,
            Action<ITransportFactoryConfigurator> configureFactory)
        {
            var transportFactoryConfigurator = new TransportFactoryConfigurator();

            configureFactory(transportFactoryConfigurator);

            configurator.AddTransportFactory(transportFactoryConfigurator.Build);

            configurator.UseJsonSerializer();
        }

        /// <summary>
        /// Specifies that RabbitMQ should be added as a transport for the service bus.
        /// </summary>
        /// <param name="configurator"></param>
        /// <returns></returns>
        public static IServiceBusConfigurator UseRabbitMq(this IServiceBusConfigurator configurator)
        {
            return UseRabbitMq(configurator, x => { });
        }

        /// <summary>
        /// Specifies that RabbitMQ should be added as a transport for the service bus. Includes a callback
        /// that can configure additional settings on the transport, such as SSL.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="configureFactory"></param>
        /// <returns></returns>
        public static IServiceBusConfigurator UseRabbitMq(this IServiceBusConfigurator configurator,
            Action<ITransportFactoryConfigurator> configureFactory)
        {
            configurator.SetSubscriptionObserver((bus, coordinator) => new RabbitSubscriptionBinder(bus));

            var busConfigurator = new PostCreateBusBuilderConfigurator(bus =>
                {
                    var interceptorConfigurator = new OutboundMessageInterceptorConfigurator(bus.OutboundPipeline);

                    // make sure we publish correctly through this interceptor; works on the outgoing pipeline
                    interceptorConfigurator.Create(new PublishEndpointInterceptor(bus));
                });

            configurator.AddBusConfigurator(busConfigurator);

            UseRabbitMq((IEndpointFactoryConfigurator)configurator, configureFactory);

            return configurator;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
<!doctype html>

		<meta charset="UTF-8">
		<title>@yield('title')</title>
		<link rel="stylesheet" type="text/css" href="{{ wardrobe_url('/') }}css/bootstrap.css">
		<link rel="stylesheet" type="text/css" href="{{ wardrobe_url('/') }}css/style.css">
		<link rel="stylesheet" type="text/css" href="{{ wardrobe_url('/') }}css/animate.css">
		<link rel="stylesheet" type="text/css" href="{{ wardrobe_url('/') }}css/hover.css">

		      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
		        Toggle navigation

		      </button>

HOME (current)

BLOG

ACHIEVEMENT

PORTOFOLIO

EVENT

			@yield('content')

 Himpunan Mahasiswa Informatika ITB

 Jl. Ganesha No. 10, Bandung 40135


text:
package ee.jiss.commons.reflect;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target(FIELD)
@Retention(RUNTIME)
@Documented
public @interface Editable {

}


text:
from __future__ import division, print_function
import numpy as np

#
#
#
def dipole_ni(me, sp1, R1, sp2, R2, **kvargs):
    """
      Computes overlap for an atom pair. The atom pair is given by a pair of species indices
      and the coordinates of the atoms.
      Args:
        sp1,sp2 : specie indices, and
        R1,R2 :   respective coordinates in Bohr, atomic units
      Result:
        matrix of orbital overlaps
      The procedure uses the numerical integration in coordinate space.
    """
    from pyscf.nao.m_ao_matelem import build_3dgrid
    from pyscf.nao.m_ao_eval_libnao import ao_eval_libnao as ao_eval

    grids = build_3dgrid(me, sp1, R1, sp2, R2, **kvargs)

    ao1 = ao_eval(me.ao1, R1, sp1, grids.coords)
    ao1 = ao1 * grids.weights
    ko1 = np.einsum('ik,oi->koi', grids.coords, ao1)
    ao2 = ao_eval(me.ao1, R2, sp2, grids.coords)
    koo2dip = np.einsum("koi,pi->kop", ko1, ao2)

    return koo2dip