Kickstarter Collection

Here is my kickstarter link collection, a collection of links to help you get applications, application features, build and test environments, up and running, smashing learning curves along the way with good demonstration.

SSO

Building A Simple Single Sign On(SSO) Server And Solution From Scratch In Node.js.
Here the author creates a “roll your own” SSO implementation in NodeJS, a solution easily ported to other platforms.

Posted in Code Samples, Helpful Links | Leave a comment

Installing Git On Windows – My Opinionated Approach

Download the installer from git-scm.com. Use a 64 bit version for a 64 bit operating system. The install sequence and comments are detailed below.

Information


Select Destination Location


Select Components

  • Uncheck Associate .sh files to be run with Bash if you have other Bash environments such as Cygwin installed.
  • Check Use a TrueType font in all console Windows if you want a nicer font in your Git-Bash terminal.

Using a TrueType font for the Git-Bash console will better display Unicode characters.


Select Start Menu Folder


Choosing the Default Editor Used By Git

Vim comes bundled with the install and is available in Git-Bash. You may change the default editor later.

$ git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

The above changes the editor to Notepad++ for in the user’s global configuration.

Do not try to use MS Word or WordPad, the configuration needs to be in plain text. Use a UTF-8 without the UTF-8 BOM encoding for the text format.


Adjusting you PATH Environment


Choosing HTTPS Transport Backend

This sets the git http.sslBackend setting and this can changed later. The top radio sets the system value to openssl. The bottom radio sets this to schannel for using the Windows Certificate store. This options can always be changed on a system, per user, or per project basis later.

This option only needs to be set to schannel if custom SSL certificates are used for accessing remote repos using HTTPS.

It is advised to go with the default OpenSSL and only switch to the other on a per project basis when needed. You can always change this later.


Configuring the Line Ending Conversions

This sets the system Git core.autocrlf config option.


Configuring the Terminal Emulator To Use With Git Bash

The seconds option is not advised here. If you want to use Git from something other than a Bash shell, use the posh-git module from the PowerShell Gallery and use Git from PowerShell.

PowerShell with posh-git still does not work as well as Git-Bash. If you insist on using Git from cmd.exe, find a good therapist.


Configuring Extra Options

I’ve not had the need to use symbolic links in any of my Git project. If needed, this option can be set later by setting the Git core.symlinks to true. Remember to set the SeCreateSymbolicLink permission for the user accounts needing this.

Posted in Git | Tagged | Leave a comment

Git File Based Repos

Sometimes you may need to keep code in a Git repo, but don’t have a nice web based backend like GitHub available yet to push your source into. A workaround can be to start with a file based repo that you can later easily push to a backend when you have one available. While you won’t have the nice web based repository view associated with many of these backends, you at least get the full Git command line.

All you need is the Git command line client to get started. Windows users can get it from git-scm.com and then use the Git-Bash command line client to manage their Git repositories.

At the time of this writing, I was using the StefanScherer/windows_10 VM image for VirtualBox from Vagrant Cloud, hence the vagrant user in the example paths.

Linux users can install Git from their distro; using the Git-Bash console in Windows has the same look and feel as Linux users using Git from Bash.

$ mkdir -p ~/repos/my-project
$ cd ~/repos/my-project
$ git init --bare

For Windows 10 users, this created a directory in your home folder for the vagrant account C:\Users\vagrant\repos\my-project. Next, figure out where you want to checkout your code to.

mkdir ~/projects
cd ~/projects
git clone file:///c/Users/vagrant/repos/my-project

This gave us a checkout directory in C:\Users\vagrant\projects\my-project. You may get the “warning: You appear to have cloned an empty repository.” message, nothing wrong here as this is exactly what you just did.

In the directory where you cloned the empty repo, you add files from an existing project or create new ones, whatever- this is your development directory. Then when your are ready for your initial push:

$ git add .
$ git commit -m 'initial revision'
$ git push

You have just done your first push to your upstream file based repo in C:\Users\vagrant\repos\my-project. You work with it just like one cloned from a backend like GitHub.

Pushing To Remote Backend

When your backend is set up and you are ready to push to a remote repository, just create a new repository on your backend. Using the remote URL, push the bare file based repo as shown in the example below:

$ cd ~/repos/my-project
$ git push --mirror git@mybackend.com/someusername/my-project.git

The URI following –mirror will different, depending on where and what your backend is.

Posted in Git | Tagged | Leave a comment

Python Install On Windows – My Opinionated Approach

This is an opinionated approach to installing Python obtained from Python.org on Windows. Essentially, install per-user and keep Python out of the system or PATH environment variable. I’ll show you how to create some simple shortcuts to create Python console windows with your installed Python so you can easily used Python from the command line.

If you install Python on a Windows server used for something like builds or Flask websites and add Python to the PATH, you will quickly get stuck on a stale, aging, old Python version that can’t be updated because you (and everyone else) will be to busy and scared to worry about breaking existing apps on the machine.

Download and Run Setup

From the Python.org official Python site, then select Windows to view all download for Windows. Find the version you want, making sure you select a 64 bit version if that is what you want for a 64 bit machine.

Download the executable or web based installer for the version and bitness you want. For this example, the 64 bit 3.7.1 windows executable installer was used.

Running the install should show the following dialog:

Initial Setup Dialog

Make sure that Install launcher for all users (recommended) and Add Python 3.7 to PATH are both unchecked.

Click Customize Installation to get the next dialog shown below:

Optional Features

Make sure py launcher and for all users (requires elevation) are both unchecked.

Click Next to get the Advanced Options dialog.

Make sure that Install for all users and Customize install location are clear, and additionally, Associate files with Python (requires the py launcher) is unchecked and disabled.

