Skip to content

Instantly share code, notes, and snippets.

View jincod's full-sized avatar

Vadim Abdrashitov jincod

View GitHub Profile
@jincod
jincod / DeserializeTest.cs
Created September 25, 2014 04:58
Test Serialize and Deserialize
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Newtonsoft.Json;
namespace Web.Test
{
public class Class1
{
public Class1(string name, IEnumerable<string> names, IEnumerable<Class2> classes)
@jincod
jincod / nginx-log-rotate.ps1
Created October 3, 2014 05:29
Powershell script for nginx log rotate
Push-Location c:\nginx
.\nginx.exe -s stop
$started = ps nginx*
while($started) {
Start-Sleep 1
$started = ps nginx*
}
Push-Location logs
$timestamp = (Get-Date).ToString("dd.MM.yyyy_HH.mm.ss")
$location = Get-Location
@jincod
jincod / index.coffee
Created October 15, 2014 08:08
Download podfm podcast from rss chanel
FeedParser = require "feedparser"
request = require "request"
fs = require "fs"
args = process.argv.slice(2)
process.exit(1) if args.length is 0
req = request(args[0])
feedparser = new FeedParser()
@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);
@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 / 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 / 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
save=true
save-exact=true
@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
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);
});