Skip to content

Instantly share code, notes, and snippets.

View regme's full-sized avatar
🤠

Andrey Katamanov regme

🤠
View GitHub Profile
@regme
regme / gist:937f134e120d3f9341f0
Created November 19, 2014 07:56
Converting between strings and ArrayBuffers
function ab2str(buf) {
return String.fromCharCode.apply(null, new Uint16Array(buf));
}
function str2ab(str) {
var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
var bufView = new Uint16Array(buf);
for (var i=0, strLen=str.length; i<strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
--DROP PROCEDURE BaseLineTableRowsCount_Proc
CREATE PROCEDURE BaseLineTableRowsCount_Proc
AS
BEGIN
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
IF ( NOT EXISTS (SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'BaseLineTableRowsCount'))
BEGIN
@regme
regme / table_size.sql
Last active August 29, 2015 14:14
Shows disk usage of each table database for MS SQL Server
select t.name as TableName, ds.name as FileGroupName, SUM(u.total_pages) * 8 / 1024 as SizeMB
from sys.tables as t inner join sys.partitions as p on t.object_id = p.object_id
inner join sys.allocation_units as u on p.partition_id = u.container_id
inner join sys.data_spaces as ds on u.data_space_id = ds.data_space_id
group by t.name, ds.name
order by SizeMB desc
@regme
regme / iis_config_path
Created June 5, 2015 00:41
общий конфиг ииса
C:\Windows\System32\inetsrv\config\applicationHost.config
@regme
regme / pre-commit.sh
Last active August 29, 2015 14:27 — forked from akfish/pre-commit.sh
Run MSBuild and MSTest for C# project from git pre-commit hook
#!/bin/sh
# Helper
safeRunCommand() {
typeset cmd="$*"
typeset ret_code
echo cmd=$cmd
eval $cmd
ret_code=$?
@regme
regme / example.msbuild.xml
Created October 26, 2015 14:00 — forked from fearthecowboy/example.msbuild.xml
Super Simple PowerShell task for MSBuild.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- @FearTheCowboy's Simple PowerShell Task for MSBuild -->
<UsingTask TaskName="PowerShell" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup><ScriptBlock ParameterType="System.String" Required="true" /></ParameterGroup>
<Task><Reference Include="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll"/><Code Type="Class" Language="cs"><![CDATA[
public class PowerShell : Microsoft.Build.Tasks.Exec {
public string ScriptBlock {set { EchoOff=true; Command = string.Format( "@powershell \"Invoke-Command -ScriptBlock {{ $errorActionPreference='Stop'; {0} ; exit $LASTEXITCODE }} \"", value.Replace("\"","\"\"").Replace("\r\n",";").Replace("\n",";").Replace("\r",";")); } }
}]]></Code></Task>
</UsingTask>
@regme
regme / Install-VisualStudio.ps1
Created March 7, 2016 12:59 — forked from altrive/Install-VisualStudio.ps1
Unattend install script for Visual Studio 2012 and Visual Studio 2012 Update 2
function Install-VisualStudio
{
[CmdletBinding()]
param (
[string] $ImagePath,
[string[]] $ArgumentList,
[string] $InstallPath,
[string] $ProductKey
)
Write-Verbose "Install Visual Studio 2012..."
http.cors.enabled: true
http.cors.allow-origin: "*"
I add these lines to /etc/elasticsearch/elasticsearch.yml and restart elasticsearch service, then it works for me.
use admin
db.createUser(
{
user: "mongodbuser",
pwd: "mongodbpass",
roles: [ { role: "root", db: "admin" } ]
}
);
exit;
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse |
Get-ItemProperty -name Version,Release -EA 0 |
Where { $_.PSChildName -match '^(?!S)\p{L}'} |
Select PSChildName, Version, Release, @{
name="Product"
expression={
switch -regex ($_.Release) {
"378389" { [Version]"4.5" }
"378675|378758" { [Version]"4.5.1" }
"379893" { [Version]"4.5.2" }