Click Install to run the install.

Create Command Shortcut

I created a batch file, py37_env.cmd with the following contents.

@echo off
TITLE Python.org 3.7
 
REM add Python executable to PATH
set python_base=%LOCALAPPDATA%\Programs\Python\Python37
 
REM add Python executable and tools like pip.exe to PATH
set PATH=%PATH%;%python_base%;%python_base%\Scripts
 
REM switch to Unicode code page
chcp 65001

I then create a shortcut to the batch file with the following for the shortcut properties:

Assuming the batch file is in %USERPROFILE%\Desktop\Toolbox I create a short cut with the following for Target:

%comspec% /K "%USERPROFILE%\Desktop\Toolbox\py37_env.cmd"

And for Start In: someting like

%USERPROFILE%

Posted in Python, Uncategorized | Leave a comment

Multiple Oracle Javas On Windows – No Installs

Whether you want a portable JDK or you just don’t want to further muck up your Windows %PATH%, you can get a older or newer Java on your Windows machine without affecting other versions.

I found a link explaining how to do it here: https://www.whitebyte.info/programming/java/how-to-install-a-portable-jdk-in-windows-without-admin-rights, but in case it ‘goes away’, here are the steps:

So far this works for Java 1.7, should work with Java 1.8.

  1. Make sure you have 7-zip on your Windows. Download the installer from Oracle
  2. Open the executable installer with 7-zip and extract the single tools.zip file inside
  3. Extract the files from the tools.zip to where you want your JDK.
  4. From a Windows command prompt in the folder where you extract the tools.zip files, run the following:

    for /R %f in (.\*.pack) do @"%cd%\bin\unpack200" -r -v -l "" "%f" "%~pf%~nf.jar"

Posted in Java | Leave a comment

WiFi From Linux Rescue CD

Using Finnix 111 rescue CD:

Generate wpa_supplicant.conf configuration file:

# wpa_passphrase ssid passphrase > /etc/wpa_supplicant.conf

If you have any funky characters like ‘@’ in your passphrase, escape with a ‘\’.

Find driver
# wpa_supplicant –help

Using the correct driver:
# wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf -B

My driver listed was ‘nl80211’. Also, do not add a space between the options and their arguments.

Use ifconfig to find the network interface.

# dhclient wlan0

Posted in Uncategorized | Leave a comment

Make Bamboo Shell Task Run Using Bash

Bamboo will call shell tasks on *nix agents using sh as opposed to Bash. For Debian agents, this means dash not bash. So, how do we redirect to bash? I found this snippet:

[code language=”bash”]
if [ “$(ps -p “$$” -o comm=)” != “bash” ]; then
# Taken from http://unix-linux.questionfor.info/q_unix-linux-programming_85038.html
echo “RUNNING THIS PUPPY THE RIGHT WAT”
bash “$0” “$@”
exit “$?”
fi
[/code]

Alas, though, looks like the link I copied and pasted from the post does not work. Here’s the post I snagged this from.

Posted in Bamboo, Bash, Snippets | Leave a comment

Hack Classpath In Gradle

I recently tried this to fix the Classpath in Gradle for compiling and testing. Works for compiling, bombs for the testing though. The Gradle plugin integration using jna-3.2.7 blows up during unit testing when the older API is not loaded. What a mess. At least this snippet should help for other scenarios.

[code language=”groovy”]
def fixTheCp(fc) {
def jnaGoodJars = fc.filter {
it.name == “jna-4.2.1.jar”
}
return jnaGoodJars.plus(fc.minus(jnaGoodJars))
}

task(“fixCompileCp”) << { sourceSets.main.compileClasspath = fixTheCp(sourceSets.main.compileClasspath) sourceSets.main.runtimeClasspath = fixTheCp(sourceSets.main.runtimeClasspath) } task("fixTestCp") << { sourceSets.test.compileClasspath = fixTheCp(sourceSets.test.compileClasspath) sourceSets.test.runtimeClasspath = fixTheCp(sourceSets.test.runtimeClasspath) } compileJava.dependsOn fixCompileCp testClasses.dependsOn fixTestCp [/code]

Posted in Gradle, Snippets | Leave a comment

Hex Encode/Decode String In C#

The same code is posted all over the news groups and Internet, but here it is, easy as a snippet for myself and for you to use.

I don’t even get credit for this as what I have pretty much matches up to what other people have already posted.

This is much easier in Python.

Encode a byte array
[code language=”csharp”]
public static string HexEncode(byte[] data)
{
return BitConverter.ToString(data).Replace(“-“, string.Empty);
}
[/code]

Decode a hex necoded string
[code language=”csharp”]
public static byte[] HexDecode(string hexEncoded)
{
int numChars = hexEncoded.Length;
byte[] retVal = new byte[numChars / 2];
for (int i = 0; i < numChars; i += 2) { retVal[i / 2] = Convert.ToByte(hexEncoded.Substring(i, 2), 16); } return retVal; } [/code]

Posted in C#, Snippets | Tagged | Leave a comment

How To Clean SVN Checkout Directory

I just love

git clean -xfd

but you just don’t get that with Subversion. Instead from your Bash shell (or Cygwin) prompt you can do:

svn status --no-ignore | egrep '^[?I]' | cut -c9- | sudo xargs -d \\n rm -r

I got that last one from http://stackoverflow.com/questions/239340/automatically-remove-subversion-unversioned-files

Oh, and on that same post, for PowerShell users I found

function svnclean{
svn status | foreach { if($_.StartsWith("?")) {Remove-Item $_.substring(8) -Verbose}
}

I could resist saving these two snippets, I know I will need them.

Posted in Bash, PowerShell | Leave a comment