Skip to content

Instantly share code, notes, and snippets.

@jackinf
jackinf / html.html
Created July 31, 2014 12:35
[HTML] Check, if color CSS is valid
<form id="form1" runat="server">
<input type='file' id="imgInp" />
<img id="blah" src="#" alt="your image" />
</form>
@jackinf
jackinf / code_line_counter.bat
Last active October 29, 2015 08:55
[CMD] Treasure commands
(dir -include *.cs,*.fx -recurse | select-string .).Count
@jackinf
jackinf / angularTests.js
Created September 5, 2014 15:04
[JASMINE, ANGULAR] My Angular spec template
describe("jsTests:", function () {
var $scope, $controller, $httpBackend, $injector;
var myService;
beforeEach(function () {
module("kn");
});
beforeEach(function () {
this.addMatchers({
// Konverdib partial Razor view to string
public string RenderRazorViewToString(string viewName, object model)
{
ViewData.Model = model;
using (var sw = new StringWriter())
{
var viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName);
var viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw);
viewResult.View.Render(viewContext, sw);
@jackinf
jackinf / jsonCamelCaseConfig.cs
Created February 15, 2015 07:27
Для того, чтобы данные с сервера приходили в удобном для javascript camelCase надо добавить следующий код в Startup.ConfigureServices
services.AddMvc().Configure<MvcOptions>(options =>
{
options.OutputFormatters
.Where(f => f.Instance is JsonOutputFormatter)
.Select(f => f.Instance as JsonOutputFormatter)
.First()
.SerializerSettings
.ContractResolver = new CamelCasePropertyNamesContractResolver();
});
@jackinf
jackinf / gist:01e3d1660ce8ff9a76d9
Created April 2, 2015 15:58
pdf genereerimine
using System;
using System.Drawing;
using System.Net.Mail;
using System.Web;
using EO.Pdf;
using System.IO;
using System.Net;
namespace KopioNiini.ProjectBank.UI.Controllers
{
@jackinf
jackinf / addFilesToZip.cs
Created April 16, 2015 14:44
[C#] ZipFile operations
using (ZipFile zipDest = ZipFile.Read(bdocPath))
{
zipDest.AddFiles(files, false, string.Empty);
zipDest.Save();
}
@jackinf
jackinf / PdfController.cs
Created April 17, 2015 13:01
[C#] [PDF] EO.PDF generation controller
public partial class PdfController : LocalDefaultController
{
public void GeneratePdfFromUrl()
{
// Option 1: save pdf file as...
var options = new HtmlToPdfOptions();
HttpCookieCollection oCookies = Request.Cookies;
for (int j = 0; j < oCookies.Count - 1; j++)
@jackinf
jackinf / gist:490746b4362a81d13237
Last active August 29, 2015 14:19
[MAC OS X] [Terminal] Essential terminal commands
# 1. add Sublime Text 3 to terminal
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
@jackinf
jackinf / 0_reuse_code.js
Created May 31, 2015 16:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console