Skip to content

Instantly share code, notes, and snippets.

View thomasw-mitutoyo-ctl's full-sized avatar

Thomas Weller thomasw-mitutoyo-ctl

View GitHub Profile
@thomasw-mitutoyo-ctl
thomasw-mitutoyo-ctl / gist:9dc43e0ec0d41af970d3a5c755c1cb74
Last active April 26, 2018 14:53 — forked from pdwetz/gist:5368441
Outputs a POCO for a given MySql table. Based on http://stackoverflow.com/a/13918084/21865 with changes for ShaoLinq.
select 'replacewithtablename' into @table;
select 'replacewithdatabasename' into @schema;
select GROUP_CONCAT(r.x SEPARATOR '\n') from
(
select '[DataAccessObject]'as x,'grp'as grp union
select concat('public abstract class ',@table,'{') as x, 'grp' as grp
union
select concat('[PersistedMember]\npublic abstract ',tps.dest,IF(tps.dest = 'string', ' ', IF(is_nullable = 'NO', ' ', '? ')), REPLACE(column_name, ' ', ''),' {get;set;}'), 'grp'
from time import sleep
from luma.core.render import canvas
from luma.led_matrix.device import ws2812
'''
Pin connections:
VCC (red): 5 Volt, don't use Raspberry's power, because it may draw a lot of current
DIN (green): Pin 12, GPIO18
GND (white): Common ground
'''
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
from luma.core.legacy import text
from luma.core.legacy.font import LCD_FONT, proportional
from luma.led_matrix.device import max7219
from time import sleep
serial = spi(port=0, device=0, gpio=noop())
scoreboard = max7219(serial, cascaded=4, block_orientation=-90)
scoreboard.contrast(20)
@thomasw-mitutoyo-ctl
thomasw-mitutoyo-ctl / ziffer3_mathematisch_vonhinten.dart
Created March 10, 2022 08:36
Zahlen mit der Ziffer 3 (mathematisch von hinten)
void main() {
var anzahlZahlenMitDrei = 0;
for (var i = 100; i <= 999; i++) {
var zahl = i;
while (zahl > 0) {
var letzteZiffer = zahl % 10;
if (letzteZiffer == 3) {
anzahlZahlenMitDrei++;
break; // while-Schleife beenden
}
import "dart:math" as math;
void main() {
var anzahlZahlenMitDrei = 0;
for (var i = 100; i <= 999; i++) {
for (int stelle = 6; stelle > 0; stelle--) {
var wertigkeit = math.pow(10, stelle).toInt(); // 10^stelle
var hintenAbgeschnitten = i ~/ (wertigkeit ~/ 10);
var vorneAbgeschnitten = hintenAbgeschnitten % 10;
if (vorneAbgeschnitten == 3) {
void main() {
var anzahlZahlenMitDrei = 0;
for (var i = 100; i <= 999; i++) {
// Nachteil: muss für jede weitere Stelle zusätzlich programmiert werden, z.B. Tausender
var hunderter = i ~/ 100;
var zehner = (i - hunderter * 100) ~/ 10;
var einer = (i - hunderter * 100 - zehner * 10);
if (hunderter == 3 || zehner == 3 || einer == 3) {
anzahlZahlenMitDrei++;
}
@thomasw-mitutoyo-ctl
thomasw-mitutoyo-ctl / ziffer3_textuell_substring.dart
Created March 10, 2022 08:55
Zahlen, die die Ziffer 3 enthalten, gelöst mit Substring
void main() {
var anzahlZahlenMitDrei = 0;
for (var i = 100; i <= 999; i++) {
var text = i.toString();
// Nachteil: muss für jede weitere Stelle zusätzlich programmiert werden, z.B. Tausender
var hunderter = text.substring(0,1);
var zehner = text.substring(1,2);
var einer = text.substring(2,3);
if (hunderter == "3" || zehner == "3" || einer == "3") {
anzahlZahlenMitDrei++;
@thomasw-mitutoyo-ctl
thomasw-mitutoyo-ctl / powerfunction.dart
Created March 22, 2022 13:36
Programmiere eine Funktion, die das gleiche Ergebnis liefert wie math.pow(), jedoch nur für Zahlen in N0
void main() {
print(pow(2,3));
print(pow(2,4));
print(pow(3,3));
print(pow(2,0));
}
int pow(int basis, int exponent)
{
int ergebnis = 1;
@thomasw-mitutoyo-ctl
thomasw-mitutoyo-ctl / minimum.dart
Created March 22, 2022 13:40
Schreibe eine Funktion, die aus einer Liste mit Zahlen die kleinste heraussucht.
void main() {
var liste = [1,5,9,1,0,-5,9];
print(minimum(liste));
}
int minimum(List zahlen)
{
int min = zahlen[0];
for (int zahl in zahlen)
{
void onDelete(int i)
{
print(2);
print(i);
}
void main()
{
var lambda = () => onDelete(5);
lambda();