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
sendJson : Cmd Msg | |
sendJson = | |
let | |
json = | |
Http.jsonBody (Json.Encode.object []) | |
in | |
Http.send SendEmptyJsonMsg | |
(Http.post "api/empty-json" json (Json.Decode.succeed "")) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# following code uses recursion, so it may run out of stack memeory for large collections | |
def flatten(container): | |
"""generate a flatten sequence from the input list""" | |
for i in container: | |
if isinstance(i, (list, tuple)): | |
for j in flatten(i): | |
yield j | |
else: | |
yield i |
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
Show hidden characters
{ | |
"always_show_minimap_viewport": true, | |
"bold_folder_labels": true, | |
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme", | |
"folder_exclude_patterns": | |
[ | |
".svn", | |
".git", | |
".hg", | |
"CVS", |
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 reverse_bits(x): | |
out = 0 | |
len = 0 | |
num = x | |
while num > 0: | |
num /= 2 | |
len += 1 | |
for i in xrange(0, len): | |
bit = x >> i & 1 | |
out |= bit << (len - 1 - i) |
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 bit is important. It detects/adds XMLHttpRequest.sendAsBinary. Without this | |
// you cannot send image data as part of a multipart/form-data encoded request from | |
// Javascript. This implementation depends on Uint8Array, so if the browser doesn't | |
// support either XMLHttpRequest.sendAsBinary or Uint8Array, then you will need to | |
// find yet another way to implement this. (This is left as an exercise for the reader, | |
// but if you do it, please let me know and I'll integrate it.) | |
// from: http://stackoverflow.com/a/5303242/945521 | |
if ( XMLHttpRequest.prototype.sendAsBinary === undefined ) { |
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
/// <summary> | |
/// Generates AntiForgery Tokens | |
/// </summary> | |
public static class AntiForgeryTokensGenerator | |
{ | |
private const string ConstantSalt = "b8YagDpYwB"; | |
private static readonly RandomNumberGenerator CryptoRandomDataGenerator = new RNGCryptoServiceProvider(); | |
// buffer for random string with 32 bytes of entropy |
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
# -*- coding: utf-8 -*- | |
"""Convert Unicode text into plain ASCII string.""" | |
# for brevity the table is kept simple | |
CONVERSION_TABLE = { | |
u"\u0394": "D", | |
u"\u03b1": "a", | |
u"\u03bd": "n", | |
u"\u03ac": "a", | |
u"\u03b7": "e" |
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
"use latest"; | |
let MongoClient = require('mongodb').MongoClient; | |
const questions = ` | |
<html> | |
<head> | |
<title>Euler problems</title> | |
</head> | |
<body> |
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.Linq; | |
namespace EnumTest | |
{ | |
public enum ContentAreaTagEnum | |
{ | |
Unknown, | |
[ContentArea(Name = "Full")] |
NewerOlder