Skip to content

Instantly share code, notes, and snippets.

View DanSearle's full-sized avatar

Daniel Searle DanSearle

View GitHub Profile
@DanSearle
DanSearle / gist:fc03eb85dfd0a5cc8ab1
Created August 23, 2014 09:24
Scan arp cache to find duplicate ip addresses
sudo arp-scan -I eth0 -l
@DanSearle
DanSearle / BootstrapNode.ps1
Last active December 19, 2015 14:58
Powershell script to create seperate a node and npm environment for a project without the need to have it installed on the machine. This aids development with node and npm based tools for web development on windows. This script will launch a powershell enviroment with node and npm setup for the project.
function download_node {
param([string]$node_directory, [string]$node_version)
$node_exe = (Join-Path $node_directory "node.exe")
if (Test-Path $node_exe) {
Write-Host "Doing nothing as $node_exe exists"
return
}
if (!$node_version) {
@DanSearle
DanSearle / BootstrapNode.py
Created December 19, 2015 16:42
Python script for Linux to create a local node and npm install for a project. The environment can be activated by sourcing bin/activate
import os
import urllib
import json
import platform
import tarfile
import shutil
import urllib2
ACTIVATE_SH = """
export PATH="{0}:$PATH"
@DanSearle
DanSearle / gist:6707491
Created September 25, 2013 23:11
Convert Virtualbox .ova Image to .ovf
The .ova file format is a tar file with a .ovf file inside.
tar xvf virtualboximage.ova
@DanSearle
DanSearle / gist:6765506
Created September 30, 2013 15:29
Convert a vector to a array pointer in c++
std::vector<double> v;
double* a = &v[0];
// From http://stackoverflow.com/a/2923290/1260257
@DanSearle
DanSearle / gist:6807908
Created October 3, 2013 10:29
Download a web page and all linked content, rewriting any links for offline viewing.
wget --mirror -p --convert-links -P <destdir> <URL>
@DanSearle
DanSearle / gist:6812394
Created October 3, 2013 16:09
C++ convert an integer to an enum
int i = 0;
EnumType t = static_cast<EnumType>(i);
@DanSearle
DanSearle / gist:6824595
Last active December 24, 2015 15:59
Generate const C++ getters for fields
cat fields.txt | awk 'sub(";","",$2){print "const",$1,"Get"substr(toupper($2), 1,1)substr($2,2)"()","const","{ return",$2"; }"}'
E.g. fields.txt contains:
std::string test;
bool jaunTwoThree;
Note this command will remove semicolons
@DanSearle
DanSearle / gist:7023487
Created October 17, 2013 11:46
IsEnabled binding of a user control
Instead of modifying a binding in some way (for example you can make it dependent on other control name as it is proposed in other answer) I would move separate the control which will be disabled and control where DataContext will be changed. For example:
<ContentControl IsEnabled="{Binding CanModify}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
<localControls:TeamEmployeeSelector DataContext="{Binding Confidentiality}"/>
</ContentControl>
From http://stackoverflow.com/a/5444979/1260257
@DanSearle
DanSearle / gist:7168268
Created October 26, 2013 11:17
Start puppet master in the foreground for debugging apache/passenger issues with puppet master
puppet master --no-daemonize --debug