Skip to content

Instantly share code, notes, and snippets.

View pinkninjajess's full-sized avatar

Jessica Valenti pinkninjajess

  • Nuremberg, Germany
  • 11:30 (UTC +02:00)
View GitHub Profile
@jmcdo29
jmcdo29 / gist:f9d4d3effc2d55996341ce18fe0cb6d3
Last active September 20, 2024 09:28
Testing Observables with Jest

I've run into trouble in the past with testing observables, so I figured I would make myself a gist to help myself remember, and to help others who find it.

Observables are rather tricky to test in general as they are made to be asynchronous and act like a stream, and up until recently it was acceptable to pass a next, error, and complete callback function, but now that method is bieng deprecated in favor of Observers. Fear not! An Observer is just like the three callbacks rolled into a signle object, plus other fields you would like to add :).

Say that we have the following Observable

const numbersArray = from([1,2,3,4,5]);
@gaearon
gaearon / modern_js.md
Last active September 29, 2024 07:57
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@TilakMaddy
TilakMaddy / Main.java
Last active September 6, 2024 18:02
A Java Starter Template for competitive programming in CodeChef, Hackerrank, etc w/ efficient coding rules and pre-designed pattern Ready to Use
/*
* No package must be added here because some Online Judges don't support it
* please remove, if any.
*
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
@gtallen1187
gtallen1187 / scar_tissue.md
Created November 1, 2015 23:53
talk given by John Ousterhout about sustaining relationships

"Scar Tissues Make Relationships Wear Out"

04/26/2103. From a lecture by Professor John Ousterhout at Stanford, class CS142.

This is my most touchy-feely thought for the weekend. Here’s the basic idea: It’s really hard to build relationships that last for a long time. If you haven’t discovered this, you will discover this sooner or later. And it's hard both for personal relationships and for business relationships. And to me, it's pretty amazing that two people can stay married for 25 years without killing each other.

[Laughter]

> But honestly, most professional relationships don't last anywhere near that long. The best bands always seem to break up after 2 or 3 years. And business partnerships fall apart, and there's all these problems in these relationships that just don't last. So, why is that? Well, in my view, it’s relationships don't fail because there some single catastrophic event to destroy them, although often there is a single catastrophic event around the the end of the relation

@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active August 24, 2024 07:35
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@Jim-Holmstroem
Jim-Holmstroem / numpy_array_hash.py
Created February 21, 2012 10:51
Hash numpy.array
from hashlib import sha1
import numpy
arr=numpy.zeros((256,256,4))
sha1(arr)