Skip to content

Instantly share code, notes, and snippets.

View DanSearle's full-sized avatar

Daniel Searle DanSearle

View GitHub Profile
@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 / 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 / gist:fc03eb85dfd0a5cc8ab1
Created August 23, 2014 09:24
Scan arp cache to find duplicate ip addresses
sudo arp-scan -I eth0 -l
@DanSearle
DanSearle / gist:b780d9ea45fe6fd24432
Created December 11, 2013 23:08
Add magento extension via command line
./mage mage-setup
./mage -V
./mage list-channels
./mage install connect20.magentocommerce.com/community/
e.g. ./mage install connect20.magentocommerce.com/community/ IG_LightBox
@DanSearle
DanSearle / gist:7316236
Created November 5, 2013 09:23
Hidden Trick to Close Windows Explorer in Windows 7 or Vista
Open the Start menu and then hold down the Ctrl and Shift keys at the same time. Right-click on an empty area of the menu, and you’ll see a new option called “Exit Explorer”
From -> http://www.howtogeek.com/howto/windows-vista/hidden-trick-to-close-windows-explorer-in-vista/
Explorer needs to be restarted from the task manager. Get to the task manager with CTRL+SHIFT+ESC
@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
@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: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: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:6807933
Created October 3, 2013 10:49
Download a web page and all linked content, rewriting any links for offline viewing.
wget --mirror -p --convert-links -P <destdir> <URL>