Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Having fun

Alexander Fallenstedt Fallenstedt

:octocat:
Having fun
View GitHub Profile
@Fallenstedt
Fallenstedt / safebuffer.go
Created May 19, 2021 — forked from arkan/safebuffer.go
Golang: Buffer is a goroutine safe bytes.Buffer
View safebuffer.go
package safebuffer
import (
"bytes"
"sync"
)
// Buffer is a goroutine safe bytes.Buffer
type Buffer struct {
buffer bytes.Buffer
@Fallenstedt
Fallenstedt / docker_export_postgre_table.sh
Last active May 17, 2021 — forked from gh0st026/docker_export_postgre_table.sh
Dump PostgreSQL Table in docker container as CSV file
View docker_export_postgre_table.sh
CONTAINER="name"
DB="Db name"
TABLE="Table Name"
FILE="file.csv"
sudo docker exec -u postgres ${CONTAINER} psql -d ${DB} -c "COPY ${TABLE} TO STDOUT WITH CSV HEADER " > ${FILE}
# Copy csv to table
# sudo psql -h localhost -U root -d my_db -p 5432 -c "\COPY source_table TO '/home/user/source_table.csv' DELIMITER ',' CSV HEADER;"
View trafficlight.ino
int switchState = 0;
// pins
const int BUTTON = 2;
const int RED_LED = 3;
const int YELLOW_LED = 4;
const int GREEN_LED = 5;
void setup() {
@Fallenstedt
Fallenstedt / encrypt_decrypt.go
Created Nov 12, 2020
Encrypting and Decrypting in go
View encrypt_decrypt.go
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/hex"
"fmt"
"io"
)
View keybase.md

Keybase proof

I hereby claim:

  • I am fallenstedt on github.
  • I am fallenstedt (https://keybase.io/fallenstedt) on keybase.
  • I have a public key ASC9XKEzj4DsJZDXNeszL8jAlaLxCHhC1esNgTCRlTXaUQo

To claim this, I am signing this object:

View error.txt
[ ] > Task :device_info:preBuild UP-TO-DATE
[ ] > Task :device_info:preDebugBuild UP-TO-DATE
[ ] > Task :device_info:checkDebugManifest UP-TO-DATE
[ ] > Transform firebase-messaging.aar (com.google.firebase:firebase-messaging:20.0.1) with AarTransform
[ ] > Transform firebase-messaging.aar (com.google.firebase:firebase-messaging:20.0.1) with AarTransform
[ ] > Task :device_info:processDebugManifest UP-TO-DATE
[ ] > Task :firebase_analytics:preBuild UP-TO-DATE
[ ] > Task :firebase_analytics:preDebugBuild UP-TO-DATE
[ ] > Task :firebase_analytics:checkDebugManifest UP-TO-DATE
[ ] > Task :firebase_analytics:processDebugManifest UP-TO-DATE
View dayOfWeek.kt
import java.util.*
fun main(args: Array<String>) {
dayOfWeek()
}
fun dayOfWeek() {
println("What day is it today?")
val dayOfWeek: Int = Calendar.getInstance().get(Calendar.DAY_OF_WEEK)
View productkey.vbs
Set WshShell = CreateObject("WScript.Shell")
MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))
Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
x = 14
@Fallenstedt
Fallenstedt / bloc.dart
Last active Jan 29, 2019
A simple bloc example
View bloc.dart
import 'dart:async';
import 'validators.dart';
import 'package:rxdart/rxdart.dart';
class Bloc with Validators {
final _email = BehaviorSubject<String>();
final _password = BehaviorSubject<String>();
Stream<String> get email => _email.stream.transform(validateEmail);
Stream<String> get password => _password.stream.transform(validatePassword);
View Button Click Stream.dart
import 'dart:html';
void main() {
final buttonElement = document.querySelector('button');
buttonElement.onClick.timeout(
new Duration(seconds: 1),
onTimeout: (sink) => sink.addError('BOOM!')
)
.listen(