Skip to content

Instantly share code, notes, and snippets.

@antonkatz
antonkatz / array-vs-generator-perf.js
Created September 12, 2020 16:09
Performance of for-of given an array vs a generator
function getNumberArray(maxValue) {
const a = [];
let i = 0
for (i = 0; i < maxValue; i++) {
a.push(i);
}
return a;
}
@antonkatz
antonkatz / watson-pomodoro.sh
Created January 8, 2020 18:34
This script turns watson into a pomodoro timer. It takes a single argument: time in minutes for the pomodoro sprint. The rest are passed to `watson start`. Once the timer is up, it activetes the shell in which it's running, and asks the user to press `Enter` to stop watson.
# getting the duration in minutes, and shifting the arguments, which will be all passed to watson
DURATION=$1
shift
echo "Setting pomodoro for ${DURATION} minutes"
WINDOW_DECIMAL_ID=`xdotool getwindowfocus`
WINDOW_ID=`printf '0x%x\n' ${WINDOW_DECIMAL_ID}`
watson start "$@"
import {OpR} from "./types"
import {PlayId} from "@honest-news/data-types/gameplay"
import {logDescriptor} from "./logTable"
import {nSQL} from "@nano-sql/core"
const TABLE_NAME = 'descriptor'
export const TABLE_DESCRIPTOR = {
name: TABLE_NAME,
model: {
'id:uuid': {pk: true},
private Set<Feature> features = new TreeSet<SearchRequestFeature>();
//Gives an error "Incompatiable types".
//Even though
public class SearchRequestFeature implements Feature
//WAT?
@antonkatz
antonkatz / gist:9518028
Created March 12, 2014 22:39
ExternalServerConfigurationClass.xml
humanReadableName :String
remoteAuthToken :String
baseUrl :String
responseFormat :String //If it is decided to keep it here, rather than in individual requests
/**
* Whether or not this server is automatically accepted by requesting/external server.
* Alternative name - canSendRequests.
*/
mutuallyAccepted :Boolean
Session session = this.sessionFactory.getSessionFactory().openSession();
c = session.createCriteria(Connection.class);
connection = new Connection(this.publicPatientSimilarityViewFactory.convert(patientPair));
c.add(Example.create(connection).excludeProperty("id"));
Session session = this.sessionFactory.getSessionFactory().openSession();
return (Connection) session.load(Connection.class, id);
/**
* So after a little bit of research into Hibernate and Entities,
@Override
public String getExternalId()
{
try {
for (Object identifierUncast : this.getData("identifiers")) {
Map.Entry<String, String> identifier = (Map.Entry<String, String>) identifierUncast;
if (identifier.getKey().equalsIgnoreCase("external_id")){
return identifier.getValue();
}
}