Zum Inhalt

Kategorie: Coding

ESP8266 Wifi Modul – Logging data to a server

While searching for something new overthere at banggood, I ordered some ESP8266 modules that are soldered to a dev board. The board is pretty awesome, has a solid quality and can be flashed without any trouble with a micro USB cable from your Arduino IDE. All you need to do is to follow some of the available tutorials on how to load the ESP Flash utility and you are ready to go. While I was looking for a new project, I decided to use the ESP8266 for something I ever wanted – a simple temperature logging device at my balcony. I started to read a lot of tutorials and choose an old friend as a temperature sensor – the DS18B20. These are available in a waterproof housing and with up to 3m cable, which is perfect for measuring temperature not in the near of the powersupply. DS18B20 basic working example As the DS18B20 arrived, I started to test it with my Arduino Nano, to check if the basics are working, before I start over with the ESP8266. First of all, I put a 4,7KOHM resistor between signal and vcc and connected it to pin 6. Everything works fine with this…

Weiterlesen ESP8266 Wifi Modul – Logging data to a server

PHP LDAP Pagination (Solution for PHP5.4+)

Because Active Directory restricts returning all results fetched by LDAP Query, I found a solution to get around this problem, without changing anything in Active Directory.

The root cause for this problem is: AD has a pagesize limit for returning elements through LDAP (default is 1000). As every good Admin / Dev knows, systemwide hardlimits should not be changed by a client system, which sends requests, because this could end up in hugh desaster. Why? Because everyone would set these limits as high as he can to prevent his software from crashing itself (better burn server cpu)

That means, we can’t set any pagelimit in PHP above the pagelimit from the server. What we need to do is to iterate through all results, check if there are more pages left and start another request until we fetched everything.

There are two functions we need to focus on. ldap_control_paged_result and ldap_control_paged_result_response

The first function enables the pagination for the current connection. The second function retrieves the information if more paged data is available (more than 1000 results). After we put everything together, we have something like that:

Weiterlesen PHP LDAP Pagination (Solution for PHP5.4+)

Drive Max7219/Max7221 with common anode displays

As you maybe already know, the max7219 and max7221 chips are serially interfaced (SPI) 8-bit LED drivers. These chips work perfect on 7 segment displays if they have common cathode pins, because they are designed for those display. If you have common cathode 7 segment display you get in touch with the benefit of these led drivers, because they handle the multiplexing in an easy way. They have built-in bcd decoder for easily displaying information and if you don’t want to use the decoder you can byte-wise set every digit of your display. For example, if you want to display the number „0“ without bcd decoding, you create the bit mask as follows:


The bit mask for number „0“ is: 0x0111111
To display this number you have to address (e.g.) digit1 and send your „number byte“ afterwards. That works perfectly.

Weiterlesen Drive Max7219/Max7221 with common anode displays

Powershell – Script automation with jobs (AD Quota)

After working a while with Powershell and doing some time expensive jobs like getting the quota of all Microsoft servers I came to the point when i was looking for some parallelisation in Powershell. My problem was the quota script, that executes the following command for each file server:

Actually we have a couple of servers and need to get the quota from all servers to calculate the file system usage and built a daily statistic. The first script collected the data from each server. Since this is a boring job, because reading a file stream and writing it to a local file is really boring, even for a computer. I wanted to accelerate this step. So i got in touch with Powershell and jobs. Jobs are (dont kill me) distantly related with multithreading in .NET. Indeed, multithreading in .NET has many more advantages and features than in powershell, but as a beginner (some years ago 🙂 ) in development i didn’t do anything more than just starting threads and wait until they are finished (Yep, invokation was a foreign concept to me). So this relation is not so far out. Anyway, jobs do a great job if you…

Weiterlesen Powershell – Script automation with jobs (AD Quota)

Powershell – Colorize string output with colorvariables in the output string

The other day I saw a script output that was colored with magenta. I was a bit impressed by the readability of the output messages. As I looked to the source code I saw something (ugly) like:

