A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
using System; | |
using System.Text; | |
namespace NodeIPC | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var input = Console.OpenStandardInput(); |
public class ObjectIdConverter : TypeConverter | |
{ | |
public override bool CanConvertFrom(ITypeDescriptorContext context, | |
Type sourceType) | |
{ | |
if (sourceType == typeof(string)) | |
return true; | |
return base.CanConvertFrom(context, sourceType); | |
} |
function randcolorhue(rgb) { //generate random color with same colore tone | |
var hsl = rgb2hsl(rgb); | |
var newhsl = [ Math.min(hsl[0]*minmaxrandom(0.95,1.05),1), hsl[1]*minmaxrandom(0.7,1), Math.min(hsl[2]*minmaxrandom(0.8,1.2),1) ]; | |
//stessa tonalita' | |
return hsl2rgb(newhsl); | |
} | |
function minmaxrandom(min, max) //genera numero casuale compreso in un range di valori | |
{ | |
return Math.random() * (max - min) + min; |
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace Tinmar.Domain.Common | |
{ | |
public sealed class ConcurrentList<T> : IList<T> | |
{ | |
private readonly IList<T> _items = new List<T>(); |
// Copyright © 2014 Rick Beerendonk. All Rights Reserved. | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS-IS" BASIS, |
// Part of https://github.com/chris-rock/node-crypto-examples | |
var crypto = require('crypto'), | |
algorithm = 'aes-256-ctr', | |
password = 'd6F3Efeq'; | |
function encrypt(buffer){ | |
var cipher = crypto.createCipher(algorithm,password) | |
var crypted = Buffer.concat([cipher.update(buffer),cipher.final()]); | |
return crypted; |
To remove a submodule you need to:
public class ConcurrentList<T> : IList<T>, IDisposable | |
{ | |
private ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); | |
private int _count = 0; | |
public int Count | |
{ | |
get | |
{ | |
_lock.EnterReadLock(); |
ZigZag-Encoding | |
--------------- | |
Maps negative values to positive values while going back and | |
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...) | |
(i >> bitlength-1) ^ (i << 1) | |
with "i" being the number to be encoded, "^" being | |
XOR-operation and ">>" would be arithemtic shifting-operation |