Skip to content

Instantly share code, notes, and snippets.

View marcelstoer's full-sized avatar
👨‍👩‍👧‍👧
The Earth was made round so that we would not see too far down the road - K.B.

Marcel Stör marcelstoer

👨‍👩‍👧‍👧
The Earth was made round so that we would not see too far down the road - K.B.
View GitHub Profile
@marcelstoer
marcelstoer / spring-security-logout-without-csrf.xml
Last active March 1, 2016 12:42
Spring Security logout without CSRF protection
...
<!-- http://docs.spring.io/spring-security/site/docs/4.0.x/reference/htmlsingle/#filter-stack -->
<!-- logout w/o CSRF protection if logout filter is placed before the CSRF filter -->
<security:custom-filter before="CSRF_FILTER" ref="logoutFilter" />
</security:http>
<bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">
<constructor-arg name="logoutSuccessUrl" value="place-whatever-you-need-here" />
<constructor-arg name="handlers">
<list>
@marcelstoer
marcelstoer / net-send-queue.lua
Last active May 16, 2016 19:33
NodeMCU net send queue
------------------------------------------------------------------------------
-- Net send queueing helper
--
-- Created by devsaurus for https://github.com/nodemcu/nodemcu-firmware/pull/1207
--
-- See also
-- https://nodemcu.readthedocs.io/en/dev/en/modules/net/#netsocketsend
--
-- Based on Vladimir Dronnikov's
-- MQTT queuing publish helper
@marcelstoer
marcelstoer / moody.lua
Last active June 9, 2016 19:35
Moody: NodeMCU with MAX7219 8x8 matrix display (SPI)
MAX7219_REG_NOOP = 0x00
MAX7219_REG_DECODEMODE = 0x09
MAX7219_REG_INTENSITY = 0x0A
MAX7219_REG_SCANLIMIT = 0x0B
MAX7219_REG_SHUTDOWN = 0x0C
MAX7219_REG_DISPLAYTEST = 0x0F
happy = {0x3C, 0x42, 0xA5, 0x81, 0xA5, 0x99, 0x42, 0x3C}
frown = {0x3C, 0x42, 0xA5, 0x81, 0xBD, 0x81, 0x42, 0x3C}
sad = {0x3C, 0x42, 0xA5, 0x81, 0x99, 0xA5, 0x42, 0x3C}
@marcelstoer
marcelstoer / rotate-8x8-matrix-char_traditional.lua
Last active June 16, 2016 21:41
http://wp.me/pzoQb-sN shows how to draw to MAX7219 8x8 matrix displays, this gist shows the maybe "traditional" way of rotating characters
local numberToTable = function(number, base, minLen)
local t = {}
repeat
local remainder = number % base
table.insert(t, 1, remainder)
number = (number - remainder) / base
until number == 0
if #t < minLen then
-- "pad" table with 0s
for i = 1, minLen - #t do table.insert(t, 1, 0) end
@marcelstoer
marcelstoer / rotate-8x8-matrix-char_convert-while-rotating.lua
Created June 16, 2016 21:48
http://wp.me/pzoQb-sN shows how to draw to MAX7219 8x8 matrix displays, this gist shows how the convert the numbers while rotating
local numberToTable = function(number, base, minLen)
local t = {}
repeat
local remainder = number % base
table.insert(t, 1, remainder)
number = (number - remainder) / base
until number == 0
if #t < minLen then
-- "pad" table with 0s
for i = 1, minLen - #t do table.insert(t, 1, 0) end
@marcelstoer
marcelstoer / rotate-8x8-matrix-char_convert-while-rotating-no-matrix.lua
Created June 16, 2016 21:55
http://wp.me/pzoQb-sN shows how to draw to MAX7219 8x8 matrix displays, this gist shows how the convert the numbers while rotating without the use of a 0|1 matrix
local rotate = function(char, rotateleft)
local tab = {}
local newTable = {}
local numberToString = function(number, base, minLen)
local s = ""
repeat
local remainder = number % base
s = remainder .. s
number = (number - remainder) / base
@marcelstoer
marcelstoer / wifi-watch.lua
Last active October 24, 2016 21:50
Keep NodeMCU connected to WiFi
-- If you have a recent firmware from the dev branch you could do away with that ugly timer
-- by relying on WiFi events and (re-)acting accordingly. See wifi.sta.eventMonReg() at
-- https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en#wifistaeventmonreg
-- init all globals
...
wifiReady = 0
function configureWiFi()
@marcelstoer
marcelstoer / nodemcu-execution-time.lua
Created April 15, 2017 21:05
How to measure the execution time of a NodeMCU Lua function
-- all credits go to http://www.esp8266.com/viewtopic.php?p=64968#p64968
function profile(name)
local start = tmr.now()
_G[name]()
local delta = tmr.now() - start
print(name .. " needs " .. (delta / 1000) .. " ms")
end
function longTime()
local sum = 0
@marcelstoer
marcelstoer / HtmlPopupTransientWindow.py
Created September 19, 2017 06:30
wxPython transient window with HTML support, selectable text and clickable links
# coding=utf-8
import wx
import wx.html
import webbrowser
class HtmlPopupTransientWindow(wx.PopupTransientWindow):
def __init__(self, parent, style, html_body_content, bgcolor, size):
@marcelstoer
marcelstoer / init.lua
Created June 3, 2018 19:00
NodeMCU Lua initializer with DNS & internet connectivity testing
WIFI_SSID = "--your-value-here--"
WIFI_PASSWORD = "--your-value-here--"
wifi_got_ip_event = function(T)
local site = "wikipedia.org"
-- Note: Having an IP address does not mean there is internet access!
-- Internet connectivity can be determined with net.dns.resolve().
print("WiFi connection is established! IP address is: " .. T.IP)
print("DNS server 1: " .. net.dns.getdnsserver(0))
print("DNS server 2: " .. net.dns.getdnsserver(1))