Skip to content

Instantly share code, notes, and snippets.

@yngwie74
yngwie74 / PY0101EN-1-1-Write_your_first_python_code.ipynb
Created February 24, 2023 02:18
PY0101EN-1-1-Write_your_first_python_code
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yngwie74
yngwie74 / dojo_lcd.py
Created March 12, 2012 23:32
LCD numbers kata and tests (python)
#!/usr/bin/python
# -*- coding: utf-8 -*-
_NONE = ' '
_LEFT = '| '
_MIDL = ' - '
_RGHT = ' |'
_BOTH = '| |'
_SEGMENTS_BY_DIGIT = {
@yngwie74
yngwie74 / LCD.cs
Created March 12, 2012 23:46
LCD numbers kata (C#)
using System.Collections.Generic;
using System.Linq;
namespace ViveCodigo.Katas.LCD
{
/// <summary>
/// Basado en la idea original de @rodrigo_salado
/// </summary>
public class LCD
{
@yngwie74
yngwie74 / run_opencover.py
Created January 9, 2018 22:38
Execute OpenCover with NUnit3 and render output with ReportGenerator
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import sys
import fnmatch
from subprocess import Popen
@yngwie74
yngwie74 / LCD.java
Created March 12, 2012 23:40
LCD numbers kata (java)
package org.vivecodigo.katas.lcd;
import java.util.*;
public class LCD {
private static final String _NONE = " ";
private static final String _LEFT = " |";
private static final String _MIDL = " _ ";
private static final String _MDLT = " _|";
@yngwie74
yngwie74 / cont_test.sh
Created December 15, 2017 00:48
Continuous testing with NUnit/GitBash
#!/bin/bash
_CURRENT_HASH="_new_stat.bak"
_PREVIOUS_HASH="_old_stat.bak"
_ANY_HASH="_???_stat.bak"
function pause() {
local key
read -t$1 -N1 -p"$2" key
case "$key" in
@yngwie74
yngwie74 / clabe.py
Created October 25, 2017 17:01
Cálculo del dígito verificador de la CLABE
#!/usr/bin/env python
from itertools import cycle, izip
def digver(clabe):
mult = cycle((3,7,1))
cta = (int(c) for c in clabe)
res = ((a * b) % 10 for (a, b) in izip(mult, cta))
return 10 - (sum(res) % 10)
namespace ACV.Common.DB
{
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
public static class SqlExtensions
{
private static object GetOrDefault(this IDataRecord record, string columnName, object @default = null)
@yngwie74
yngwie74 / wordwrap.py
Last active December 15, 2015 05:29
Word wrap kata in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
def wrap(s, w):
def split(s, at, gap=0):
return s[:at] + '\n' + wrap(s[at + gap:], w)
@yngwie74
yngwie74 / finddup.py
Created February 27, 2013 10:39
Find duplicate files within a file system sub-tree. It demonstrates a simple way for combining Functional and Object-Oriented Programming techniques -- no religious wars! -- using generator expressions, comprehensions and decorators, among others.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from os import path
from itertools import imap, chain
import fnmatch
# Set the base path to scan for duplicates here
base = r'/media/file-rep/files'