Skip to content

Instantly share code, notes, and snippets.

from numpy.random import choice as random_choice, randint as random_randint, rand
MAX_INPUT_LEN = 40
AMOUNT_OF_NOISE = 0.2 / MAX_INPUT_LEN
CHARS = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .")
def add_noise_to_string(a_string, amount_of_noise):
"""Add some artificial spelling mistakes to the string"""
if rand() < amount_of_noise * len(a_string):
# Replace a character with a random character
random_char_position = random_randint(len(a_string))
//natural code with no code alignment and you can see that
//readability of the code is not that good
var people1 = new List<Person>()
{
new Person { Name = "Benita", Location = "Bareilly India", Age = 25 },
new Person { Name = "Deedee Almon Fonsec", Location = "Bari Italy", Age = 32 } ,
new Person { Name = "Chase Hussain", Location = "Barika Algeria", Age = 45 } ,
new Person { Name = "Cordia", Location = "Barinas Venezuela", Age = 26 } ,
new Person { Name = "Malvina Neff", Location = "Barisal Bangladesh", Age = 36 } ,
new Person { Name = "Erika ", Location = "Barnaul Russia", Age = 56 } ,
//same above code with column indention
var people2 = new List<Person>()
{
new Person { Name = "Benita" , Location = "Bareilly India" , Age = 25 } ,
new Person { Name = "Deedee Almon Fonsec" , Location = "Bari Italy" , Age = 32 } ,
new Person { Name = "Chase Hussain" , Location = "Barika Algeria" , Age = 45 } ,
new Person { Name = "Cordia" , Location = "Barinas Venezuela" , Age = 26 } ,
new Person { Name = "Malvina Neff" , Location = "Barisal Bangladesh" , Age = 36 } ,
new Person { Name = "Erika " , Location = "Barnaul Russia" , Age = 56 } ,
new Person { Name = "Lisabeth Terr" , Location = "Barquisimeto Venezuela" , Age = 67 } ,
var benita = new Person() { Name = "Benita" };
var deedeeAlmon = new Person() { Name = "Deedee Almon Fonsec" };
var chaseHussain = new Person() { Name = "Chase Hussain" };
var cordia = new Person() { Name = "Cordia" };
benita.Age = 35;
deedeeAlmon.Age = 12;
chaseHussain.Age = 24;
cordia.Age = 22;
var benita = new Person ( ) { Name = "Benita" } ;
var deedeeAlmon = new Person ( ) { Name = "Deedee Almon Fonsec" } ;
var chaseHussain = new Person ( ) { Name = "Chase Hussain" } ;
var cordia = new Person ( ) { Name = "Cordia" } ;
benita . Age = 35 ;
deedeeAlmon . Age = 12 ;
chaseHussain . Age = 24 ;
cordia . Age = 22 ;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Example_02.NoIndention
{
class SyntaxToken
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Example_02.ColumnIndention
{
class SyntaxToken
{
@kudchikarsk
kudchikarsk / data.service.ts
Last active April 20, 2019 13:57
Angular Error Handling
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { map, tap, catchError } from 'rxjs/operators';
import { allBooks, allReaders } from 'app/data';
import { Reader } from "app/models/reader";
import { Book } from "app/models/book";
import { BookTrackerError } from 'app/models/bookTrackerError';
import { OldBook } from 'app/models/oldBook';
@kudchikarsk
kudchikarsk / resolver.service.ts
Last active April 20, 2019 13:54
Angular Resolver
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Observable, of } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { Book } from 'app/models/book';
import { DataService } from 'app/core/data.service';
import { BookTrackerError } from 'app/models/bookTrackerError';
@Injectable({