Skip to content

Instantly share code, notes, and snippets.

View SunKing2's full-sized avatar

Louie van Bommel SunKing2

View GitHub Profile
@SunKing2
SunKing2 / reading_firestore_collection.md
Last active August 27, 2023 04:44
Reading Firestore Firebase collection 2023 with javascript using bun run index.js

Reading a Firebase Firestore collection with JavaScript

Create file in current directory called index.js

Do yourself a favor, and instal Bun (a replacement for NodeJS) and run it with Bun

import { initializeApp } from "firebase/app";
import { getFirestore, collection, getDocs, addDoc } from 'firebase/firestore/lite';
@SunKing2
SunKing2 / asdf.md
Last active October 15, 2023 15:40

asdf cheatsheet

Install Perl and set as current:

asdf plugin-add perl # gotta install for each language
asdf list-all perl  # show all available version #s
asdf install perl 5.38.0
asdf global perl 5.38.0 #(do this!!!, more info below)
asdf plugin list all | grep -i graal # see if there's a plugin for graalvm or graal or something like that
@SunKing2
SunKing2 / gotchas_in_perl7.txt
Created July 18, 2023 00:49
Gotchas in perl 7
Gotchas in perl 7
Class:
- you can't just initialize any field using a constructor.
: it must have :param on it
field $employee_number: param;
@SunKing2
SunKing2 / make_c_run_rust.sh
Created July 15, 2023 06:11
Run Rust from Perl (and from C)
set -e
cat > prime.rs <<EOF
#[no_mangle]
pub extern "C" fn is_prime(n: u64) -> bool {
if n <= 1 {
return false;
}
// check if even
if n % 2 == 0 {
return n == 2;
@SunKing2
SunKing2 / MyRealArray.pm
Created July 4, 2023 14:43
How to use plain arrays with Perl Moose
package MyRealArray;
use Moose;
use namespace::autoclean;
has 'arr' => (
is => 'rw',
isa => 'ArrayRef',
default => sub { [] },
);
@SunKing2
SunKing2 / gist:cd32371c56b223ad86d6c36176649764
Created June 10, 2023 04:45
object oriented with Moose and perl (it uses an array too!)
# Sources:
# Mastering Object-Oriented Perl Programming (OOP): Unleashing the Power of OOP in Perl (YouTube, last 2 minutes!!!!)
# Docs for Moose::Meta::Attribute::Native::Trait::Array
# probably at: https://metacpan.org/pod/Moose::Meta::Attribute::Native::Trait::Array
# GlobalStuff.pm in current directory
package GlobalStuff;
use Moose;
has 'name' => (is=>'ro' , isa=>'Str' , default=>'');
@SunKing2
SunKing2 / perl-tdd.txt
Created June 13, 2017 06:10
Perl tdd : test driven development with Object Oriented Programming and Classes
# We'll create Scramble::Game and test it.
# Adapted from book "Perl Medic" (Chapter on Testing)
h2xs -AXn Scramble::Game
cd Scramble-Game
perl Makefile.PL
make test
mv t/Scramble-Game.t t/01_basics.t
sed -i '/t\/Scramble-Game.t/ d' MANIFEST # remove .t file from MANIFEST
perl -0777 -i.original -pe 's/\A.*use strict/#\/usr\/bin\/perl\nuse strict/igsm' t/01_basics.t
perl -0777 -i.original -pe 's/^###.*$//igsm' t/01_basics.t
@SunKing2
SunKing2 / pythonmongodb.txt
Last active May 27, 2017 21:20
python mongodb create and retrieve Ubuntu 17.04 continuous testing with unittest
sudo apt-get install -y python3.6 python3-pip virtualenv mongodb
sudo systemctl start mongodb
virtualenv -p /usr/bin/python3.6 --distribute myproject
source myproject/bin/activate
pip install --upgrade pip
python -m pip install pymongo
pip install PyZen
cat > test_mongo.py <<EOL
import unittest
from pymongo import MongoClient
@SunKing2
SunKing2 / standalone-jasmine.txt
Created May 20, 2017 05:52
Testing Javascript with standalone jasmine
If this link doesn't work, go to next step:
https://github.com/jasmine/jasmine/releases
download latest version of standalone jasmine from that link or search Google for "standalone jasmine".
Follow this tutorial:
https://code.tutsplus.com/tutorials/testing-your-javascript-with-jasmine--net-21229
Here's my version of the code:
// src/convert.js
function Convert(iAmount, sUnitFrom) {
@SunKing2
SunKing2 / karma-jasmine-ubuntu
Last active May 20, 2017 12:46
setup karma as continuous runner of jasmine ubuntu 17.04
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get update
sudo apt-get install -y nodejs
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install -y yarn
yarn init -y
yarn add karma karma-jasmine karma-chrome-launcher jasmine-core
sudo yarn global add karma-cli