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
def flatEnumerate(obj, prefix='root'): | |
if isinstance(obj, int): | |
return [{ prefix: obj }] | |
elif isinstance(obj, list): | |
res = [] | |
for option in obj: | |
res.extend(flatEnumerate(option, prefix)) | |
return res | |
elif isinstance(obj, dict): | |
if len(obj) == 0: return [{}] |
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 <ctime> | |
#include <cstdlib> | |
#include <vector> | |
#include <string> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
const int H = 4; | |
const int W = 8; |
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
// See: http://stackoverflow.com/questions/17218089/salt-and-hash-using-pbkdf2 | |
// See: https://crackstation.net/hashing-security.htm | |
'use strict'; | |
let Promise = require('bluebird'); | |
let crypto = require('crypto'); | |
function calcPassword(password) { | |
const RANDOM_BYTES = 64; |
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 <vector> | |
/** | |
Given an non-decreasing ordered array `arr`, search the biggest `i` that makes `arr[i] == value`. | |
If `i` doesn't exist, return -1 | |
*/ | |
int search_last_match(const std::vector<int>& arr, const int value) | |
{ | |
int lef = 0, rig = static_cast<int>(arr.size()); | |
while (rig-lef > 1) |
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
/* | |
* GET message listing => show() | |
* POST meaasge posting => send() | |
*/ | |
var settings = require('../settings'); | |
var group = require('../models/group'); | |
var mesg = require('../models/mesg'); | |
var md = require('markdown').markdown.toHTML; |
NewerOlder