The output looked like: The Output is not so bad, but the effort is enormous. I came to the idea to encode the colorsettings within the output string. So I ended up with the following Script:

Now it’s possible to use a single string to encode the color by seperating each color with a hashtag (#). Here is an example: The syntax is very simple. Choose a color for the next characters and put it into hashtags (#). To stop coloring the characters just put another hashtag behind the colored characters to reset the foreground color to its default.

If you want to use any other charater, or command for the coloring, just replace the hashtag of the split function in line 20 with your character/command. I think this is a usefull function, because script output is often needed and coloring the important parts of the output is sometimes very helpful 🙂 Edit: I edited the script to work even…

Weiterlesen Powershell – Colorize string output with colorvariables in the output string

Powershell – Rename domain computer remotely (within an active directory domain as well)

I wanted to rename a couple of computers within our active directory. After some research i figured out thats it seems to be nearly impossible to rename a computer by just touching one object: the ad computer object, or the computer (client) itself. My first thought was „ok, you have to rename both objects, rejoin the computer and hope everything works“. But that’s no solution, that makes me happy, because the more steps you do, the more problems can occure. For examples, what happens if the computer has to reboot, after renaming to get correct rejoined? Do i have to create a local admin account at the clientside to have permissions after the computer lost his connection to ad? And so on… I played around, renamed the ad object, rebooted it – negative, the computer has to be joined again. After that i tried it the „bottom up“ way by renaming the computer by hand, and rebooted it instantly. While the computer was shutting down i noticed, that the computerobject in active directory was renamed before the computer was finished with its shutdown process. So i tried this several times and every time the ad computerobject was renamed properly. YAY!…

Weiterlesen Powershell – Rename domain computer remotely (within an active directory domain as well)

Powershell – SCCM – Readvertise a previously installed softwarepackage remotly (not from console)

Ever came to the situation, that you have to rerun an advertisement on a computer after a failed installation with SCCM? This could happen if you want to install flashplayer or adobe acrobat or some kind of software that is frequently used by the user. We had problems on installing software while wsus was installing its updates and the msi installer said „Hmm… perhaps, another installation is running already, so I cant do anything for you (BLAME!), sorry“. I hate this message, because its a pain in the ass to readvertise these failed softwarepackages on a single computer. As some posts earlier mentioned, I am writing an administration webapplication to administrate our environment. This includes softwaredeployment too. We address our softwarepackages by Active Directory groups. Every time we create a new softwarepackage, we create a seperate computer collection in SCCM and link it to a newly created ad group. Every member of this ad group (computers for instance) gets the linked software by SCCM. While it’s a bit difficult to get some automation into the readvertisement with all these groups and links, we wrote a script, that is triggered by my webgui and does this job on the client computer…

Weiterlesen Powershell – SCCM – Readvertise a previously installed softwarepackage remotly (not from console)

Active Directory – Supersonic and the directory searcher

Whats the difference between supersonic and the directory searcher? Nothing, because if you get over ~1000 you crash into a wall. 🙂 Last week we had to deal with the limitations on the directory searcher. We performed a user search on an organizational unit (subtree) with more than 1000 users beneath. We where astonished that our userobject only contained 1000 items every time we did the search. I wrote a little test script in powershell to reproduce this behaviour and to see if this limitation is a C# problem or not. So I wrote this script:

As expected, powershell returned only 1000 objects. Then we tried to find out why and looked at the $objSearcher property list.

As you can see, there are two interesting properties: sizelimit and pagesize. So I played around with these two properties and found some explanations for them. Sizelimit is the limit for the maximum returned results, but you can’t set this property above 1000. So I looked at the second property, pagesize. This property sets the maximum result items per returned page. So all you have to do is, set sizelimit to 0 and set pagesize to 1000 and you will get…

Weiterlesen Active Directory – Supersonic and the directory searcher

VB.NET – Enable Buttons in Applications with API calls

Every once in a while I stumble across some applications that have disabled control buttons without (for me) any reason. As a primary web developer I would like to have an easy way to enable these buttons. There exist some tools for firefox which you can enable buttons easily. For windows applications its a bit different. There are some win32 unlocker tools, but my virusscan doesn’t like those tools at all and I would like to learn how to do it on my own. I finally ended up with my IDE and some ideas on how to achieve this.
I found some tutorials on how to solve this problem with C#.net, but I haven’t installed C#.net on my box. I therefore tried to find a way to get through this with visual basic.net.

The Problem

There is a small, well known tool, that comes with Windows 7, that I use from time to time: The Calculator.
I like the windows calculator but my girlfriend mentioned that the „%“ button is disabled if you change the calculator from standard to scientific. For me, there is no reason why this button should be disabled, so I tried to find a way to enable it. Here we go.

Weiterlesen VB.NET – Enable Buttons in Applications with API calls

SCCM – SQL Query for Computer Information (statistics)

I am developing an administrative webgui to give our admins access to different services to manage their users and computers in our new Active Directory environment. We came across that this is the best solution to automate so many things like creating home folder, creating profile folder, creating terminalserver profile folder, set ACL to folders, create and publish printers to the AD, set quota for different kind of folders, distribute software via SCCM by AD groups and so on. It is necessary that every admin can only see objects that belong to his department. After developing all these base functionality we came to the conclusion that the information that is stored in the SCCM database is really informative for the admins, so we created some selects for the database to get the information about computerobjects, softwarestatus, hardwareinformation, etc…

Additional we thought it would be a great idea to build some kind of dashboard to get an overview over our environment and whats going on there, so we played around with the SQL Adminstudio and got some good looking SQL queries, implemented these and display the information in some pie charts (highcharts.com).
Weiterlesen SCCM – SQL Query for Computer Information (statistics)

YDRjRectangle – JQuery rectangle selection – new version

After some weeks of dealing with jquery and the rectangle function i released earlier i wrote a new and cleaner version, renamed it to YDRjRectangle and put it into a plugin like shape, so everyone can implement further functionality for selecting objects or do other customizing to fit its needs.

If you want to use a technique like click & drag/mouse move you should get the disabletextselect plugin from jdempster, to get rid of unwanted text selection while drawing your div rectangle.

Weiterlesen YDRjRectangle – JQuery rectangle selection – new version

Galleriffic and Colorbox – Quick Fix

I wrote a small web gallery application and used the galleriffic template as my base layout. I liked the image preloading and the image swap effect and didn’t want any other template for my gallery script, so I modified all the links to get a „german gallery“.
The only thing that I didn’t like was the „Show Original“ link beneath the image on the right side so I decided to use colorbox to spice it up a bit.

First of all you have to add the Colorbox javascript code to your webserver and add a link to the javascript file

Normally, if you click on the „Show Original“ link you get the image in the top left corner of your browser without any css/html styling and it looks some kind of rough to me for such a great layout, so I added all files of colorbox to my server, added the needed sourcecode and added a „rel=’cbviewer'“ tag to the „Show Original“ link and after some minutes of testing I recognized, that this link is finally broken and nothing happend, when clicking on it. Nothing comes up, no nice colorbox popup, no image in an empty browser window, nothing.

The first thing that I checked was the errorconsole of firefox and found an entry of colorbox that indicates some incompatibilities between the galleriffic javascript and colorbox.
I googled a bit and found a lot of fixes for this problem and the more i found they become bigger and more complex so I started to find a fix for this on my own. I wanted a small solution, 5 lines of code, or something to get colorbox working.

I had two ideas. The first one was a small fix to get the colorbox popup if I click the „Show Original“ link, without the ‚previous‘ and ’next‘ links in colorbox. The second idea I had was a link beside the „start slideshow“ to start a colorbox slideshow in fullscreen mode with the start position at the current gallery image. I started with the small fix for colorbox and will add a small tutorial for the fullscreen slideshow later.

Weiterlesen Galleriffic and Colorbox – Quick Fix