This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <functional> | |
int main() | |
{ | |
auto _if = [](bool cond, std::function<void()> _t, std::function<void()> _f) | |
{ | |
cond ? _t() : _f(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <type_traits> | |
extern void* enabler; | |
template<typename T, typename std::enable_if<std::is_integral<T>::value>::type *& = enabler> | |
void print(T t) | |
{ | |
std::cout << "is integral : " << t << std::endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TEMPLATE FUNCTION make_unique | |
template<class _Ty, | |
class... _Types> inline | |
typename enable_if<!is_array<_Ty>::value, | |
unique_ptr<_Ty> >::type make_unique(_Types&&... _Args) | |
{ // make a unique_ptr | |
return (unique_ptr<_Ty>(new _Ty(_STD forward<_Types>(_Args)...))); | |
} | |
template<class _Ty> inline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('lodash'); | |
var io = require('socket.io-client'); | |
if (process.argv.length <= 2) { | |
throw 'usage: node memo-cli.js hostname'; | |
} | |
var host = process.argv[2]; | |
var socket = io.connect('http://' + host + '/'); | |
var log = {}; | |
socket.on('create', function (memoData) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override void Awake() | |
{ | |
var threshold = .5f; | |
var mouseDownStream = this.UpdateAsObservable() | |
.Where(_ => Input.GetMouseButtonDown(0)); | |
var mouseUpStream = this.UpdateAsObservable() | |
.Where(_ => Input.GetMouseButtonUp(0)); | |
var mouseStream = this.UpdateAsObservable() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.UpdateAsObservable() | |
.TakeUntil(this.UpdateAsObservable().Where(_ => Input.GetMouseButtonUp(0))) | |
.Scan(new List<Vector3>(), (list, _) => | |
{ | |
Debug.Log("Scan"); | |
return list; | |
}) | |
.Where(list => | |
{ | |
Debug.Log("Where"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int ToInt(string str) | |
{ | |
return str | |
.ToCharArray() | |
.Reverse() | |
.Select((c, i) => new KeyValuePair<int, int>(i, (int)c - (int)'A' + 1)) | |
.Aggregate(0, (sum, pair) => sum + pair.Value * (int)Math.Pow(26, pair.Key)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var encrypted = CryptoJS.AES.encrypt('message', 'pass'); | |
console.log(encrypted.salt.toString()); // 467c08b2364309e8 | |
console.log(encrypted.key.toString()); // 6e475a9672994638c4231bd750ab7aceeb9004229f0a26c3622a2045deb789e9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty(String.prototype, 'f', { | |
get: function () { | |
var body = this; | |
return function () { | |
var params = []; | |
var args = []; | |
for (var i = 0; i < arguments.length; i++) { | |
params.push('$' + i); | |
args.push('arguments[' + i + ']'); | |
} |