Το blog μας, σας κρατάει ενήμερους για τα τελευταία νέα και εξελίξεις.

 

How to : unblock my own admin account on Drupal7

August 4, 2014 at 9:23 am | Drupal | No comment

 

Clear the flood table (if you experience the failure after 5 failed login attempts)

Add following code in your index.php after drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
/**
* Reset password
*/
require_once 'includes/password.inc';
echo user_hash_password('admin');
die();

Get the hash and paste in the password field in db.

add to delicious digg it add to reddit add to stumbleupon

 

Excel : Detecting Cell Edit Mode

July 11, 2014 at 7:10 am | Blog, Excel | No comment

 

The following code can be used to determine if Excel is in Edit Mode and also to get it out of Edit mode. The only call you need to make is exitEditMode(). If Excel is OK, nothing happens; however, if it is in edit mode, it pops it out so your automation code can continue.

[DllImport("User32.dll")]
public static extern Int32 SetForegroundWindow(int hWnd);

Excel.Application xlApp;
public Form1()
{
    InitializeComponent();
    xlApp = new Excel.Application();
    xlApp.Visible = true;
}

private void button1_Click(object sender, EventArgs e)
{
    exitEditMode(); // the only call you need to make
}

private void exitEditMode()
{
    if (!isExcelInteractive())
    {
        // get the current range
        Excel.Range r = xlApp.ActiveCell;
        // bring Excel to the foreground, with focus
        // and issue keys to exit the cell
        xlBringToFront();
        xlApp.ActiveWindow.Activate();
        SendKeys.Flush();
        SendKeys.Send("{ENTER}");
        // now make sure the original cell is
        // selected…
        r.Select();
    }
}

private bool isExcelInteractive()
{
    try
    {
        // this line does nothing if Excel is not
        // in edit mode. However, trying to set
        // this property while Excel is in edit
        // cell mdoe will cause an exception
        xlApp.Interactive = xlApp.Interactive;
        return true; // no exception, ecel is
                     // interactive
    }
    catch
    {
        return false; // in edit mode
    }
}

private void xlBringToFront()
{
    SetForegroundWindow(xlApp.Hwnd);
}

add to delicious digg it add to reddit add to stumbleupon

 

Drupal 7 How to load a teaser programatically

May 15, 2013 at 2:17 pm | Blog, Drupal | No comment

 

This worked for me in Drupal 7 (inside overridden theme template: page.tpl.php):

$body =field_get_items('node', $node, 'body');

$teaser= $body[0]['summary'];

In place of ‘summary’ you can also use ‘safe_summary’.

add to delicious digg it add to reddit add to stumbleupon

 

IIS 7.5 Express – Serving external traffic on Windows Server 2003

April 11, 2013 at 12:28 pm | .Net | No comment

 

Step 1 – Firewall

First you need to open your firewall to let through TCP connections on the local port(s) that you run IIS Express on, typically 8080.

Step 2 – Configure HTTP.SYS (requires elevation)

Secondly you have to configure HTTP.SYS to allow your application, running as a standard user, to listen to external traffic over the wire.

httpcfg set urlacl /u http://192.168.0.21:8080/ /a D:(A;;GX;;;WD)

Note: using "*" instead of full IP of your PC might won't work

To delete the above alaise use:httpcfg delete urlacl /u http://192.168.0.21:8080/

Step 3 – Modify applicationhost.config.

And last but not least you might be missing a binding information in applicationhost.config. You can find it in your user profile (%userprofile%\Documents\IISExpress\config\applicationhost.config). Next, you could either Locate your site under the <Sites> node. Since there are potentially a whole bunch of sites there you can find it by searching for the physical path in which all files for your site belongs. Now add a binding with your machine name:

<binding protocol="http" bindingInformation=":8080:192.168.0.21" />  <application path="/">        <virtualDirectory path="/" physicalPath="D:\folder\myapp" />  </application>  <bindings>       <binding protocol="http" bindingInformation=":8080:192.168.0.21" />  </bindings>

Also, you could copy the whole configuration file to you website physical directory and modify it in place.

Step 3 – Restart IIS Express.

Finally, don’t forget to restart IIS Express for this change to carry into effect.

 

