Thursday, December 22, 2016

`` Debian init script

Startup init script for the Distributed WPA PSK strength auditor python script

Turning the `` utility into a system daemon can be achieved by utilizing the `screen` utility, below is my first attempt at it - feel free to comment with improvements or questions.

# Provides:
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.

# Symbolic link this file into your `/etc/init.d`, then run `rcconf` and select the script to start, note the file name must be alphanumeric only
# example: `root@sh1:/etc/init.d# ln -s /usr/local/ help_crack`

cmd="screen -d -m -S ./"
# Provides:
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.

# Symbolic link this file into your `/etc/init.d`, then run `rcconf` and select the script to start, note the file name must be alphanumeric only
# example: `root@sh1:/etc/init.d# ln -s /usr/local/ help_crack`

cmd="screen -d -m -S ./"

name=`basename $0`

get_pid() {
        cat "$pid_file"

is_running() {
    [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1

case "$1" in
    if is_running; then
        echo "Already started"
        echo "Starting $name"
        cd "$dir"
        if [ -z "$user" ]; then
            #sudo $cmd >> "$stdout_log" 2>> "$stderr_log" & # start it in the background which we don't want so that we can get the right PID
            sudo $cmd >> "$stdout_log" 2>> "$stderr_log"
            # sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" & # start it in the background which we don't want so that we can get the right PID
            sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log"
        #echo $! > "$pid_file"
        # IMPRV: make the session name a variable or extract it from the `cmd`
        screen -ls | grep -Po '(?<=\t)(\d+)(?' > "$pid_file"
        if ! is_running; then
            echo "Unable to start, see $stdout_log and $stderr_log"
            exit 1

        echo "Started, you can reconnect by typing \`screen -r `get_pid`\`"

    if is_running; then
        echo -n "Stopping $name.."
        # killin Screen PID is not enough, so we gather all children and kill them too
        #echo "current_pid=$current_pid"
        while [ -n "$current_pid" ] # if not empty execute loop
          pids_to_kill="$current_pid $pids_to_kill"
          current_pid=`pgrep -P $current_pid`
        #echo $pids_to_kill
        kill $pids_to_kill
        for i in {1..10}
            if ! is_running; then

            echo -n "."
            sleep 1

        if is_running; then
            echo "Not stopped; may still be shutting down or shutdown may have failed"
            exit 1
            echo "Stopped"
            if [ -f "$pid_file" ]; then
                rm "$pid_file"
        echo "Not running"
    $0 stop
    if is_running; then
        echo "Unable to stop, will not attempt to start"
        exit 1
    $0 start
    if is_running; then
        echo "Running, you can reconnect by typing \`screen -r `get_pid`\`"
        echo "Stopped"
        exit 1
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1

exit 0

Thursday, December 8, 2016

Lightning Out off Platform Example

Due to the limited documentation out there for the BETA Lightning Out functionality I am posting my code for others to benefit.

Please note that after extensive research I have come to the conclusion that off platform functionality is broken, but executing the code from within a naked VF page should work. The issue is that the bootstrapping process does not adjust the URLs for the dynamically loaded scripts and styles sheets - the JS assumes it is still run from within a SF org domain. A case with SF has been filled but if I am incorrect on my conclusion please comment.

Even if one patches the script/style URLs loading at runtime further errors manifest from withing aura_prod.js

Salesforce's 'Lighting Out' Example

Prior to using the below code ensure you have wrapped your lighting component into an App, setup a connected App, and CORS whitelisted your domain - afterwards copy and paste the below into your HTML file to be served from a server.

<div id='lightning'></div>
<script src=""></script>
<script src="https://<REMOVED>"></script>
sAccessToken = location.hash.match(/access_token=([^&]*)/) ? location.hash.match(/access_token=([^d]*)/)[1] : null;
sInstanceURL = location.hash.match(/instance_url=([^&]*)/) ? decodeURIComponent(location.hash.match(/instance_url=([^&]*)/)[1]) : null;
if (sAccessToken ==  null) {
  window.location.href = '<YOUR CONNECTED APP'S SECRET KEY>&redirect_uri=https://localhost'
  ,function() {
        ComponentHeading: 'Header',
      ,function(cmp) {
        //do some stuff

Thursday, December 1, 2016

Windows Error: "Source Path Too Long"

Unable to delete folder due to 'path too long' error

Windows dinosaur 256(?) path limitation weirdness prevented me from deleting a backup recovery folder, the solution to that is to use a utility called Unlocker - it also allows deletion/moving of locked files. If you found this useful feel free to follow me on twitter @danielsokolows or comment, also do donate the author of the program.

Sunday, November 20, 2016

Softeher 'Error occurred. (Error code: 2)' sollution

Protocol error occurred. Error was returned from the destination server.

The Softether server by default to run on port 443, if you server also hosts normal https then 443 is already taken and so Softether can't bind to it.

When you run `vpncmd` it attempts to connect, find an active port, but of course fails with 'Protocol error occurred. Error was returned from the destination server.' because it's not actually connecting to the vpn server.

By default Softether also listens on 992, 1194, and 5555 so the sollution is to modify specify `localhost:5555` when executing the `vpncmnd`. If this has helped you feel free to comment or follow me on twitter @danielsokolows.

Friday, November 11, 2016

FIELD_INTEGRITY_EXCEPTION: Failed to save undefined: QualifiedName is required for descriptors: Source

Save error: A problem was encountered while invoking the subscription method

If in the Salesforce 'Developer Console' you get the error mentioned in the subject or if you in Eclipse IDE you get:

Save error: A problem was encountered while invoking the subscription method: No TOKENS named markup://c:defaultTokens foundproblem Save error: COMPONENT's markup cannot be empty. If you are trying to delete the Lightning definition bundle, directly delete the bundle instead. Save error: QualifiedName is required for descriptors

Then ensure that you don't have an empty `controller=""` attribute, this took a me a little while to notice so for the prosperity of others and my own memory forming benefit I am posting this. If this has helped you feel free to follow or thanks comment.

Sunday, July 10, 2016

`fetch chromium` fails

Fix for: `Command '/usr/bin/python src/build/linux/sysroot_scripts/ --running-as-hook' returned non-zero exit status 1 in /root/chromium-src`.

As part of some R&D for a JS framework I have been thinking of for a while I needed to do some Chromium hacking, problem is I hit a wall just simply attempting to check out the source code. This was on a fresh Debian VM machine following the official checkout docs.

root@lh1:~/chromium-src# fetch --no-history chromium
Running: gclient root
Running: gclient config --spec 'solutions = [
    "url": "",
    "managed": False,
    "name": "src",
    "deps_file": ".DEPS.git",
    "custom_deps": {},
Running: gclient sync --no-history
Error: Command '/usr/bin/python src/build/linux/sysroot_scripts/ --running-as-hook' returned non-zero exit status 1 in /root/chromium-src
Traceback (most recent call last):
  File "/root/depot_tools/", line 353, in 
  File "/root/depot_tools/", line 348, in main
    return run(options, spec, root)
  File "/root/depot_tools/", line 342, in run
    return checkout.init()
  File "/root/depot_tools/", line 142, in init
  File "/root/depot_tools/", line 76, in run_gclient
    return + cmd, **kwargs)
  File "/root/depot_tools/", line 66, in run
    return subprocess.check_output(cmd, **kwargs)
  File "/usr/lib/python2.7/", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '('gclient', 'sync', '--no-history')' returned non-zero exit status 2

The solution is to:

  • `export PATH=$PATH:/root/depot_tools`, this one is important or you will get an error when script is processing 'Downloading /root/chromium-src/src/third_party/binutils/Linux_x64/binutils.tar.bz2'.
  • gclient sync --nohooks --no-history chromium which will fetch the code without running hooks code; more info here.
  • Then running `aptitude install sudo` if not already installed
  • `./src/build/ --unsupported --no-syms --no-arm --no-chromeos-fonts --no-nacl`
    • But that will error out with various 'E: Unable to locate package ...' on a Debian system, copy the echoed command and remove the packages from the list manually or use Bash's for loop like so:
    • for i in apache2-bin bison cdbs curl devscripts dpkg-dev elfutils fakeroot flex fonts-indic fonts-thai-tlwg g++ git-core git-svn gperf language-pack-da language-pack-fr language-pack-he language-pack-zh-hant lib32gcc1 lib32stdc++6 libapache2-mod-php5 libasound2 libasound2-dev libatk1.0-0 libav-tools libbluetooth-dev libbrlapi0.6 libbrlapi-dev libbz2-1.0 libbz2-dev libc6 libc6-i386 libcairo2 libcairo2-dev libcap2 libcap-dev libcups2 libcups2-dev libcurl4-gnutls-dev libdrm-dev libelf-dev libexpat1 libffi6 libffi-dev libfontconfig1 libfreetype6 libgbm-dev libgconf2-dev libgl1-mesa-dev libgles2-mesa-dev libglib2.0-0 libglib2.0-dev libglu1-mesa-dev libgnome-keyring0 libgnome-keyring-dev libgtk2.0-0 libgtk2.0-dev libjpeg-dev libkrb5-dev libnspr4 libnspr4-dev libnss3 libnss3-dev libpam0g libpam0g-dev libpango1.0-0 libpci3 libpci-dev libpcre3 libpixman-1-0 libpng12-0 libpulse0 libpulse-dev libsctp-dev libspeechd2 libspeechd-dev libsqlite3-0 libsqlite3-dev libssl-dev libstdc++6 libudev1 libudev-dev libwww-perl libx11-6 libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxi6 libxinerama1 libxkbcommon-dev libxrandr2 libxrender1 libxslt1-dev libxss-dev libxt-dev libxtst6 libxtst-dev mesa-common-dev msttcorefonts openbox patch perl php5-cgi pkg-config python python-cherrypy3 python-crypto python-dev python-numpy python-opencv python-openssl python-psutil python-yaml realpath rpm ruby subversion ttf-dejavu-core ttf-kochi-gothic ttf-kochi-mincho wdiff xcompmgr zip zlib1g; do sudo apt-get install -y $i; done
  • Then finally run `gclient runhooks`.

Wednesday, May 18, 2016

Eclipse IDE Unable to Save to Server

"Save error: Package Visibility: Type is not visible: "

If all other checks fail and you are actually able to reference `` than in my experience this error is caused due to the fact that the class you are working on has been updated on the server.

Solution is to disable tooling api support in project properties. If this has helped you please comment or follow me .

Thursday, April 21, 2016

Emulate Bluetooh Keyboard using Windows PC

Control your Phone with Windows keyboard and mouse

While at work, I have been on a search to control my phone through the computers keyboard and mouse. Today I have found Across software which is a possible solution, but unfortunatly Lumia 640 LTE lacks the proper bluetooth keyboard profile.

If you find a solution to get Lumia 640 to work please post a comment.

Thursday, April 7, 2016

I prefix my variables with their type!

Why 'Systems Hungarian' makes sense.

As a developer, if you prefix the variable type you are clearly in the minority - I for one am a propoment of Systems Hungarian and belong to that group myself.

The merrits become apparent when reading other people's code, or when you look at your own code months/years after. Properly naming variables is hard, the type is not always obvious and left to individual interpenetration. Prefixing completely removes any uncertainty, it immediately reveals the type of the variable, and the developer reading the code does not have to go through the mental friction of inferring from the name or from how it is being used in the context or traversing back to where the variable was defined.

For weakly typed languages like JS/Python it has the huge additional benefit of making debugging that much easier, when one treats the prefix as the intent of what should be the value stored it reveals possible issues immediately when steping through code.

When the end goal is the benefit to 'other' developers reading your code Systems Hungarian makes perfect sense. Yes, it does mean some time getting used to it, but it's no different then any other coding pattern you habituate yourself to.

We end up gravitating towards the familiar and find other patterns ugly which in my opinion is the root cause of the negativity against type prefixing.

JavaScript and Apex variable prefixing

Variables are prefixed using letters from primitive types, the base 'Object', or `f` for functions. An exception are arrays that are prefixed with `a` even though the base type is an Object - this keeps the rule list small and as follows:

// Note: you can use `` to get the primitive type of it. 

var nYear; // for Numbers 
var bGender; // for Booleans
var sName; // strings
var oTable; // objects
var aScores; // arrays
var fAge = function () {}; //gets age of the person

I am was happy to find at one other person thinks the same: what-do-you-mean-by-the-initial-letter-on-javascript-variables-functions.

Apex variable prefixing

Blob blBlobieFoo; 
Boolean bBooleano;
Datetime dtStartDateAndTime;
Decimal dAgeOfUniverise;
Double dbBiggerNumber;
Integer iUserAge;
Long lTurlleAge;
Object oContentList;
Object oContentMap;
String sFirstName;
Time tAlarm;

// Methods??? m??? mUserAge // unsure about this one, thoughts?

What are you thoughts on this?

Tuesday, January 19, 2016

Salesforce Developer Console Not Showing Code Coverage

Code coverage highlighting lines missing from class editor

It appears that in latest Winter 2016 upgrade a bug was introduced where code coverage line highlights are missing from the Salesforce Developer Console

You can get them back by selecting the 'Test > Always Run Asynchronously' checkbox and re-running your test.

If this has helped you please comment or follow me @danielsokolows.

Saturday, January 2, 2016

LightScribe Template Labeler for Windows 10

LightScribe Template Labeler installation "Operating System Inadequate" Issue

Unfortunately 'LightScribe Template Labeler' installation will not work on Windows 8 and Windows 10 machines as the install simply will error out with 'Operating System Inadequate'. Trying to install using compatibility mode did not help.

Installing LightScribe Template Labeler Workaround

However if you simply copy the installed folder from an older machine like Windows 7 into your `C:\\Program Files (x86)\LightScribe Template Labeler`, create a shortcut, then the software will still happily work, see:

So you can install Windows 7 machine in a virtual machine, install 'LightScribe Template Labeler', and then copy the resulting folder to your Windows 8 or Windows 10 machine. For my own convenience to avoid this process in the future I am keeping a zipped version of the folder that you can download it here: LightScribe Template Labeler for Windows 10 (please comment if the link is dead).

Feel free to comment or follow me .