Skip to content

Instantly share code, notes, and snippets.

View fwojciec's full-sized avatar

Filip Wojciechowski fwojciec

View GitHub Profile
// this pattern subscribes adds item to an array when subscribe function
// is is assigned to a variable, and unsubscribes when this variable is eventually called
// taken from Redux tutorial
// https://egghead.io/lessons/react-redux-implementing-store-from-scratch
// also discussed here
// https://stackoverflow.com/questions/35304790/es6-redux-returning-a-function-to-remove-event-listener
let listeners = []
@fwojciec
fwojciec / decorator.py
Created December 5, 2017 20:03
Python Simple Decorator Template
import functools
def my_decorator(func):
@functools.wraps(func)
def function_that_runs_func():
print('Before the decorated function!')
func()
print('After the decorated function!')
return function_that_runs_func
@fwojciec
fwojciec / decorator_with_arguments.py
Created December 5, 2017 20:08
Python Decorator with Arguments Template
import functools
def my_decorator_with_arguments(arg):
def my_decorator(func):
@functools.wraps
def function_that_runs_func(*args, **kwargs):
print('Before the decorated func!')
if arg:
print('Not running the func!')
else:
// based on https://www.youtube.com/watch?v=mth5WpEc4Qs
"use strict";
var add1 = function add1(num) {
return num + 1;
};
var doubleIt = function doubleIt(num) {
return num * 2;
};
@fwojciec
fwojciec / RemoveAttachments.vba
Created June 20, 2018 14:51
RemoveAttachments
Sub RemoveAttachments()
Dim objSelection As Outlook.Selection
Dim i, n As Long
Dim objMail As Outlook.MailItem
Dim objAttachment As Outlook.Attachment
'Get the selected emails
Set objSelection = Outlook.Application.ActiveExplorer.Selection
'Process each email one by one
@fwojciec
fwojciec / go-web-workshop_s01-e4.go
Last active July 23, 2018 09:15
My solution to "Exercise queries" from Section 01 of Francesc Campoy's Go Web Workshop
// https://github.com/campoy/go-web-workshop/blob/master/section01/README.md
package main
import (
"io"
"log"
"net/http"
"os"
)
@fwojciec
fwojciec / go-web-workshop_s01-e3.go
Created July 23, 2018 06:53
My solution to "Exercise PUT request" from Section 01 of Francesc Campoy's Go Web Workshop
// https://github.com/campoy/go-web-workshop/blob/master/section01/README.md
package main
import (
"fmt"
"log"
"net/http"
"strings"
)
@fwojciec
fwojciec / go-web-workshop_s01-e2.go
Last active July 23, 2018 09:14
My solution to "Exercise body" from Section 01 of Francesc Campoy's Go Web Workshop
// https://github.com/campoy/go-web-workshop/blob/master/section01/README.md
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
@fwojciec
fwojciec / go-web-workshop_s01-e1.go
Created July 23, 2018 07:00
My solution to "Exercise status codes" from Section 01 of Francesc Campoy's Go Web Workshop
// https://github.com/campoy/go-web-workshop/blob/master/section01/README.md
package main
import (
"fmt"
"net/http"
)
func main() {
res, err := http.Get("https://golang.org/ssssdfasdfa")
@fwojciec
fwojciec / go-web-workshop_s02-e1.go
Created July 23, 2018 08:06
My solution to "Exercise Bye, web" from Section 02 of Francesc Campoy's Go Web Workshop
// https://github.com/campoy/go-web-workshop/blob/master/section02/README.md
package main
import (
"fmt"
"log"
"net/http"
)
func helloHandler(w http.ResponseWriter, r *http.Request) {