Skip to content

Instantly share code, notes, and snippets.

View tarasn's full-sized avatar
馃幆
Focusing

Taras Naumtsev tarasn

馃幆
Focusing
View GitHub Profile
@tarasn
tarasn / mock-method.py
Created November 27, 2014 16:50
How to replace a class method with mocked method for unit testing?
#http://stackoverflow.com/questions/13073281/how-to-mock-pythons-datetime-now-in-a-class-method-for-unit-testing?rq=1
from mock import patch
from mock import Mock
import unittest
class MyCalc(object):
def add(self,x ,y):
return x+y
@tarasn
tarasn / AdPreference.java
Created July 7, 2014 21:03 — forked from ishitcno1/AdPreference.java
Setup AdMob as preference item
import android.app.Activity;
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
@tarasn
tarasn / button-text.js
Created June 29, 2014 13:59
Place text on top of over images (sprites, buttons etc) tags: phaser
var sprite = game.add.sprite(0, 0, 'button');
var text = game.add.text(0, 0, "Some text", {font: "16px Arial", fill: "#ffffff"});
sprite.addChild(text);
// now text will be positioned relative to the sprite, and will move around with it like a group - except with sprites you can still use physics :)
@tarasn
tarasn / Author.cs
Last active August 29, 2015 14:00
Blog model using Fluent Nhibernate
using System;
namespace NHibernateExperimentsV2.ManyToMany.Data
{
public class Author
{
public virtual Guid Id { get; set; }
public virtual string FullName { get; set; }
}
}
@tarasn
tarasn / app.config
Created March 16, 2014 10:21
Enabling log4net internal tracing
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add
name="textWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\log4net.txt" />
@tarasn
tarasn / SHA1Util.cs
Created January 21, 2014 09:14
Generate SHA1 hex string for a string encoded as UTF8 ( https://gist.github.com/kristopherjohnson/3021045#file-sha1util-cs )
using System.Security.Cryptography;
using System.Text;
namespace Snippets
{
public static class SHA1Util
{
/// <summary>
/// Compute hash for string encoded as UTF8
/// </summary>
@tarasn
tarasn / NunitTest.cs
Created December 9, 2013 07:28
NUnit test boilerplate
using NUnit.Framework;
[TestFixture]
public class SomeTest
{
[SetUp]
public void Setup()
{
}
@tarasn
tarasn / Program.cs
Created November 24, 2013 10:54
An example of usage of Nustache framework( mustache for .NET) .Rendering object, collection and using a condition
using System;
using System.Collections.Generic;
using MyNustache.Properties;
using Nustache.Core;
namespace MyNustache
{
class Name
{
@tarasn
tarasn / image-resizing.html
Created November 10, 2013 09:35
Image resizing via css
<!DOCTYPE html>
<html>
<head>
<title>2 - Responsive image</title>
<style>
img {
max-width: 100%;
min-width: 500px;
height: auto;
}
@tarasn
tarasn / application-he.json
Created November 6, 2013 22:16
Localization to Russian and Hebrew using Zepto.js and localization plugin (jquery)
{
"title": "转专讙讜诐 砖驻讜转",
"link": "注讘专讬转",
"footer": {
"disclaimer": "诇讛转专讗讜转"
}
}