Skip to content

Instantly share code, notes, and snippets.

@Thaina
Thaina / dom-to-json.js
Last active June 11, 2016 08:14 — forked from sstur/dom-to-json.js
Stringify DOM nodes using JSON (and revive again)
/** @param {Node|HTMLElement} node */
function toJSON(node) {
if(!node)
node = this;
var obj = { nodeType: node.nodeType };
if(node.tagName)
obj.tagName = node.tagName.toLowerCase();
else if(node.nodeName)
p_0(1 - t)^3 + 3p_1t(1 - t)^2 + 3p_2t^2(1 - t) + p_3t^3
\\
p_0(1 - 3t + 3t^2 - t^3)
+ 3p_1(t - 2t^2 + t^3)
+ 3p_2(t^2 - t^3)
+ p_3t^3
\\
t^3(p_3 - 3p_2 + 3p_1 - p_0)
+ t^23(p_2 - 2p_1 + p_0)
+ t3(p_1 - p_0) + p_0
/** @param {string} id
* @param {string} secret */
function BitBucket(id, secret){
this.auth = AccessToken(id, secret);
this.Commit = function(repo,branch,message,files){
return Commit(repo,branch,message,files,this.auth.access_token);
}
}
/** @param {string} id
@Thaina
Thaina / MiniJSON.cs
Created June 29, 2016 07:42 — forked from darktable/MiniJSON.cs
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2013 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining
var resolved = false;
var resolving;
/* global FB */
var fbResolver = new Promise((resolve,reject) => {
if(resolved)
return resolve();
resolving = resolve;
});
@Thaina
Thaina / bitbucket-pipelines.yml
Created July 31, 2016 10:34
Bitbucket Pipeline publish to AWS Lambda with version
image: python:3.5.1
pipelines:
default:
- step:
script: # Modify the commands below to build and test your repository.
- apt-get update
- apt-get install -y zip
- zip -r $BITBUCKET_REPO_SLUG".zip" *
- pip install awscli
function (doc,req) {
if(!req.id)
return [null,{ message : "Support only PUT with id" }];
if(!doc)
doc = { "_id":req.id };
var data = JSON.parse(req.body);
delete data._id;
delete data.id;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
using System;
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Google.Protobuf;
using Google.Protobuf.Collections;
@Thaina
Thaina / ObjectProxyOperator.tt
Last active September 3, 2019 09:38
T4 file for generate common operator on C# object
<#@ output extension=".cs" #>
class ObjectProxyOperator
{
<#
{
var types = new[]{ "sbyte","byte","short","ushort","int","uint","long","ulong","float","double","decimal" };
foreach(var pair in new System.Collections.Generic.Dictionary<string,string>() { ["Add"] = "+",["Subtract"] = "-",["Multiply"] = "*",["Divide"] = "/",["Mod"] = "%" })
{
var func = pair.Key;
var op = pair.Value;