Skip to content

Instantly share code, notes, and snippets.

View jincod's full-sized avatar

Vadim Abdrashitov jincod

View GitHub Profile
@jincod
jincod / transform.js
Created July 1, 2016 10:43
Remove 'es6-promise' imports from legacy code. Using https://github.com/facebook/jscodeshift
export default function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.ImportDeclaration, {
source: {
value: 'es6-promise'
}
})
.filter(({node}) => node.specifiers.filter(value => value.local.name === 'Promise').length > 0)
@jincod
jincod / docker-compose.yml
Created March 28, 2016 08:17
docker-compose config
---
version: '2'
volumes:
pgdata: {}
services:
db:
image: postgres:latest
ports:
@jincod
jincod / default.ps1
Last active January 29, 2018 17:47
Run NUnit3 tests from powershell
$ProjectDir = "."
$PackagesDir = "$ProjectDir\packages"
$OutDir = "$ProjectDir\bin\Debug"
# Install NUnit Test Runner
$nuget = "$ProjectDir\.nuget\nuget.exe"
& $nuget install NUnit.Runners -ExcludeVersion -o $PackagesDir
# Set nunit path test runner
$nunit = "$ProjectDir\packages\NUnit.ConsoleRunner\tools\nunit3-console.exe"
var urls = [];
var tasks = urls.map(function(url) {
return $.getJSON(url);
});
var lastPromise = urls.reduce(function(promise, url) {
return promise.then(function() {
return $.ajax(url);
});
@jincod
jincod / default.ps1
Created February 6, 2016 15:47
Powershell script for find and calculate urls with max errors
gci | Select-String "\s502\s|\s504\s" | %{$_ -match 'GET (.*) HTTP/1.1'} | foreach { $matches[1] }| group-object -noelement | Where-Object {$_.Name -notlike "*solr*"} | Sort-Object Count -Descending | % {"{0} {1}" -f $_.Count, $_.Name} | Out-File result.txt
save=true
save-exact=true
@jincod
jincod / router.coffee
Created April 10, 2015 17:08
express.js route builder from controllers
fs = require 'fs'
path = require 'path'
routes = fs.readdirSync('./server/controllers').map (f) ->
path.basename(f, path.extname(f))
addRouter = (app, name) ->
name = name.replace 'index', ''
app.use '/' + name, require './controllers/' + name
@jincod
jincod / changes.ps1
Created November 21, 2014 10:23
Get changes from TeamCity build
$buildId = 10048
$teamcityUrl = "http://teamcity:8080"
$auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("username:password"))
@((Invoke-RestMethod $teamcityUrl/httpAuth/app/rest/changes?build=id:$buildId -Headers @{"Authorization" = "Basic $auth"}).changes.change) | % { (Invoke-RestMethod $teamcityUrl/httpAuth/app/rest/changes/id:$($_.id) -Headers @{"Authorization" = "Basic $auth"}).change.comment}
@jincod
jincod / sample.conf
Created November 14, 2014 21:23
Supervisor simple config
[program:sample]
command=coffee index.coffee
user=deployer
stdout_logfile=/var/projects/sample/logs/supervisor/access.log
stderr_logfile=/var/projects/sample/logs/supervisor/error.log
directory=/var/projects/sample/server/
autostart=true
autorestart=true
redirect_stderr=true
environment=NODE_ENV=production
@jincod
jincod / 1-remove.cs
Last active August 29, 2015 14:09
Refactoring Remove method in MongoDb Repository
public void RemoveById(Guid id)
{
_collection.Remove(Query.EQ("_id", id));
}
// Using
_repository.RemoveById(id);