Skip to content

Instantly share code, notes, and snippets.

View timnew's full-sized avatar

TimNew timnew

View GitHub Profile
@timnew
timnew / Rename.ps1
Last active May 23, 2024 13:50
Script to Rename Computer without Reboot
$ComputerName = "New Name"
Remove-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -name "Hostname"
Remove-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -name "NV Hostname"
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\Computername\Computername" -name "Computername" -value $ComputerName
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Control\Computername\ActiveComputername" -name "Computername" -value $ComputerName
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -name "Hostname" -value $ComputerName
Set-ItemProperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -name "NV Hostname" -value $ComputerName
Set-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -name "AltDefaultDomainName" -value $ComputerName
@timnew
timnew / HashTextConverter.ps1
Created April 13, 2012 04:56
Powershell script to covert between hash and key value pairs
Function ConvertTo-KeyValue($hashObject) {
$hashObject.GetEnumerator() | %{ $_.Key + "=" + $_.Value }
}
Function ConvertTo-Hash($text) {
if($text -eq $null) {
$text = $input
}
$result = @{}
@timnew
timnew / uninstall_mysql.sh
Created May 9, 2012 05:13
Steps to manually uninstall mysql from Mac OS X
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
@timnew
timnew / Rakefile
Created May 12, 2012 16:22
Coffee-script node.js module skeleton
desc "Run Unit Test"
task :test do
sh "mocha -r \"coffee-script\" -R spec -G -c test/*.coffee"
end
desc "Start development environment"
task :dev => ["dev:mate", "dev:test"] do
end
desc "Start development environment"
@timnew
timnew / behaviors.rb
Created July 17, 2012 13:27
Rails MultiSchema utility for Postgres multi-schema database
module MultiSchema
module Behaviors
@@disable_message = false
def disable_message=(val)
@@disable_message = val
end
def disable_message
@@disable_message
@timnew
timnew / gist:3137257
Created July 18, 2012 16:20
Inject Javascript to current page
javascript:var%20b=document.body;if(b){void(z=document.createElement('script'));void(z.type='text/javascript');void(z.src='http://code.jquery.com/jquery-1.7.2.min.js');void(b.appendChild(z));}else{}
@timnew
timnew / cached_attrs.rb
Created August 28, 2012 15:27
Cached Attributes
module CachedAttrs
def self.build_cache_variable_name(attr_name)
"@_cached_#{attr_name}".to_sym
end
def self.extended(mod)
mod.send(:include, CachedAttrs::InstanceMethods)
end
def cached_attr(attr_name, &block)
@timnew
timnew / dabblet.css
Created November 13, 2012 11:09
Untitled
body {
position: relative;
width:500px;
height:200px;
}
.notification {
width: 360px;
height: 142px;
overflow: hidden;
@timnew
timnew / JSONView Dark Theme.css
Created March 15, 2013 03:16
This is a dark theme for JSONView chrome extension
body {
white-space: pre;
font-family: consolas;
color: white;
background: black;
}
.property {
color: orange;
font-weight: bold;
@timnew
timnew / add_row.js
Last active December 18, 2015 18:09
Scripts to manage T&E system
// Script to add empty rows in activity
(function($){
function addRows(moreRow) {
var $addRow = $(containerId+' [alt=Addrow_button]:first')
var $spinner = $(containerId+' img[alt=Ajax-loader]').parent()
var totalRows = $(containerId + ' td select[id$=category]').length + moreRow;
function needAddRow(){
var result = $(containerId + ' td select[id$=category]').length < totalRows