Skip to content

Instantly share code, notes, and snippets.

View AlexShkor's full-sized avatar

Alex Shkor AlexShkor

View GitHub Profile
pragma solidity ^0.4.17;
contract AtomicSwap {
enum State { Empty, Initiator, Participant }
struct Swap {
uint initTimestamp;
uint refundTime;
bytes20 hashedSecret;
#ifndef IS_TEST_NET
+ auto snapshot_path = string("./snapshot5392323.json");
+ auto snapshot_file = fc::path(snapshot_path);
+ FC_ASSERT( fc::exists( snapshot_file ), "Snapshot file '${file}' was not found.", ("file", snapshot_file) );
+
+ std::cout << "Initializing state from snapshot file: "<< snapshot_file.generic_string() << "\n";
+
+ unsigned char digest[MD5_DIGEST_LENGTH];
+ char snapshot_checksum [] = "081b0149f0b2a570ae76b663090cfb0c";
+ char md5hash[33];

Keybase proof

I hereby claim:

  • I am alexshkor on github.
  • I am alexshkor (https://keybase.io/alexshkor) on keybase.
  • I have a public key ASCy8ZEQVu-av_-_k6j41hkYJDnkTzM6L8X49mS0DMKSxAo

To claim this, I am signing this object:

@AlexShkor
AlexShkor / gist:cd089e0bf2d71ff22b7a
Created June 18, 2015 10:48
Location IBsonSerializable
public struct Location : IBsonSerializable
{
public const double LatitudeMinValue = -90;
public const double LatitudeMaxValue = 90;
public const double LongitudeMinValue = -180;
public const double LongitudeMaxValue = 180;
private const double PIx = 3.141592653589793;
public const double EarthRaduisInKm = 6378.16;
public const double EarthRaduisInMiles = 3959;
[POST]
public JsonResult UploadImage(HttpPostedFileBase uploadedFile)
{
var cloudinary = new CloudinaryDotNet.Cloudinary(ConfigurationManager.AppSettings.Get("cloudinary_url"));
bool isValidImage;
if (uploadedFile != null)
{
isValidImage = uploadedFile.IsValidImage(250, 250);
}
@AlexShkor
AlexShkor / gist:7115182
Created October 23, 2013 09:09
JsonModel in BaseController
protected JsonResult JsonModel<T>(T model) where T : BaseViewModel
{
model.Errors = GetErorsModel().ToList();
return Json(model);
}
protected IEnumerable<ValidationError> GetErorsModel()
{
foreach (var state in ModelState)
{
@AlexShkor
AlexShkor / gist:7115055
Created October 23, 2013 08:58
send model
var sendModel = function (url, model, successCallback, ignoreList) {
model.Loading(true);
var mapping = {
ignore: ignoreList
};
sendJson(url, ko.mapping.toJS(model,mapping), function(response) {
var defaultBehaviour = true;
if (successCallback) {
var result = successCallback(response);
if (result === false) {
@AlexShkor
AlexShkor / gist:6250733
Created August 16, 2013 15:07
send json as plain form data
var sendJson = function(url, json, callback){
var data = {};
parseValues(json, function(key, value) {
data[key] = value;
});
$.post(url, data,callback);
};
var parseValues = function (data, callback, prefix, postfix) {
@AlexShkor
AlexShkor / gist:6018730
Created July 17, 2013 08:16
Amazon S3 helper
public class AmazonS3Helper
{
private readonly string _amazonAccessKey;
private readonly string _amazonSecretKey;
private const string BucketName = "zertisedpm";
public AmazonS3Helper(string amazonAccessKey, string amazonSecretKey )
{
_amazonAccessKey = amazonAccessKey;
_amazonSecretKey = amazonSecretKey;
@AlexShkor
AlexShkor / KnockoutHtmlHelper.cs
Created May 9, 2013 11:47
HtmlHelper for applying Knockout model
using Newtonsoft.Json;
namespace System.Web.Mvc
{
public static class HtmlHelperExt
{
private const string BaseApplyModelScriptString = @"<script type=""text/javascript"">
$(function () {{
var model = new AllMessagesModel({0});
ko.applyBindings(model);