Skip to content

Instantly share code, notes, and snippets.

@tigerhawkvok
tigerhawkvok / poetry-convert.py
Last active December 11, 2024 16:22
Convert a requirements.txt file to a Poetry project
#!python3
"""
Convert a requirements.txt file to a Poetry project.
Just place in the root of your working directory and run!
"""
sourceFile = "./requirements.txt"
import re
import os
@Isabellle
Isabellle / RecyclerViewListener.java
Created May 13, 2016 09:41
Get clicked item and its position in RecyclerView
//Based on the link: Why doesn't RecyclerView have onItemClickListener()? and How RecyclerView is different from Listview?, and also @Duncan's general idea, I give my solution here:
//define one interface 'RecyclerViewClickListener' for passing message from adapter to Activity/Fragment:
public interface RecyclerViewClickListener
{
public void recyclerViewListClicked(View v, int position);
}
//In Activity/Fragment implement the interface, and also pass listener to adapter:
@Override
@amadamala
amadamala / HashTable.java
Last active June 28, 2022 03:55
HashTable implementation in Java
public class HashTable {
private static int INITIAL_SIZE = 16;
private HashEntry[] entries = new HashEntry[INITIAL_SIZE];
public void put(String key, String value) {
int hash = getHash(key);
final HashEntry hashEntry = new HashEntry(key, value);
if(entries[hash] == null) {
entries[hash] = hashEntry;
}
// If there is already an entry at current hash