Skip to content

Instantly share code, notes, and snippets.

View LifeIsStrange's full-sized avatar
🎯
Focusing

LifeIsStrange

🎯
Focusing
View GitHub Profile
@keithstric
keithstric / app.component.html
Last active October 21, 2020 13:28
Loading spinner app.component
<!-- Loading spinner -->
<div *ngIf="loading" class="loading-container flex-content-center">
<mat-progress-spinner
color="primary"
mode="indeterminate">
</mat-progress-spinner>
</div>
<!-- the application -->
<div class="site-container">
@Felflare
Felflare / XLNet_span_selection_squad
Created February 10, 2020 03:03
XLNet Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear layers on top of the hidden-states output to compute `span start logits` and `span end logits`). Simple demo of loss and logits.
from transformers import XLNetTokenizer, XLNetForQuestionAnsweringSimple
import torch
tokenizer = XLNetTokenizer.from_pretrained('xlnet-base-cased')
model = XLNetForQuestionAnsweringSimple.from_pretrained('xlnet-base-cased')
input_ids = torch.tensor(tokenizer.encode("Hello, my dog is cute", add_special_tokens=True)).unsqueeze(0) # Batch size 1
print(f'Encoded sequence ids -- {input_ids.tolist()[0]}')
# Encoded sequence ids -- [17, 11368, 19, 94, 2288, 27, 10920, 4, 3]
start_positions = torch.tensor([1])
end_positions = torch.tensor([3])
@Glamdring
Glamdring / ESBulkProcessor.java
Created December 2, 2019 20:12
ElasticSearch Bulk Processor
/**
* A component that takes care of the bulking of elasticsearch indexing requests to accommodate near-real-time indexing
*
* It executes indexing requests when either a time limit or a size limit is reached.
* It avoids blocking the current thread that inserts the records to be indexed.
*/
@Component
public class ESBulkProcessor {
private static final Logger logger = LoggerFactory.getLogger(ESBulkProcessor.class);
@slava-vishnyakov
slava-vishnyakov / readme.md
Last active March 28, 2025 07:52
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

/**
 * Matches following attributes in Markdown-typed image: [, alt, src, title]
 *
@brntbeer
brntbeer / phabricator-mercurial-github-comparison.md
Created June 18, 2019 13:59
github vs phabricator and mercurial

Feature Matrix

UI for adding/removing files
Feature GitHub Phabricator Notes
## Code
@RBusarow
RBusarow / TestCoroutineExtension.kt
Last active November 20, 2023 19:03
A JUnit 4 Rule and JUnit 5 Extension for utilizing TestCoroutineDispatcher and TestCoroutineScope from kotlinx.coroutines-test
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.TestCoroutineScope
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import org.junit.jupiter.api.extension.AfterAllCallback
import org.junit.jupiter.api.extension.AfterEachCallback
import org.junit.jupiter.api.extension.BeforeAllCallback
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.jupiter.api.extension.ExtensionContext
@lisawolderiksen
lisawolderiksen / git-commit-template.md
Last active April 24, 2025 02:56
Use a Git commit message template to write better commit messages

Using Git Commit Message Templates to Write Better Commit Messages

The always enthusiastic and knowledgeable mr. @jasaltvik shared with our team an article on writing (good) Git commit messages: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the

@steklopod
steklopod / WebTestClient.kt
Created December 19, 2018 10:43
Example of junit 5 WebTestClient on Kotlin
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.extension.ExtendWith
@Rich-Harris
Rich-Harris / what-is-svelte.md
Last active March 20, 2025 20:49
The truth about Svelte

I've been deceiving you all. I had you believe that Svelte was a UI framework — unlike React and Vue etc, because it shifts work out of the client and into the compiler, but a framework nonetheless.

But that's not exactly accurate. In my defense, I didn't realise it myself until very recently. But with Svelte 3 around the corner, it's time to come clean about what Svelte really is.

Svelte is a language.

Specifically, Svelte is an attempt to answer a question that many people have asked, and a few have answered: what would it look like if we had a language for describing reactive user interfaces?

A few projects that have answered this question:

@fay59
fay59 / Quirks of C.md
Last active April 3, 2025 02:27
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;