CategoryProgramming

WordPress plugin to disable the WP Admin Bar (hidewpbar)

Working on a membership site, we have to create multiple level of users. Usually we do not want the users to have access to the WP-Admin panel because it is not customized for their experience. Rather we have put everything necessary (such as edit profile page), user dashboard etc, on the front-end. For that reason we have to disable the WP Admin Bar for all except the administrators ( hidewpbar...

Linux Makefile for applications and shared libraries

Makefiles are a simple way to organize code compilation. Make is a Unix tool to simplify building program executables from many modules. make reads in rules (specified as a list of target entries) from a user created Makefile. make will only re-build things that need to be re-built (object or executables that depend on files that have been modified since the last time the objects or executables...

C# Registry Keys Manager

Usually an application needs to save or retrieve data from windows registry. For this reason a registry manager class is required. The following code snippet provides a simple yet effective way for handling windows registry keys. public class Manager { public void addRegistry(string subkey, string name, string value) { if (Microsoft.Win32.Registry.GetValue(@""+subkey, name, null) == null) {...

Capturing screenshots using C#

What is the right way to take screenshots using C#? It’s certainly possible to grab a screenshot using the .NET Framework. The following code snippet provides a C# class for capturing and saving screenshots. public class Screenshot { public DateTime timestamp; public Bitmap bitmap; public Screenshot(DateTime timestamp, Bitmap bitmap) { this.timestamp = timestamp; this.bitmap = bitmap; } }...

Calling a method from a string in C# (dynamic method invocation)

We are often used to call methods dynamically. You can invoke methods of a class instance using reflection, doing a dynamic method invocation. The following code snipped presents an easy way of invocation in C#. public void Execute(string methodName, object[] args) { if (GetType().GetMethod(methodName)) != null) { MethodInfo method = GetType().GetMethod(methodName); method.Invoke(this, new...

Better way to convert any number to C string

In the previous version of number to C string converter, we could only convert integer numbers. Even if it was faster, sometimes it is crucial to use floating point numbers in our projects. This version of num_to_string function provides conversion of both positive and negative numbers as well as floating point numbers. const char * num_to_string( double value ) { char * result; double...

Using Sockets with C++

Linux sockets are always a useful tool for an application. In the simplest terms, a socket is a pseudo-file that represents a network connection. Once a socket has been created (using the proper primitives, and the proper parameters to identify the other host), writes to the socket are turned into network packets that get sent out, and data received from the network can be read from the socket...

Using a Simple Linked List as Queue in C

Simple data structures such as linked lists are almost always required in programming. The following code snippets provide the most basic functions for for using simple linked list as a queue in C programming language: Insert Item Remove Item (Please check also: Using a Simple Linked List as Stack in C) Insert Function (Example 1) struct node_t * insert_1(struct node_t * head, struct...

Using a Simple Linked List as Stack in C

The following code snippets are some useful functions for using a simple linked list as a stack in C programming language. (Please check also: Using a Simple Linked List as Queue in C) struct node_t * push_1(struct node_t * head, struct node_t * node) { node->next = head; return node; } // Example : 2 void push_2(struct node_t ** head, struct node_t * node) { node->next = *head; *head = node; }...

Reverse a Simple Linked List in C

Some more advanced functions for simple linked lists such as reserving could be a good reference. The following code snippet is a simple function for reversing a simple linked list. Please check also Using a Simple Linked List as Stack in C Using a Simple Linked List as Queue in C struct node_t * reverse(struct node_t * head) { struct node_t * temp = head; struct node_t * new_head =...

Disclaimer: The present content may not be used for training artificial intelligence or machine learning algorithms. All other uses, including search, entertainment, and commercial use, are permitted.

Categories

Tags