Skip to content

Instantly share code, notes, and snippets.

View utzig's full-sized avatar

Fabio Utzig utzig

  • Brazil
View GitHub Profile
@utzig
utzig / gist:52213b644be8ffb27077
Created July 15, 2015 10:12
Add missing port functions for freerunning mode on RT
Index: os/rt/ports/AVR/chcore.h
===================================================================
--- os/rt/ports/AVR/chcore.h (revision 8095)
+++ os/rt/ports/AVR/chcore.h (revision 8096)
@@ -381,6 +381,10 @@
}
#endif
+#if CH_CFG_ST_TIMEDELTA > 0
+#include "chcore_timer.h"
@utzig
utzig / gist:263173f80c03eb187d01
Created July 26, 2015 14:05
ATmega1280 Tickless
*** ChibiOS/RT test suite
***
*** Kernel: 3.0.0
*** Compiled: Jul 26 2015 - 10:38:20
*** Compiler: GCC 4.8.1
*** Architecture: AVR
*** Core Variant: MegaAVR
*** Port Info: None
*** Platform: AVR
*** Test Board: Arduino Mega
@utzig
utzig / gist:b2552e40ac3e4cb96052
Created July 26, 2015 14:07
ATmega1280 periodic
*** ChibiOS/RT test suite
***
*** Kernel: 3.0.0
*** Compiled: Jul 26 2015 - 11:05:59
*** Compiler: GCC 4.8.1
*** Architecture: AVR
*** Core Variant: MegaAVR
*** Port Info: None
*** Platform: AVR
*** Test Board: Arduino Mega
@utzig
utzig / gist:f89864ec1169fecc7982
Created July 28, 2015 22:37
ChibiOS/RT 3.0 Periodic NRF51822
*** ChibiOS/RT test suite
***
*** Kernel: 3.0.0
*** Compiled: Jul 28 2015 - 19:33:15
*** Compiler: GCC 4.8.4 20140725 (release) [ARM/embedded-4_8-branch revision 213147]
*** Architecture: ARMv6-M
*** Core Variant: Cortex-M0
*** Port Info: Preemption through NMI
*** Platform: Nordic Semiconductor nRF51822
*** Test Board: WvShare BLE400
@utzig
utzig / islands.py
Created September 2, 2015 21:35
Counter number of islands in a map
#!/usr/bin/env python
test_cases = [
# small, no island
([
"00",
"00",
],
0
@utzig
utzig / islands.py
Created September 2, 2015 22:31
Count number of islands (fixed)
#!/usr/bin/env python
test_cases = [
# small, no island
([
"00",
"00",
],
0
ENTRY(Reset_Handler)
MEMORY
{
flash : org = 0x00000d10, len = 128k - 0xd10
ram : org = 0x1FFFE000, len = 16k
}
__ram_start__ = ORIGIN(ram);
__ram_size__ = LENGTH(ram);
@utzig
utzig / perm_missing.py
Created February 4, 2016 12:42
Codility - Perm missing element
def solution(A):
found = [False] * (len(A) + 1)
for v in A:
found[v-1] = True
return found.index(False) + 1
@utzig
utzig / dominator.py
Created February 5, 2016 12:07
Dominator
def solution(A):
o = {}
for v in A:
o[v] = o.get(v, 0) + 1
import operator
s = sorted(o.items(), key=operator.itemgetter(1))
s.reverse()
return A.index(s[0][0])
@utzig
utzig / project_euler_23.py
Created April 8, 2016 12:03
Project Euler 23
#!/usr/bin/env python3
# A perfect number is a number for which the sum of its proper divisors
# is exactly equal to the number. For example, the sum of the proper
# divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28
# is a perfect number.
# A number n is called deficient if the sum of its proper divisors is
# less than n and it is called abundant if this sum exceeds n.