Skip to content

Instantly share code, notes, and snippets.

Avatar

Huy Thái huyttq

  • Perth, Australia
View GitHub Profile
@huyttq
huyttq / Import-PfxCertificate.ps1
Created Oct 2, 2019 — forked from deadlydog/Import-PfxCertificate.ps1
PowerShell script that imports a .pfx certificate file. Useful to do before building the solution on a build server.
View Import-PfxCertificate.ps1
param($PfxFilePath, $Password)
$absolutePfxFilePath = Resolve-Path -Path $PfxFilePath
Write-Output "Importing store certificate '$absolutePfxFilePath'..."
Add-Type -AssemblyName System.Security
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($absolutePfxFilePath, $Password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet")
$store = new-object system.security.cryptography.X509Certificates.X509Store -argumentlist "MY", CurrentUser
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::"ReadWrite")
@huyttq
huyttq / RestoreDbWithReplace.sql
Last active Jul 11, 2018
Restore MS SQL Server DB with replace
View RestoreDbWithReplace.sql
use [master]
Declare @BackupFileLocation varchar(max)
Declare @BackupMDFFileName varchar(max)
Declare @BackupLogFileName varchar(max)
Declare @ImportTesterMDFFileName varchar(max)
Declare @ImportTesterLogFileName varchar(max)
set @BackupFileLocation =
N'\\file-path\bk.bak'
@huyttq
huyttq / gist:2000353
Created Mar 8, 2012
Install imagemagick
View gist:2000353
#!/bin/bash
mkdir -p ~/local
command -v identify > /dev/null
if [ $? -eq 1 ]; then
echo "${bldgrn}Installing imagemagick into ${txtwht}$HOME/local/imagemagick${txtrst}"
wget -N --retr-symlinks ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar -xzvf ImageMagick.tar.gz
cd ImageMagick-*
./configure --prefix=$HOME/local/imagemagick
make
@huyttq
huyttq / gist:1862679
Created Feb 19, 2012
Useful Vim commands
View gist:1862679
# Replace text across files
:args dir_path/*/* #(for 2 levels)
:argdo %s/, :expire.*)/)/gc | update
@huyttq
huyttq / gist:1814612
Created Feb 13, 2012
Rails & Jenkins notes
View gist:1814612
http://lostechies.com/ryansvihla/2011/09/25/rail-3-1-ci-setup-with-jenkins-test-unit-simplecov-on-os-x-lion/
http://danseaver.com/blog/2011/11/22/using-jenkins-with-rails/
http://rails-jenkins.danseaver.com/#1
Setup Redis server
http://www.denofubiquity.com/nosql/412/
@huyttq
huyttq / gist:1814610
Created Feb 13, 2012
Ruby code quality
View gist:1814610
http://www.slideshare.net/martin_j_andrews/code-quality-analysis?type=presentation
@huyttq
huyttq / gist:1813644
Created Feb 13, 2012
Zero downtime when migration
View gist:1813644
# http://blog.tstmedia.com/news_article/show/85364?referrer_id=308069
class << self
RemovedColumns = {'column_to_remove' => true}
def columns
cols = super
cols.reject { |col| RemovedColumns.has_key? col.name }
end
end
# http://pedro.herokuapp.com/past/2011/7/13/rails_migrations_with_no_downtime/
@huyttq
huyttq / gist:1380019
Created Nov 20, 2011
Useful bash commands
View gist:1380019
History: Ctrl + r
Find: find /home/user -name abc.txt
Pipeline: vi `find /home/user -name abc.txt`
Ctrl-x, Ctrl-e will bring up an $EDITOR containing whatever is currently entered into the prompt. (opposed to editing last command actually entered)
Managing remote systems and trying to figure out what hardware you're on and whether it's healthy or not: dmidecode
Repeat last command with "sudo" prepended: sudo !!
Execute <command> with the argument to your previous command: <command> !$ / !* for get all args.
@huyttq
huyttq / gist:1363082
Created Nov 14, 2011
.vimrc for ruby
View gist:1363082
"-----------------------------------------------------------------------------
" General
"-----------------------------------------------------------------------------
set nocompatible
set history=1024
set cf " enable error files and error jumping
set ffs=unix,dos,mac " support these files
filetype on
filetype plugin on
filetype indent on
@huyttq
huyttq / gist:1354248
Created Nov 10, 2011
Slice specific param to work well with cabybara
View gist:1354248
<td>
<%= link_to("Send", send_task_admin_path(task, params.slice(:page))) %>
</td>