Running IIS Express from the Command Line

  1. Open a command prompt.

    You do not need Administrator user rights to run the commands in this walkthrough. However, you must have Administrator user rights if you want to run IIS Express on ports numbered 1024 or less.

  2. Run the following command to navigate to the IIS Express installation folder:
    cd \Program Files\IIS Express

    or if you are using a 64-bit OS, run the following command:

    cd \Program Files (x86)\IIS Express
  3. Run the following command to view the IIS Express usage string:
    iisexpress /?
  4. Run your site using one of the following:
    • Use /config to run a site from a configuration file.

      See “Running your site from a configuration file” for more information.

    • Use /path to run a site from the application folder.

      See “Running your site from the application folder” for more information.

    Note: The /path option and the /config option cannot be combined.

    Running your site from a configuration file

    IIS Express and IIS use the ApplicationHost.config file, which specifies global settings for sites, application pools, handlers, etc. IIS Express uses a default, user-specific ApplicationHost.config file to allow many users to share the same computer without interfering with other user’s settings. This file is located in the %userprofile%\Documents\IISExpress\config folder or %userprofile%\My Documents\IISExpress\config folder, depending on your OS. When you run a site from a configuration file, you can specify which site to run.

    You can use the following commands:

    • To run the website Website1in the default configuration file, run:
      iisexpress /site:WebSite1
    • To run the first website in the default configuration file, run:
      iisexpress
    • To run the first website in a custom configuration file, run:
      iisexpress /config:c:\myconfig\applicationhost.config
    • To run a site called MyBlogfrom a custom configuration file, run:
      iisexpress /config:c:\myconfig\applicationhost.config /site:MyBlog

    Note: The /config option specifies the full path of the configuration file. You can omit this option if you want to use the default configuration file. The /site option specifies a particular site in the configuration file. You can omit this option to run the first site in the configuration file.

    Running your site from the application folder

    You can also use the /path option to run a site directly from a folder. This option works for any type of application, including static HTML, ASP.NET, PHP, and WCF. By default, IIS Express will run the site on http://localhost:8080/. For a managed website, such as ASP.NET, IIS Express will use .NET 4.0. You can use the /port and /clr options to override these default values.

    For example, the following command runs the specified application, “myapp,” on http://localhost:9090/ by using .NET 2.0:

    iisexpress /path:c:\myapp\ /port:9090 /clr:v2.0

add to delicious digg it add to reddit add to stumbleupon

 

Observablecollection to an XML file

February 18, 2013 at 8:15 am | .Net | No comment

 

Observable collection containing customer objects:

 public class Customer
  {
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Street { get; set; }
    public string Location { get; set; }
    public string ZipCode { get; set; }
  }

XML serialization :

ObservableCollection customers = new ObservableCollection();
...
XmlSerializer xs = new XmlSerializer(typeof(ObservableCollection));
using (StreamWriter wr = new StreamWriter("customers.xml"))
{
    xs.Serialize(wr, customers);
}

To reload the data from the file :

XmlSerializer xs = new XmlSerializer(typeof(ObservableCollection));
using (StreamReader rd = new StreamReader("customers.xml"))
{
    customers = xs.Deserialize(rd) as ObservableCollection;
}

add to delicious digg it add to reddit add to stumbleupon

 

Drupal 7:Pathauto patterns from menu structure hierarchy

February 17, 2013 at 8:16 am | Drupal | No comment

 

With recent version of Pathauto/Token:

[node:menu-link:parents:join-path]/[node:menu-link]

Or

[node:menu-link:parent:url:alias]/[node:menu-link]

add to delicious digg it add to reddit add to stumbleupon

 

Boot Windows 7 from USB hard disk

November 22, 2012 at 11:58 am | Blog | No comment

 

This article was written after trial and error from another article of the above title.

It seems that there is an ability of Win7 to boot directly from an external USB device which Microsoft set it to disabled by default.

reg.exe add HKLM\System\CurrentControlSet\Control /f /v BootDriverFlags /t REG_DWORD /d 0x6
reg.exe add HKLM\System\CurrentControlSet\Control\PnP /f /v PollBootPartitionTimeout /t REG_DWORD /d 30000

Read more…

add to delicious digg it add to reddit add to stumbleupon

 

Create a new CCK node in Drupal programatically

November 9, 2012 at 11:08 am | Blog, Drupal | No comment

 

Basics

First, if you have a general knowledge of a node structure, it would be much easier for you to create nodes by code. Read more…

add to delicious digg it add to reddit add to stumbleupon

 

Drupal 7, TinyMCE allow all attributes

October 29, 2012 at 9:14 pm | Drupal | No comment

 

Notice: This hack have security concerns.

Problem: TinyMCE strip custom attributes when Disable rich-text or saving node.

Solution : Create new module in sites/all/modules/MYMODULE

MYMODULE.module:

<?php
function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {

if ($context['profile']->editor == 'tinymce') {

$settings['extended_valid_elements'] .= 'form[action|accept|accept-charset|enctype|method|target]';
//OR
$settings['extended_valid_elements'] .= '*[*]'; //ACCEPT ALL ATRIBUTES
}
}
?>

MYMODULE.module:

name = TinyMCE tweaks

description = Allows TinyMCE to output form elements

package = MYMODULE

core = 7.x

version = 7.x-1.0

project = MY MODULE

add to delicious digg it add to reddit add to stumbleupon

 

Drupal 7 Metatags on Front Page

October 28, 2012 at 2:58 pm | Drupal | No comment

 

Suppose we are using a Drupal 7 metatag module to make our website SEO friendly.
This works very well for all pages except the front page.
Go to modules -> Meta tags -> Settings -> Global: Front page
Set the values for description, keywords etc.

Now in : page–front.tpl.php check to see if you render the $page[‘content’]. If not just put:

<?php
render($page['content'])
?>

And the all meta will be printed. Check the source code to verify the truth of the abov

add to delicious digg it add to reddit add to stumbleupon

 

Categories:

Archives: