Skip to content

Instantly share code, notes, and snippets.

View jincod's full-sized avatar

Vadim Abdrashitov jincod

View GitHub Profile
@jincod
jincod / new.ps1
Created April 22, 2014 19:05
Refactoring build script on Psake
task Clean {
exec -maxRetries 3 {
Get-ChildItem . -Include bin,obj,*.orig -Recurse | Remove-Item -Recurse -Force
}
}
@jincod
jincod / build.cmd
Created April 23, 2014 16:34
Run Psake tasks on TeamCity
@echo off
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "& {& Scripts\nuget.exe install Psake -Version 4.3.2 -o packages; .\packages\psake.4.3.2\tools\psake.cmd .\Scripts\default.ps1 %*; exit $lastexitcode;}"
@jincod
jincod / index.coffee
Created August 22, 2014 07:30
Internet magazine
app.post '/pay', (req, res) ->
payment =
account: req.body.account
value: req.body.value
transactionId: (Math.random() * 1e18).toString(36)
res.redirect "#{appUrl}/#{payment.account}/#{payment.value}/#{payment.transactionId}?returnUrl=#{returnUrl}"
app.post '/payment', (req, res) ->
input = req.body.account + req.body.value + req.body.transactionId + secureKey
sign = crypto.createHash("md5").update(input).digest("hex")
@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